Class: DTK::DSL::FileParser
- Inherits:
-
Object
- Object
- DTK::DSL::FileParser
- Defined in:
- lib/dsl/file_parser.rb,
lib/dsl/file_parser/input.rb,
lib/dsl/file_parser/output.rb,
lib/dsl/file_parser/input/hash.rb,
lib/dsl/file_parser/input/array.rb
Defined Under Namespace
Class Method Summary collapse
- .file_ref_in_error(file_obj) ⇒ Object
-
.parse_content(parse_template_type, file_obj, opts = {}) ⇒ Object
opts can have keys: :dsl_version.
- .yaml_parse!(file_obj) ⇒ Object
Class Method Details
.file_ref_in_error(file_obj) ⇒ Object
52 53 54 |
# File 'lib/dsl/file_parser.rb', line 52 def self.file_ref_in_error(file_obj) (file_obj && file_obj.path?) ? " in file #{file_obj.path?}" : '' end |
.parse_content(parse_template_type, file_obj, opts = {}) ⇒ Object
opts can have keys:
:dsl_version
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dsl/file_parser.rb', line 28 def self.parse_content(parse_template_type, file_obj, opts = {}) ret = Output.create(:output_type => :hash) return ret unless file_obj.content? input_hash = yaml_parse!(file_obj) dsl_version = opts[:dsl_version] || dsl_version__raise_error_if_illegal(input_hash, file_obj) # parsing with respect to the parse_template_type template_class = Template.template_class(parse_template_type, dsl_version) template_class.create_for_parsing(input_hash, :file_obj => file_obj).parse end |
.yaml_parse!(file_obj) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dsl/file_parser.rb', line 40 def self.yaml_parse!(file_obj) if file_obj.respond_to?(:yaml_parse_hash) if ret = file_obj.yaml_parse_hash ret else file_obj.yaml_parse_hash = YamlHelper.parse(file_obj) end else YamlHelper.parse(file_obj) end end |