optparse_plus 0.0.2 → 0.0.3
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
 - data/lib/optparse_plus.rb +15 -1
 - data/lib/optparse_plus/version.rb +1 -1
 - data/spec/optparse_plus_spec.rb +39 -4
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3693fb720be2610cf8f3e4db42bf283ae69915cc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0536ecccb3b06f50370e9cf942016870990c9aa9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a23180b4ab19f2992fae316108b0e9b485bf4af7094451c3019c68591b101892b9939d1398220e3718b300b382c49cb04d29ba664bba34bffc145789691b4e9a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6c187ecf02b1edbc83c88d1bfb5426f102b1c2d4987890d7209a5f37f345466a99b5c1d75b59168b9f14ac74487b82b2d0cd0e59f5e73796a9c340142aee7fc7
         
     | 
    
        data/lib/optparse_plus.rb
    CHANGED
    
    | 
         @@ -16,7 +16,7 @@ module OptparsePlus 
     | 
|
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                def new_with_yaml(config_yaml_source=nil)
         
     | 
| 
       19 
     | 
    
         
            -
                  cur_file = caller[0] 
     | 
| 
      
 19 
     | 
    
         
            +
                  cur_file = extract_cur_file_path(caller[0])
         
     | 
| 
       20 
20 
     | 
    
         
             
                  config_yaml_source ||= read_after_program_end(cur_file)
         
     | 
| 
       21 
21 
     | 
    
         
             
                  opt = OptPlus.create_opt(config_yaml_source)
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
         @@ -26,6 +26,20 @@ module OptparsePlus 
     | 
|
| 
       26 
26 
     | 
    
         
             
                    opt
         
     | 
| 
       27 
27 
     | 
    
         
             
                  end
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                def windows?
         
     | 
| 
      
 31 
     | 
    
         
            +
                  /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                private
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                def extract_cur_file_path(caller_info)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if windows? and /\A[A-Z]:/i =~ caller_info
         
     | 
| 
      
 38 
     | 
    
         
            +
                    caller_info.split(/:/, 3)[0, 2].join(':')
         
     | 
| 
      
 39 
     | 
    
         
            +
                  else
         
     | 
| 
      
 40 
     | 
    
         
            +
                    caller_info.split(/:/)[0]
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
       29 
43 
     | 
    
         
             
              end
         
     | 
| 
       30 
44 
     | 
    
         | 
| 
       31 
45 
     | 
    
         
             
              class OptPlus
         
     | 
    
        data/spec/optparse_plus_spec.rb
    CHANGED
    
    | 
         @@ -230,10 +230,17 @@ YAML 
     | 
|
| 
       230 
230 
     | 
    
         
             
                end
         
     | 
| 
       231 
231 
     | 
    
         | 
| 
       232 
232 
     | 
    
         
             
                describe '#inherit_ruby_options' do
         
     | 
| 
       233 
     | 
    
         
            -
                   
     | 
| 
       234 
     | 
    
         
            -
                    external_encoding = Encoding.default_external
         
     | 
| 
       235 
     | 
    
         
            -
                    internal_encoding = Encoding.default_internal
         
     | 
| 
      
 233 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 234 
     | 
    
         
            +
                    @external_encoding = Encoding.default_external
         
     | 
| 
      
 235 
     | 
    
         
            +
                    @internal_encoding = Encoding.default_internal
         
     | 
| 
      
 236 
     | 
    
         
            +
                  end
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                  after do
         
     | 
| 
      
 239 
     | 
    
         
            +
                    Encoding.default_external = @external_encoding
         
     | 
| 
      
 240 
     | 
    
         
            +
                    Encoding.default_internal = @internal_encoding
         
     | 
| 
      
 241 
     | 
    
         
            +
                  end
         
     | 
| 
       236 
242 
     | 
    
         | 
| 
      
 243 
     | 
    
         
            +
                  it 'can add -E option' do
         
     | 
| 
       237 
244 
     | 
    
         
             
                    Encoding.default_external = 'UTF-8'
         
     | 
| 
       238 
245 
     | 
    
         
             
                    expect(Encoding.default_external).to eq(Encoding::UTF_8)
         
     | 
| 
       239 
246 
     | 
    
         | 
| 
         @@ -244,7 +251,35 @@ YAML 
     | 
|
| 
       244 
251 
     | 
    
         
             
                    end
         
     | 
| 
       245 
252 
     | 
    
         | 
| 
       246 
253 
     | 
    
         
             
                    expect(Encoding.default_external).to eq(Encoding::Windows_31J)
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
      
 254 
     | 
    
         
            +
                  end
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
                  it '-E option accepts an internal only arguement such as -E:Windows-31J' do
         
     | 
| 
      
 257 
     | 
    
         
            +
                    Encoding.default_internal = 'UTF-8'
         
     | 
| 
      
 258 
     | 
    
         
            +
                    expect(Encoding.default_internal).to eq(Encoding::UTF_8)
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                    set_argv("-E:Windows-31J")
         
     | 
| 
      
 261 
     | 
    
         
            +
                    OptionParser.new_with_yaml(@config_yaml_with_banner) do |opt|
         
     | 
| 
      
 262 
     | 
    
         
            +
                      opt.inherit_ruby_options("E")
         
     | 
| 
      
 263 
     | 
    
         
            +
                      opt.parse!
         
     | 
| 
      
 264 
     | 
    
         
            +
                    end
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
                    expect(Encoding.default_internal).to eq(Encoding::Windows_31J)
         
     | 
| 
      
 267 
     | 
    
         
            +
                  end
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
                  it '-E option can set external and internal encodings at once' do
         
     | 
| 
      
 270 
     | 
    
         
            +
                    Encoding.default_external = 'UTF-8'
         
     | 
| 
      
 271 
     | 
    
         
            +
                    Encoding.default_internal = 'UTF-8'
         
     | 
| 
      
 272 
     | 
    
         
            +
                    expect(Encoding.default_external).to eq(Encoding::UTF_8)
         
     | 
| 
      
 273 
     | 
    
         
            +
                    expect(Encoding.default_internal).to eq(Encoding::UTF_8)
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                    set_argv("-EWindows-31J:Windows-31J")
         
     | 
| 
      
 276 
     | 
    
         
            +
                    OptionParser.new_with_yaml(@config_yaml_with_banner) do |opt|
         
     | 
| 
      
 277 
     | 
    
         
            +
                      opt.inherit_ruby_options("E")
         
     | 
| 
      
 278 
     | 
    
         
            +
                      opt.parse!
         
     | 
| 
      
 279 
     | 
    
         
            +
                    end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                    expect(Encoding.default_external).to eq(Encoding::Windows_31J)
         
     | 
| 
      
 282 
     | 
    
         
            +
                    expect(Encoding.default_internal).to eq(Encoding::Windows_31J)
         
     | 
| 
       248 
283 
     | 
    
         
             
                  end
         
     | 
| 
       249 
284 
     | 
    
         | 
| 
       250 
285 
     | 
    
         
             
                  it 'expect to print help message' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: optparse_plus
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - HASHIMOTO, Naoki
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-10-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |