xml_schema_mapper 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -4
 - data/lib/thor/xsd_mappers.rb +1 -32
 - data/lib/xml_schema_mapper/version.rb +1 -1
 - metadata +2 -2
 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -1,8 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            source 'https://rubygems.org'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            gem  
     | 
| 
       5 
     | 
    
         
            -
            gem  
     | 
| 
       6 
     | 
    
         
            -
            gem "libxml-ruby", :path => '../libxml-ruby/'
         
     | 
| 
      
 3 
     | 
    
         
            +
            gem 'libxml-ruby', git: 'https://github.com/webgago/libxml-ruby.git', branch: 'schema-interface'
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem 'virtus'
         
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'thor'
         
     | 
| 
       7 
6 
     | 
    
         
             
            # Specify your gem's dependencies in xml_schema_mapper.gemspec
         
     | 
| 
       8 
7 
     | 
    
         
             
            gemspec
         
     | 
    
        data/lib/thor/xsd_mappers.rb
    CHANGED
    
    | 
         @@ -6,20 +6,17 @@ module XsdMappers 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                desc 'generate path/to/xsd', 'generate mappers for xsd types'
         
     | 
| 
       8 
8 
     | 
    
         
             
                method_option :module_name, default: ''
         
     | 
| 
       9 
     | 
    
         
            -
                method_option :converter_module_name, default: ''
         
     | 
| 
       10 
     | 
    
         
            -
                method_option :'skip-converters', type: :boolean
         
     | 
| 
       11 
9 
     | 
    
         | 
| 
       12 
10 
     | 
    
         
             
                def generate(schema_path)
         
     | 
| 
       13 
11 
     | 
    
         
             
                  schema(schema_path).types.each do |name, _|
         
     | 
| 
       14 
12 
     | 
    
         
             
                    Mappers.new([name, schema_path], options).invoke_all
         
     | 
| 
       15 
     | 
    
         
            -
                    Converters.new([name, schema_path], options).invoke_all unless options[:'skip-converters']
         
     | 
| 
       16 
13 
     | 
    
         
             
                  end
         
     | 
| 
       17 
14 
     | 
    
         
             
                end
         
     | 
| 
       18 
15 
     | 
    
         | 
| 
       19 
16 
     | 
    
         
             
                protected
         
     | 
| 
       20 
17 
     | 
    
         | 
| 
       21 
18 
     | 
    
         
             
                def schema(path)
         
     | 
| 
       22 
     | 
    
         
            -
                  @schema  
     | 
| 
      
 19 
     | 
    
         
            +
                  @schema = LibXML::XML::Schema.cached(path)
         
     | 
| 
       23 
20 
     | 
    
         
             
                end
         
     | 
| 
       24 
21 
     | 
    
         | 
| 
       25 
22 
     | 
    
         
             
              end
         
     | 
| 
         @@ -105,32 +102,4 @@ module XsdMappers 
     | 
|
| 
       105 
102 
     | 
    
         
             
                  "#{module_name}#{class_name}"
         
     | 
| 
       106 
103 
     | 
    
         
             
                end
         
     | 
| 
       107 
104 
     | 
    
         
             
              end
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
              class Converters < Mappers
         
     | 
| 
       110 
     | 
    
         
            -
                class_option :attributes, type: :array
         
     | 
| 
       111 
     | 
    
         
            -
                class_option :converter_module_name, default: ""
         
     | 
| 
       112 
     | 
    
         
            -
                class_option :force, default: false
         
     | 
| 
       113 
     | 
    
         
            -
                class_option :skip, default: true
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                def module_path
         
     | 
| 
       116 
     | 
    
         
            -
                  options[:converter_module_name] ? options[:converter_module_name].underscore : ""
         
     | 
| 
       117 
     | 
    
         
            -
                end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                def create_lib_file
         
     | 
| 
       120 
     | 
    
         
            -
                  filename = "#{name.underscore}_converter.rb"
         
     | 
| 
       121 
     | 
    
         
            -
                  template('templates/converter_class.erb', File.join('app/converters/', module_path, filename))
         
     | 
| 
       122 
     | 
    
         
            -
                end
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
                def create_test_file
         
     | 
| 
       125 
     | 
    
         
            -
                  test     = options[:test_framework] == "test" ? :test : :spec
         
     | 
| 
       126 
     | 
    
         
            -
                  filename = "#{name.underscore}_converter_#{test}.rb"
         
     | 
| 
       127 
     | 
    
         
            -
                  with_padding do
         
     | 
| 
       128 
     | 
    
         
            -
                    template 'templates/converter_spec.erb', File.join("#{test}/converters/", module_path, filename)
         
     | 
| 
       129 
     | 
    
         
            -
                  end
         
     | 
| 
       130 
     | 
    
         
            -
                end
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                def converter_name
         
     | 
| 
       133 
     | 
    
         
            -
                  "#{name.underscore.camelize}Converter"
         
     | 
| 
       134 
     | 
    
         
            -
                end
         
     | 
| 
       135 
     | 
    
         
            -
              end
         
     | 
| 
       136 
105 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -2,14 +2,14 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            name: xml_schema_mapper
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 5 
     | 
    
         
            +
              version: 0.0.6
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Anton Sozontov
         
     | 
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-02-27 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     |