Class: MarkdownRecord::Rendering::Nodes::JsonDirectory

Inherits:
JsonBase
  • Object
show all
Defined in:
lib/markdown_record/rendering/nodes/json_directory.rb

Constant Summary

Constants included from ContentDsl

ContentDsl::HTML_COMMENT_REGEX

Constants included from ContentDsl::Enable

ContentDsl::Enable::ENCODED_REGEX, ContentDsl::Enable::REGEX

Constants included from ContentDsl::Disable

ContentDsl::Disable::ENCODED_REGEX, ContentDsl::Disable::REGEX

Constants included from ContentDsl::UseLayout

ContentDsl::UseLayout::ENCODED_REGEX, ContentDsl::UseLayout::REGEX

Constants included from ContentDsl::Fragment

ContentDsl::Fragment::ENCODED_REGEX, ContentDsl::Fragment::REGEX

Constants included from ContentDsl::DirectoryFragment

ContentDsl::DirectoryFragment::ENCODED_REGEX, ContentDsl::DirectoryFragment::REGEX

Constants included from ContentDsl::EndModel

ContentDsl::EndModel::ENCODED_REGEX, ContentDsl::EndModel::REGEX

Constants included from ContentDsl::EndAttribute

ContentDsl::EndAttribute::ENCODED_REGEX, ContentDsl::EndAttribute::REGEX

Constants included from ContentDsl::Attribute

ContentDsl::Attribute::ENCODED_REGEX, ContentDsl::Attribute::REGEX

Constants included from ContentDsl::Model

ContentDsl::Model::ENCODED_REGEX, ContentDsl::Model::REGEX

Constants included from ContentDsl::Scope

ContentDsl::Scope::ENCODED_REGEX, ContentDsl::Scope::REGEX

Instance Attribute Summary

Attributes inherited from JsonBase

#concatenated, #json_models, #name

Instance Method Summary collapse

Methods inherited from JsonBase

#add_content_fragment, #save

Methods included from ContentDsl

#remove_html_dsl_command, #remove_json_dsl_commands

Methods included from ContentDsl::Enable

#enable_dsl, remove_dsl

Methods included from ContentDsl::Disable

#disable_dsl, remove_dsl

Methods included from ContentDsl::UseLayout

remove_dsl, #use_layout_dsl

Methods included from ContentDsl::Fragment

#fragment_dsl, remove_dsl

Methods included from ContentDsl::DirectoryFragment

#directory_fragment_dsl, remove_dsl

Methods included from ContentDsl::EndModel

#end_model_dsl, remove_dsl

Methods included from ContentDsl::EndAttribute

#end_attribute_dsl, remove_dsl

Methods included from ContentDsl::Attribute

#attribute_dsl, remove_dsl

Methods included from ContentDsl::Model

#model_dsl, remove_dsl

Methods included from ContentDsl::Scope

remove_dsl, #scope_dsl

Methods included from PathUtilities

#base_content_root_name, #base_rendered_path, #base_rendered_root, #clean_path, #erb_locals_from_path, #fragment_attributes_from_path, #full_path_to_parts, #path_to_fragment_id, #remove_prefix, #rendered_path, #scoped_id_to_parts, #to_scoped_id

Constructor Details

#initialize(pathname, options, top_level = false) ⇒ JsonDirectory

Returns a new instance of JsonDirectory.



6
7
8
9
10
# File 'lib/markdown_record/rendering/nodes/json_directory.rb', line 6

def initialize(pathname, options, top_level = false)
  super(pathname, options)
  @concatenated = true
  @top_level = top_level
end

Instance Method Details

#fragment_metaObject



27
28
29
# File 'lib/markdown_record/rendering/nodes/json_directory.rb', line 27

def fragment_meta
  @fragment_meta ||= children.select {|c| c.respond_to?(:directory_meta) }.reduce({}) { |meta, child| meta.merge(child.directory_meta) }
end

#render(file_saver, inherited_scope = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/markdown_record/rendering/nodes/json_directory.rb', line 12

def render(file_saver, inherited_scope = nil)
  # Only override scope if this directory
  # doesn't have its own scope defined
  # First call to scope will search files
  # and get the scope if defined.
  @scope = inherited_scope unless scope

  children.each do |child|
    child.render(file_saver, scope)
  end

  concatenate_json
  save(file_saver) if @options[:concat] || (@options[:concat_top_level] && @top_level)
end

#scopeObject



31
32
33
# File 'lib/markdown_record/rendering/nodes/json_directory.rb', line 31

def scope
  @scope ||= children.select {|c| c.respond_to?(:directory_scope) }.find(&:directory_scope)&.directory_scope
end