Class: Trevl::Processor
- Inherits:
-
Object
- Object
- Trevl::Processor
- Defined in:
- lib/trevl/processor.rb
Instance Attribute Summary collapse
-
#parse_errors ⇒ Object
readonly
Returns the value of attribute parse_errors.
-
#processed_content ⇒ Object
readonly
Returns the value of attribute processed_content.
-
#trevl_content ⇒ Object
readonly
Returns the value of attribute trevl_content.
Class Method Summary collapse
Instance Method Summary collapse
- #component_yaml_content ⇒ Object
- #components ⇒ Object
- #full_yaml_content ⇒ Object
-
#initialize(trevl_content) ⇒ Processor
constructor
A new instance of Processor.
- #valid? ⇒ Boolean
Constructor Details
#initialize(trevl_content) ⇒ Processor
Returns a new instance of Processor.
7 8 9 10 11 |
# File 'lib/trevl/processor.rb', line 7 def initialize(trevl_content) @trevl_content = trevl_content @parse_errors = [] @processed_content = process_content end |
Instance Attribute Details
#parse_errors ⇒ Object (readonly)
Returns the value of attribute parse_errors.
5 6 7 |
# File 'lib/trevl/processor.rb', line 5 def parse_errors @parse_errors end |
#processed_content ⇒ Object (readonly)
Returns the value of attribute processed_content.
5 6 7 |
# File 'lib/trevl/processor.rb', line 5 def processed_content @processed_content end |
#trevl_content ⇒ Object (readonly)
Returns the value of attribute trevl_content.
5 6 7 |
# File 'lib/trevl/processor.rb', line 5 def trevl_content @trevl_content end |
Class Method Details
.from_hash(trevl_hash) ⇒ Object
13 14 15 |
# File 'lib/trevl/processor.rb', line 13 def self.from_hash(trevl_hash) new(trevl_hash.to_yaml) end |
Instance Method Details
#component_yaml_content ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/trevl/processor.rb', line 21 def component_yaml_content comps = @processed_content["components"] stringified = if comps.is_a?(Array) comps.map { |c| c.is_a?(Hash) ? CoreExt::Hash.deep_stringify_keys(c) : c } else comps end YAML.dump(stringified, canonical: false) end |
#components ⇒ Object
17 18 19 |
# File 'lib/trevl/processor.rb', line 17 def components @processed_content["components"] end |
#full_yaml_content ⇒ Object
31 32 33 |
# File 'lib/trevl/processor.rb', line 31 def full_yaml_content YAML.dump(CoreExt::Hash.deep_stringify_keys(@processed_content), canonical: false) end |
#valid? ⇒ Boolean
35 36 37 |
# File 'lib/trevl/processor.rb', line 35 def valid? @parse_errors.empty? end |