optparse-subcommand 1.0.0.pre.2 → 1.0.0
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 +7 -0
- data/lib/optparse/subcommand.rb +16 -3
- data/spec/optparse/subcommand_spec.rb +2 -0
- metadata +25 -20
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: a4ddc7b210db174e4e63ff97c3e2d14ed6f87304
         | 
| 4 | 
            +
              data.tar.gz: e182abc38c419b3750143a059bf46c41b72b0415
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 975a977839672edd73731a579ff68526f67cb14f27d0665a6211b51eb8e52ad14dc2a6d370c7861c951dd58de0a64e3763d3022cc968b82bd5493007bc8889ba
         | 
| 7 | 
            +
              data.tar.gz: ab3839a5cb7b988ba74d54345585cee27135f29fc7f09a5138f444b0ca91164f86fc21b64405a1e127ec096a2bba2dc53e63aa262a913a4961de5fd38258aeac
         | 
    
        data/lib/optparse/subcommand.rb
    CHANGED
    
    | @@ -14,16 +14,29 @@ class OptionParser | |
| 14 14 | 
             
                    alias_method :parse_without_subcommand!, :parse!
         | 
| 15 15 | 
             
                    alias_method :parse!, :parse_with_subcommand!
         | 
| 16 16 | 
             
                    public :parse!
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    alias_method :summarize_without_subcommand, :summarize
         | 
| 19 | 
            +
                    alias_method :summarize, :summarize_with_subcommand
         | 
| 17 20 | 
             
                  end
         | 
| 18 21 | 
             
                end
         | 
| 19 22 |  | 
| 20 | 
            -
                def parse_with_subcommand!( | 
| 23 | 
            +
                def parse_with_subcommand!(*args)
         | 
| 21 24 | 
             
                  subcommand = catch(:subcommand) do
         | 
| 22 | 
            -
                    return order!( | 
| 25 | 
            +
                    return order!(*args) { |sub| throw :subcommand, sub }
         | 
| 23 26 | 
             
                  end
         | 
| 24 27 |  | 
| 25 28 | 
             
                  sub_parser = subcommands[subcommand.to_s]
         | 
| 26 | 
            -
                  sub_parser.call.send(:parse!,  | 
| 29 | 
            +
                  sub_parser.call.send(:parse!, *args) if sub_parser
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def summarize_with_subcommand(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
         | 
| 33 | 
            +
                  summarize_without_subcommand(to, width, max, indent, &blk)
         | 
| 34 | 
            +
                  to << "\n"
         | 
| 35 | 
            +
                  subcommands.each do |key, sub_parser|
         | 
| 36 | 
            +
                    to << indent + key + "\n"
         | 
| 37 | 
            +
                    sub_parser.call.send(:summarize,to,width,max,indent + "  ",&blk)
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                  to
         | 
| 27 40 | 
             
                end
         | 
| 28 41 |  | 
| 29 42 | 
             
                def subcommands
         | 
    
        metadata
    CHANGED
    
    | @@ -1,38 +1,43 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: optparse-subcommand
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0 | 
| 5 | 
            -
              prerelease: 6
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 | 
            -
            -  | 
| 7 | 
            +
            - Bo Jeanes
         | 
| 9 8 | 
             
            autorequire: optparse/subcommand
         | 
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 11 | 
            +
            date: 2017-04-08 00:00:00.000000000 Z
         | 
| 13 12 | 
             
            dependencies:
         | 
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: rake
         | 
| 16 | 
            -
              requirement:  | 
| 17 | 
            -
                none: false
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 18 16 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 17 | 
            +
                - - "~>"
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: '0'
         | 
| 19 | 
            +
                    version: '12.0'
         | 
| 22 20 | 
             
              type: :development
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '12.0'
         | 
| 25 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 28 | 
             
              name: rspec
         | 
| 27 | 
            -
              requirement:  | 
| 28 | 
            -
                none: false
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 29 30 | 
             
                requirements:
         | 
| 30 | 
            -
                - - =
         | 
| 31 | 
            +
                - - '='
         | 
| 31 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 33 | 
             
                    version: 2.9.0
         | 
| 33 34 | 
             
              type: :development
         | 
| 34 35 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - '='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: 2.9.0
         | 
| 36 41 | 
             
            description: Add subcommand parsing to Ruby's OptionParser class
         | 
| 37 42 | 
             
            email: me@bjeanes.com
         | 
| 38 43 | 
             
            executables: []
         | 
| @@ -44,26 +49,26 @@ files: | |
| 44 49 | 
             
            - lib/optparse/subcommand.rb
         | 
| 45 50 | 
             
            - spec/optparse/subcommand_spec.rb
         | 
| 46 51 | 
             
            homepage: http://github.com/bjeanes/optparse-subcommand
         | 
| 47 | 
            -
            licenses: | 
| 52 | 
            +
            licenses:
         | 
| 53 | 
            +
            - MIT
         | 
| 54 | 
            +
            metadata: {}
         | 
| 48 55 | 
             
            post_install_message: 
         | 
| 49 56 | 
             
            rdoc_options: []
         | 
| 50 57 | 
             
            require_paths:
         | 
| 51 58 | 
             
            - lib
         | 
| 52 59 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 53 | 
            -
              none: false
         | 
| 54 60 | 
             
              requirements:
         | 
| 55 | 
            -
              - -  | 
| 61 | 
            +
              - - ">="
         | 
| 56 62 | 
             
                - !ruby/object:Gem::Version
         | 
| 57 63 | 
             
                  version: '0'
         | 
| 58 64 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 59 | 
            -
              none: false
         | 
| 60 65 | 
             
              requirements:
         | 
| 61 | 
            -
              - -  | 
| 66 | 
            +
              - - ">="
         | 
| 62 67 | 
             
                - !ruby/object:Gem::Version
         | 
| 63 | 
            -
                  version:  | 
| 68 | 
            +
                  version: '0'
         | 
| 64 69 | 
             
            requirements: []
         | 
| 65 70 | 
             
            rubyforge_project: 
         | 
| 66 | 
            -
            rubygems_version:  | 
| 71 | 
            +
            rubygems_version: 2.5.2
         | 
| 67 72 | 
             
            signing_key: 
         | 
| 68 73 | 
             
            specification_version: 3
         | 
| 69 74 | 
             
            summary: Add subcommand parsing to Ruby's OptionParser class
         |