yaop 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (10) hide show
  1. data/Gemfile +3 -3
  2. data/Gemfile.lock +9 -9
  3. data/LICENSE.txt +1 -1
  4. data/README.md +2 -3
  5. data/Rakefile +2 -2
  6. data/VERSION +1 -1
  7. data/lib/yaop.rb +13 -4
  8. data/test.rb +14 -0
  9. data/yaop.gemspec +57 -0
  10. metadata +75 -58
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "hash-utils", ">= 0.1.0"
4
+ gem "hash-utils", ">= 2.0.0"
5
5
  gem "types", ">= 0.1.0"
6
6
 
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
9
9
  group :development do
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.2"
10
+ gem "bundler", ">= 1.0.0"
11
+ gem "jeweler2", ">= 2.0.0"
12
12
  end
@@ -3,13 +3,13 @@ GEM
3
3
  specs:
4
4
  abstract (1.0.0)
5
5
  git (1.2.5)
6
- hash-utils (0.15.0)
7
- jeweler (1.5.2)
8
- bundler (~> 1.0.0)
6
+ hash-utils (2.0.0)
7
+ ruby-version
8
+ jeweler2 (2.0.9)
9
9
  git (>= 1.2.5)
10
- rake
11
- multitype-introspection (0.1.2)
12
- rake (0.9.0)
10
+ multitype-introspection (0.2.0)
11
+ hash-utils (>= 0.16.0)
12
+ ruby-version (0.3.1)
13
13
  types (0.1.3)
14
14
  abstract (>= 1.0.0)
15
15
  multitype-introspection (>= 0.1.0)
@@ -18,7 +18,7 @@ PLATFORMS
18
18
  ruby
19
19
 
20
20
  DEPENDENCIES
21
- bundler (~> 1.0.0)
22
- hash-utils (>= 0.1.0)
23
- jeweler (~> 1.5.2)
21
+ bundler (>= 1.0.0)
22
+ hash-utils (>= 2.0.0)
23
+ jeweler2 (>= 2.0.0)
24
24
  types (>= 0.1.0)
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
1
+ Copyright (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -9,8 +9,7 @@ declarative approach. See example:
9
9
  require "yaop"
10
10
 
11
11
  options = YAOP::get do
12
- option "--strip"
13
- type Boolean, false # simple presency is enough
12
+ option "--strip" # simple presency is enough
14
13
 
15
14
  options "-l", "--level" # both of them
16
15
  type Integer, 7 # first part, default value 7
@@ -43,7 +42,7 @@ Contributing
43
42
  Copyright
44
43
  ---------
45
44
 
46
- Copyright © 2011 [Martin Kozák][3]. See `LICENSE.txt` for
45
+ Copyright © 2011-2012 [Martin Kozák][3]. See `LICENSE.txt` for
47
46
  further details.
48
47
 
49
48
  [2]: http://github.com/martinkozak/yaop/issues
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ rescue Bundler::BundlerError => e
12
12
  end
13
13
 
14
14
  require 'rake'
15
- require 'jeweler'
15
+ require 'jeweler2'
16
16
 
17
17
  Jeweler::Tasks.new do |gem|
18
18
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.name = "yaop"
21
21
  gem.homepage = "https://github.com/martinkozak/yaop"
22
22
  gem.license = "MIT"
23
- gem.summary = "Yet another options parser. Parses the command-line arguments and parameters. Simple, lightweight with nice declarative approach."
23
+ gem.summary = "Yet another options parser. Parses the command-line arguments and parameters. Simple, lightweight with nice DSL declarative approach."
24
24
  gem.email = "martinkozak@martinkozak.net"
25
25
  gem.authors = ["Martin Kozák"]
26
26
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
2
+ # (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
4
  require "types"
5
5
  require "hash-utils/hash" # >= 0.1.0
@@ -119,11 +119,19 @@ class YAOP
119
119
  params << arg
120
120
  end
121
121
  end
122
-
122
+
123
123
  # Converts datatypes
124
124
  result = Hash::new { |dict, key| dict[key] = [ ] }
125
125
 
126
126
  index.each_pair do |opt, spec|
127
+
128
+ # If no types defines, sets true as symbol of presency
129
+ if spec.types.empty?
130
+ result[opt] = spec.present
131
+ next
132
+ end
133
+
134
+ # If types defined, takes them
127
135
  spec.types.each_index do |i|
128
136
  type, default = spec.types[i]
129
137
  value = nil
@@ -141,15 +149,16 @@ class YAOP
141
149
  result[opt] << value
142
150
  end
143
151
  end
152
+
144
153
  end
145
-
154
+
146
155
  # Converts single value arguments to single-ones
147
156
  result.each_pair do |opt, values|
148
157
  if index[opt].types.length == 1
149
158
  result[opt] = values.first
150
159
  end
151
160
  end
152
-
161
+
153
162
  # Takes parameters from last argument
154
163
  if not last.nil?
155
164
  parameters = index[last].values[index[last].types.length..-1]
data/test.rb ADDED
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ $:.push(".")
3
+ require "./lib/yaop"
4
+
5
+ options = YAOP::get do
6
+ option "--strip"
7
+
8
+ options "-l", "--level" # both of them
9
+ type Integer, 7 # first part, default value 7
10
+ type Integer, 8 # second part, default value 8
11
+ type Integer, 9 # third part, default value 9
12
+ end
13
+
14
+ p options
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "yaop"
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Martin Koz\u{e1}k"]
12
+ s.date = "2012-08-05"
13
+ s.email = "martinkozak@martinkozak.net"
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/yaop.rb",
27
+ "test.rb",
28
+ "yaop.gemspec"
29
+ ]
30
+ s.homepage = "https://github.com/martinkozak/yaop"
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = "1.8.24"
34
+ s.summary = "Yet another options parser. Parses the command-line arguments and parameters. Simple, lightweight with nice DSL declarative approach."
35
+
36
+ if s.respond_to? :specification_version then
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<hash-utils>, [">= 2.0.0"])
41
+ s.add_runtime_dependency(%q<types>, [">= 0.1.0"])
42
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
43
+ s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
44
+ else
45
+ s.add_dependency(%q<hash-utils>, [">= 2.0.0"])
46
+ s.add_dependency(%q<types>, [">= 0.1.0"])
47
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
48
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<hash-utils>, [">= 2.0.0"])
52
+ s.add_dependency(%q<types>, [">= 0.1.0"])
53
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
54
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
55
+ end
56
+ end
57
+
metadata CHANGED
@@ -1,71 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yaop
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
8
- - "Martin Koz\xC3\xA1k"
7
+ authors:
8
+ - Martin Kozák
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-29 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: hash-utils
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.1.0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - !ruby/object:Gem::Dependency
27
31
  name: types
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
33
37
  version: 0.1.0
