argparser 1.0.0 → 1.0.1

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.
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+ rescue LoadError
5
+ $stderr.puts "CodeClimate is not started: #{$!.message}"
6
+ end
7
+
8
+ require 'minitest/autorun'
9
+ require 'argparser'
10
+
11
+ class ExitStub < RuntimeError
12
+ attr_accessor :status
13
+ def initialize(status, message)
14
+ @status = status
15
+ super(message)
16
+ end
17
+ end
18
+
19
+ class ArgParser
20
+ def on_exit(status, message)
21
+ raise ExitStub.new(status, message)
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require 'spec_helper'
3
+ require 'argparser/tools'
4
+
5
+ class StubClass
6
+ include ArgParser::Tools
7
+ attr_reader :hash
8
+ attr_reader :array
9
+ attr_reader :value
10
+ end
11
+
12
+ describe 'hash behaviour' do
13
+ before do
14
+ @hash = { :array => [StubClass.new, StubClass.new],
15
+ :hash => {'foo' => 1, 'bar' => 2},
16
+ :value => 'foo' }
17
+ end
18
+
19
+ it 'allows to pack/unpack' do
20
+ obj1 = StubClass.new.hash2vars!(@hash)
21
+ hash = obj1.to_hash
22
+ obj2 = StubClass.new.hash2vars!(hash)
23
+ obj1.hash.each{|k, v| obj2.hash[k].must_equal(v)}
24
+ obj1.array.must_equal(obj2.array)
25
+ obj1.value.must_equal(obj2.value)
26
+ obj1.wont_be_same_as(obj2)
27
+ end
28
+ end
metadata CHANGED
@@ -1,27 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-03 00:00:00.000000000 Z
12
- dependencies: []
13
- description: "== Trying to follow POSIX and GNU guidelines"
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4'
55
+ description: "== Yet another ruby command line argument parser library"
14
56
  email: sinm.sinm@gmail.com
15
57
  executables: []
16
58
  extensions: []
17
59
  extra_rdoc_files: []
18
60
  files:
19
61
  - ".gitignore"
62
+ - ".hound.yml"
63
+ - ".rubocop.yml"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - HISTORY.md
20
67
  - LICENSE.txt
21
68
  - README.md
69
+ - Rakefile
22
70
  - argparser.gemspec
71
+ - argparser.sublime-project
23
72
  - lib/argparser.rb
24
- - lib/argparser/examples/example.rb
73
+ - lib/argparser/default_parser.rb
74
+ - lib/argparser/option.rb
75
+ - lib/argparser/tools.rb
76
+ - spec/argparser_spec.rb
77
+ - spec/spec_helper.rb
78
+ - spec/tools_spec.rb
25
79
  homepage: https://github.com/sinm/argparser
26
80
  licenses:
27
81
  - MIT
@@ -45,6 +99,8 @@ rubyforge_project:
45
99
  rubygems_version: 2.2.2
46
100
  signing_key:
47
101
  specification_version: 4
48
- summary: Command line argument parser
49
- test_files: []
50
- has_rdoc:
102
+ summary: Yet another ruby command line argument parser library
103
+ test_files:
104
+ - spec/argparser_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/tools_spec.rb
@@ -1,32 +0,0 @@
1
- require 'argparser'
2
- args= ArgParser.new( # Here goes the manifest.
3
- :program => 'example.rb', # Use additional properties like these:
4
- :version => '1.0', # :info, :copyright, :license,
5
- :options => [{ # :package, :bugs, :homepage
6
- :names => %w[m mode],
7
- :argument => 'first|second|third',
8
- :default => 'first',
9
- :multiple => true,
10
- :help => 'Example mode.',
11
- :validate => (lambda {|this, parser| # Validating value in-line
12
- possible = this.argument.split('|')
13
- this.value.select{|v| possible.include?(v)}.size == this.value.size })
14
- }, {
15
- :names => 'file',
16
- :input => true,
17
- :required => true,
18
- :help => 'Filename or - for stdin.',
19
- :validate => (lambda {|this, parser|
20
- if this.value == '-'
21
- this.value = $stdin.read
22
- else
23
- parser.terminate(2, 'No such file') unless File.exists?(this.value)
24
- this.value = File.read(this.value)
25
- end
26
- true })
27
- }]
28
- ).parse! # Uses ARGV by default, you may supply your own arguments.
29
- # It exits if bad arguments given or they aren't validated.
30
-
31
- puts args['mode'].value.inspect # So we could use our options...
32
- puts args['file'].value # Prints contents of a file