Class: Yaml::Merge::FileAnalysis
- Inherits:
-
Object
- Object
- Yaml::Merge::FileAnalysis
- Includes:
- Ast::Merge::FileAnalyzable
- Defined in:
- lib/yaml/merge/file_analysis.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #documents ⇒ Object
- #fallthrough_node?(value) ⇒ Boolean
-
#initialize(source, signature_generator: nil, parser_path: nil, **_options) ⇒ FileAnalysis
constructor
A new instance of FileAnalysis.
- #root_node ⇒ Object
- #ruleset_owner_selector ⇒ Object
- #ruleset_render_family ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(source, signature_generator: nil, parser_path: nil, **_options) ⇒ FileAnalysis
Returns a new instance of FileAnalysis.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/yaml/merge/file_analysis.rb', line 10 def initialize(source, signature_generator: nil, parser_path: nil, **) @source = source @lines = source.lines.map(&:chomp) @signature_generator = signature_generator @parser_path = parser_path @errors = [] DebugLogger.time('FileAnalysis#parse_yaml') { parse_yaml } @statements = valid? ? documents : [] end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
8 9 10 |
# File 'lib/yaml/merge/file_analysis.rb', line 8 def ast @ast end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/yaml/merge/file_analysis.rb', line 8 def errors @errors end |
Instance Method Details
#documents ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yaml/merge/file_analysis.rb', line 31 def documents return [] unless valid? index = 0 @ast.root_node.children.filter_map do |child| next unless child.type.to_s == 'document' wrapper = NodeWrapper.new(child, lines: @lines, source: @source, document_index: index) index += 1 wrapper end end |
#fallthrough_node?(value) ⇒ Boolean
46 47 48 |
# File 'lib/yaml/merge/file_analysis.rb', line 46 def fallthrough_node?(value) value.is_a?(NodeWrapper) || super end |
#root_node ⇒ Object
25 26 27 28 29 |
# File 'lib/yaml/merge/file_analysis.rb', line 25 def root_node return unless valid? NodeWrapper.new(@ast.root_node, lines: @lines, source: @source) end |
#ruleset_owner_selector ⇒ Object
50 51 52 |
# File 'lib/yaml/merge/file_analysis.rb', line 50 def ruleset_owner_selector :line_bound_statements end |
#ruleset_render_family ⇒ Object
54 55 56 |
# File 'lib/yaml/merge/file_analysis.rb', line 54 def ruleset_render_family :yaml_documents_and_mappings end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/yaml/merge/file_analysis.rb', line 21 def valid? @errors.empty? && !@ast.nil? end |