34
38
  type: :runtime
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.0
46
+ - !ruby/object:Gem::Dependency
38
47
  name: bundler
39
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
40
49
  none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
44
53
  version: 1.0.0
45
54
  type: :development
46
55
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: jeweler
50
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
51
57
  none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- version: 1.5.2
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler2
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.0
56
70
  type: :development
57
71
  prerelease: false
58
- version_requirements: *id004
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.0
59
78
  description:
60
79
  email: martinkozak@martinkozak.net
61
80
  executables: []
62
-
63
81
  extensions: []
64
-
65
- extra_rdoc_files:
82
+ extra_rdoc_files:
66
83
  - LICENSE.txt
67
84
  - README.md
68
- files:
85
+ files:
69
86
  - .document
70
87
  - Gemfile
71
88
  - Gemfile.lock
@@ -74,35 +91,35 @@ files:
74
91
  - Rakefile
75
92
  - VERSION
76
93
  - lib/yaop.rb
94
+ - test.rb
95
+ - yaop.gemspec
77
96
  homepage: https://github.com/martinkozak/yaop
78
- licenses:
97
+ licenses:
79
98
  - MIT
80
99
  post_install_message:
81
100
  rdoc_options: []
82
-
83
- require_paths:
101
+ require_paths:
84
102
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
103
+ required_ruby_version: !ruby/object:Gem::Requirement
86
104
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 1846092196582087239
91
- segments:
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ segments:
92
110
  - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
111
+ hash: 1815022339456278642
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
113
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
100
118
  requirements: []
101
-
102
119
  rubyforge_project:
103
- rubygems_version: 1.8.4
120
+ rubygems_version: 1.8.24
104
121
  signing_key:
105
122
  specification_version: 3
106
- summary: Yet another options parser. Parses the command-line arguments and parameters. Simple, lightweight with nice declarative approach.
123
+ summary: Yet another options parser. Parses the command-line arguments and parameters.
124
+ Simple, lightweight with nice DSL declarative approach.
107
125
  test_files: []
108
-