optparse-simple 0.4.4 → 0.4.5
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/optparse-simple.rb +14 -9
- metadata +3 -3
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ea3a3a04d3463032d7b2c0cd3120a8999705fd5a
         | 
| 4 | 
            +
              data.tar.gz: 8c49b1a26f92d43c712ef2caf996d48d12b16c23
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9f95efa9b778a9fb9965c0d70e5fa155d7bc81a00b3acf875c43cb78d5ac9bda5137c635fec282e794216d42159eae3084a102829d694112149c3e4ac4ed649f
         | 
| 7 | 
            +
              data.tar.gz: 4ca8bfc69bfc82d4204ec470ee63cbdec94113bfbf95da78176fb775bb2c8537f305b35c330638ef6e48817527c0b30faa88c14fbc4a4c8b3421c4d4de50ede4
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        data/lib/optparse-simple.rb
    CHANGED
    
    | @@ -50,12 +50,14 @@ class OptParseSimple | |
| 50 50 | 
             
                    .map {|node|  %w(switch alias)\
         | 
| 51 51 | 
             
                      .map{|x| node.text(x)}.compact}\
         | 
| 52 52 | 
             
                    .flatten
         | 
| 53 | 
            +
                puts 'after flatten 2'
         | 
| 53 54 | 
             
                args.map!.with_index do |x,i|
         | 
| 54 55 | 
             
                  next unless x or i < args.length - 1
         | 
| 55 56 | 
             
                  (x += '=' + args[i+1]; args[i+1] = nil) if options.include?(x)
         | 
| 56 57 | 
             
                  x
         | 
| 57 58 | 
             
                end
         | 
| 58 | 
            -
                args.compact! | 
| 59 | 
            +
                args.compact!
         | 
| 60 | 
            +
             | 
| 59 61 | 
             
                # -- end of bind any loose value to their argument
         | 
| 60 62 |  | 
| 61 63 | 
             
                a1 = []
         | 
| @@ -77,8 +79,9 @@ class OptParseSimple | |
| 77 79 | 
             
                end
         | 
| 78 80 |  | 
| 79 81 | 
             
                a2 = args.zip(options_remaining).map(&:reverse)
         | 
| 82 | 
            +
                
         | 
| 80 83 | 
             
                if a2.map(&:first).all? then
         | 
| 81 | 
            -
                  @h = Hash[*(a1+a2).map{|x,y| [x.to_s.strip.to_sym, y]}.flatten]
         | 
| 84 | 
            +
                  @h = Hash[*(a1+a2).map{|x,y| [x.to_s.strip.to_sym, y || true]}.flatten]
         | 
| 82 85 | 
             
                else
         | 
| 83 86 | 
             
                  invalid_option = a2.detect {|x,y| x.nil? }.last
         | 
| 84 87 | 
             
                  raise "invalid option: %s not recognised" % invalid_option
         | 
| @@ -105,8 +108,10 @@ class OptParseSimple | |
| 105 108 | 
             
              def options_match(option, args)
         | 
| 106 109 |  | 
| 107 110 | 
             
                switch, switch_alias = option.text('summary/switch'), option.text('summary/alias')
         | 
| 108 | 
            -
                switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch | 
| 111 | 
            +
                switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch
         | 
| 112 | 
            +
             | 
| 109 113 | 
             
                switch_matched, arg_index = args.each_with_index.detect {|x,j| x[/^#{switch_pattern}/]}
         | 
| 114 | 
            +
             | 
| 110 115 | 
             
                key, value = nil
         | 
| 111 116 |  | 
| 112 117 | 
             
                if switch_matched then
         | 
| @@ -164,11 +169,11 @@ class OptParseSimple | |
| 164 169 | 
             
              end
         | 
| 165 170 |  | 
| 166 171 | 
             
              def readx(s)
         | 
| 167 | 
            -
             | 
| 168 | 
            -
                r = if s | 
| 169 | 
            -
                  Polyrex.new('options/optionx[name,switch,alias,value,mandatory]/errorx[msg]').parse(s).to_xml
         | 
| 170 | 
            -
                elsif s.is_a? Polyrex then
         | 
| 172 | 
            +
                    
         | 
| 173 | 
            +
                r = if s.is_a? Polyrex then
         | 
| 171 174 | 
             
                  s.to_xml
         | 
| 175 | 
            +
                elsif s[/\s/] then
         | 
| 176 | 
            +
                  Polyrex.new('options/optionx[name,switch,alias,value,mandatory]/errorx[msg]').parse(s).to_xml
         | 
| 172 177 | 
             
                elsif s[/^https?:\/\//] then  # url
         | 
| 173 178 | 
             
                  Kernel.open(s, 'UserAgent' => 'Polyrex-Reader').read
         | 
| 174 179 | 
             
                elsif s[/\</] # xml
         | 
| @@ -176,8 +181,8 @@ class OptParseSimple | |
| 176 181 | 
             
                else # local file
         | 
| 177 182 | 
             
                  File.read s
         | 
| 178 183 | 
             
                end    
         | 
| 179 | 
            -
             | 
| 184 | 
            +
             | 
| 180 185 | 
             
                r
         | 
| 181 186 | 
             
              end
         | 
| 182 187 |  | 
| 183 | 
            -
            end
         | 
| 188 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: optparse-simple
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4. | 
| 4 | 
            +
              version: 0.4.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - James Robertson
         | 
| @@ -31,7 +31,7 @@ cert_chain: | |
| 31 31 | 
             
              reMUqAcVi3UK52Ugibv74I27D9zJTDYgqRMX3SevcEFrJo+g8ulq9nmVLQ3T+YB/
         | 
| 32 32 | 
             
              BlF5+4+5WNopaw==
         | 
| 33 33 | 
             
              -----END CERTIFICATE-----
         | 
| 34 | 
            -
            date: 2015- | 
| 34 | 
            +
            date: 2015-07-10 00:00:00.000000000 Z
         | 
| 35 35 | 
             
            dependencies:
         | 
| 36 36 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 37 | 
             
              name: polyrex
         | 
| @@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 100 100 | 
             
                  version: '0'
         | 
| 101 101 | 
             
            requirements: []
         | 
| 102 102 | 
             
            rubyforge_project: 
         | 
| 103 | 
            -
            rubygems_version: 2. | 
| 103 | 
            +
            rubygems_version: 2.4.8
         | 
| 104 104 | 
             
            signing_key: 
         | 
| 105 105 | 
             
            specification_version: 4
         | 
| 106 106 | 
             
            summary: optparse-simple
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |