Class: Presenter::Xsd
- Inherits:
-
Object
- Object
- Presenter::Xsd
- Defined in:
- lib/presenter/xsd.rb
Instance Method Summary collapse
- #get_enums_by_type(domain_arguments) ⇒ Object
- #unique_enums(domain_arguments) ⇒ Object
- #variation_between_schema_versions?(enums_hash) ⇒ Boolean
Instance Method Details
#get_enums_by_type(domain_arguments) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/presenter/xsd.rb', line 3 def get_enums_by_type(domain_arguments) xsd_files_gateway = ViewModelGateway::XsdFilesGateway.new(domain_arguments) begin xsd_files = xsd_files_gateway.xsd_files rescue ViewModelBoundary::XsdFilesNotFound => e raise ViewModelBoundary::XsdFilesNotFound, e..to_s end hash = {} xsd_files.each do |file| enums_hash = File.extname(file).downcase == ".xsd" ? read_xsd(file, domain_arguments.simple_type) : read_xml(file, domain_arguments.simple_type, domain_arguments.node_hash) next if enums_hash.empty? hash[xsd_files_gateway.schema_version(file)] = enums_hash end raise ViewModelBoundary::NodeNotFound, "Node #{domain_arguments.simple_type} was not found in any of the files in #{domain_arguments.xsd_dir_path} directory" if hash.empty? hash end |
#unique_enums(domain_arguments) ⇒ Object
27 28 29 30 |
# File 'lib/presenter/xsd.rb', line 27 def unique_enums(domain_arguments) enums = get_enums_by_type(domain_arguments).values enums.group_by(&:inspect).values.map(&:first) end |
#variation_between_schema_versions?(enums_hash) ⇒ Boolean
32 33 34 |
# File 'lib/presenter/xsd.rb', line 32 def variation_between_schema_versions?(enums_hash) enums_hash.values.flatten.uniq.count != 1 end |