applix 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +11 -0
- data/.rspec +1 -0
- data/LICENSE +1 -1
- data/{README.markdown → README.mkd} +2 -2
- data/Rakefile +19 -13
- data/VERSION +1 -1
- data/lib/applix/oattr.rb +5 -4
- data/spec/applix_spec.rb +25 -34
- data/spec/spec_helper.rb +4 -4
- metadata +62 -13
- data/.gitignore +0 -6
data/.autotest
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Autotest.add_hook(:initialize) {|at|
|
2
|
+
at.add_exception %r{^\.git} # ignore Version Control System
|
3
|
+
at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
|
4
|
+
#at.clear_mappings # take out the default (test/test*rb)
|
5
|
+
at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
|
6
|
+
Dir['spec/**/*_spec.rb']
|
7
|
+
}
|
8
|
+
nil
|
9
|
+
}
|
10
|
+
|
11
|
+
# vim: set syntax=ruby ft=ruby:
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --backtrace --format documentation --debug
|
data/LICENSE
CHANGED
@@ -35,6 +35,6 @@ becomes:
|
|
35
35
|
bump version in a commit by itself I can ignore when I pull)
|
36
36
|
* Send me a pull request. Bonus points for topic branches.
|
37
37
|
|
38
|
-
|
38
|
+
## Copyright
|
39
39
|
|
40
|
-
Copyright (c) 2009 dirk luesebrink. See LICENSE for details.
|
40
|
+
Copyright (c) 2009/11 dirk luesebrink. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -33,28 +33,34 @@ begin
|
|
33
33
|
gem.email = "dirk@sebrink.de"
|
34
34
|
gem.homepage = "http://github.com/crux/applix"
|
35
35
|
gem.authors = ["dirk luesebrink"]
|
36
|
-
|
36
|
+
|
37
|
+
gem.add_development_dependency "rspec", ">= 2.3.0"
|
38
|
+
gem.add_development_dependency "rcov"
|
39
|
+
gem.add_development_dependency "ZenTest", ">= 4.4.2"
|
37
40
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
38
41
|
end
|
39
42
|
rescue LoadError
|
40
43
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
41
44
|
end
|
42
45
|
|
43
|
-
require 'spec/rake/spectask'
|
44
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
45
|
-
spec.libs << 'lib' << 'spec'
|
46
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
47
|
-
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
spec
|
53
|
-
|
47
|
+
require "rspec/core/rake_task"
|
48
|
+
namespace :test do
|
49
|
+
desc "Run all specs."
|
50
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
51
|
+
t.pattern = 'spec/**/*_spec.rb'
|
52
|
+
t.verbose = false
|
53
|
+
end
|
54
54
|
|
55
|
-
|
55
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
56
|
+
t.rcov = true
|
57
|
+
t.rcov_opts = %q[--exclude "spec"]
|
58
|
+
t.verbose = true
|
59
|
+
end
|
60
|
+
end
|
56
61
|
|
57
|
-
task :default => :
|
62
|
+
task :default => :check_dependencies
|
63
|
+
task :spec => 'test:spec'
|
58
64
|
|
59
65
|
require 'rake/rdoctask'
|
60
66
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/applix/oattr.rb
CHANGED
@@ -5,10 +5,11 @@ module OAttr
|
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
def oattr *names
|
8
|
-
container =
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
container = if names.last.kind_of? Hash
|
9
|
+
"@#{(names.pop)[:container]}"
|
10
|
+
else
|
11
|
+
"@options"
|
12
|
+
end
|
12
13
|
names.each do |name|
|
13
14
|
class_eval "def #{name}; #{container}['#{name}'.to_sym]; end"
|
14
15
|
end
|
data/spec/applix_spec.rb
CHANGED
@@ -4,57 +4,48 @@ describe "Applix" do
|
|
4
4
|
#it "fails" do
|
5
5
|
# fail "hey buddy, you should probably rename this file and start specing for real"
|
6
6
|
#end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
__END__
|
11
|
-
|
12
|
-
port this from unit to rspec...
|
13
|
-
|
14
|
-
#!/usr/bin/env ruby
|
15
|
-
|
16
|
-
require 'test/unit'
|
17
|
-
require 'pp'
|
18
|
-
|
19
|
-
#require 'hash_from_argv'
|
20
|
-
#H = Hash::FromArgvHelperNamespaceToAvoidPolution
|
21
|
-
|
22
|
-
require 'applix-hash'
|
23
|
-
H = ApplixHash
|
24
|
-
|
25
|
-
class HashFromArgvTest < Test::Unit::TestCase
|
26
|
-
|
27
|
-
def test_applix_hash_parse
|
7
|
+
|
8
|
+
it "should parse the old unit test..." do
|
28
9
|
# -f becomes { :f => true }
|
29
10
|
# --flag becomes { :flag => true }
|
30
|
-
|
31
|
-
|
11
|
+
(ApplixHash.parse '-f').should == [:f, true]
|
12
|
+
(ApplixHash.parse '--flag').should == [:flag, true]
|
32
13
|
# --flag:false becomes { :flag => false }
|
33
|
-
|
14
|
+
(ApplixHash.parse '--flag:false').should == [:flag, false]
|
34
15
|
|
35
16
|
# --option=value becomes { :option => "value" }
|
36
|
-
|
17
|
+
(ApplixHash.parse '--opt=val').should == [:opt, 'val']
|
37
18
|
|
38
19
|
# --int=1 becomes { :int => "1" }
|
20
|
+
# --int:1 becomes { :int => 1 }
|
39
21
|
# --float=2.3 becomes { :float => "2.3" }
|
40
22
|
# --float:2.3 becomes { :float => 2.3 }
|
41
23
|
# -f:1.234 becomes { :f => 1.234 }
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
(Hash.from_argv ["--int=1"])[:int].should == "1"
|
25
|
+
(Hash.from_argv ["--int:1"])[:int].should == 1
|
26
|
+
(Hash.from_argv ["--float=2.3"])[:float].should == "2.3"
|
27
|
+
(Hash.from_argv ["--float:2.3"])[:float].should == 2.3
|
28
|
+
(Hash.from_argv ["-f:2.345"])[:f].should == 2.345
|
46
29
|
|
47
30
|
# --txt="foo bar" becomes { :txt => "foo bar" }
|
48
31
|
# --txt:'"foo bar"' becomes { :txt => "foo bar" }
|
49
32
|
# --txt:%w{foo bar} becomes { :txt => ["foo", "bar"] }
|
50
|
-
|
51
|
-
|
52
|
-
|
33
|
+
(Hash.from_argv ['--txt="foo bar"'])[:txt].should == "foo bar"
|
34
|
+
(Hash.from_argv [%q|--txt:'"foo bar"'|])[:txt].should == "foo bar"
|
35
|
+
(Hash.from_argv [%q|--txt:'%w{foo bar}'|])[:txt].should == ["foo", "bar"]
|
53
36
|
|
54
37
|
# --now:Time.now becomes { :now => Mon Jul 09 01:30:21 0200 2007 }
|
55
|
-
dt = Time.now - H.parse("--now:Time.now")[1]
|
56
|
-
|
38
|
+
#dt = Time.now - H.parse("--now:Time.now")[1]
|
39
|
+
(t = (Hash.from_argv ["--now:Time.now"])[:now]).should_not == nil
|
57
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
__END__
|
45
|
+
|
46
|
+
port this from unit to rspec...
|
47
|
+
|
48
|
+
class HashFromArgvTest < Test::Unit::TestCase
|
58
49
|
|
59
50
|
# XXX this is hacking the new Hash.from_argv interface into the old
|
60
51
|
# dissect signature to make proper reuse of the existing unit tests
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rspec'
|
3
5
|
require 'applix'
|
4
6
|
require 'applix/oattr'
|
5
|
-
require 'spec'
|
6
|
-
require 'spec/autorun'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
Rspec.configure do |config|
|
9
|
+
config.mock_with :rspec
|
10
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- dirk luesebrink
|
@@ -9,19 +15,55 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-02-07 00:00:00 +01:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 0
|
34
|
+
version: 2.3.0
|
17
35
|
type: :development
|
18
|
-
|
19
|
-
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rcov
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
20
42
|
requirements:
|
21
43
|
- - ">="
|
22
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
23
48
|
version: "0"
|
24
|
-
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: ZenTest
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 43
|
60
|
+
segments:
|
61
|
+
- 4
|
62
|
+
- 4
|
63
|
+
- 2
|
64
|
+
version: 4.4.2
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
25
67
|
description: " ApplixHash#from_argv builds hashes from ARGV like argument vectors\n according to following examples: \n \n '-f' --> { :f => true }\n '--flag' --> { :flag => true }\n '--flag:false' --> { :flag => false }\n '--flag=false' --> { :flag => 'false' }\n '--option=value' --> { :option => \"value\" }\n '--int=1' --> { :int => \"1\" }\n '--float=2.3' --> { :float => \"2.3\" }\n '--float:2.3' --> { :float => 2.3 }\n '--txt=\"foo bar\"' --> { :txt => \"foo bar\" }\n '--txt:'\"foo bar\"'' --> { :txt => \"foo bar\" }\n '--txt:%w{foo bar}' --> { :txt => [\"foo\", \"bar\"] }\n '--now:Time.now' --> { :now => #<Date: 3588595/2,0,2299161> }\n \n remaining arguments(non flag/options) are inserted as [:arguments,\n args], eg:\n Hash.from_argv %w(--foo --bar=loo 123 now)\n becomes \n { :foo => true, :bar => 'loo', :arguments => [\"123\", \"now\"] }\n \n"
|
26
68
|
email: dirk@sebrink.de
|
27
69
|
executables: []
|
@@ -30,12 +72,13 @@ extensions: []
|
|
30
72
|
|
31
73
|
extra_rdoc_files:
|
32
74
|
- LICENSE
|
33
|
-
- README.
|
75
|
+
- README.mkd
|
34
76
|
files:
|
77
|
+
- .autotest
|
35
78
|
- .document
|
36
|
-
- .
|
79
|
+
- .rspec
|
37
80
|
- LICENSE
|
38
|
-
- README.
|
81
|
+
- README.mkd
|
39
82
|
- Rakefile
|
40
83
|
- VERSION
|
41
84
|
- lib/applix.rb
|
@@ -48,26 +91,32 @@ homepage: http://github.com/crux/applix
|
|
48
91
|
licenses: []
|
49
92
|
|
50
93
|
post_install_message:
|
51
|
-
rdoc_options:
|
52
|
-
|
94
|
+
rdoc_options: []
|
95
|
+
|
53
96
|
require_paths:
|
54
97
|
- lib
|
55
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
56
100
|
requirements:
|
57
101
|
- - ">="
|
58
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
59
106
|
version: "0"
|
60
|
-
version:
|
61
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
62
109
|
requirements:
|
63
110
|
- - ">="
|
64
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
65
115
|
version: "0"
|
66
|
-
version:
|
67
116
|
requirements: []
|
68
117
|
|
69
118
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
119
|
+
rubygems_version: 1.4.2
|
71
120
|
signing_key:
|
72
121
|
specification_version: 3
|
73
122
|
summary: build typed option hashed from command line arguments
|