applix 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/lib/applix/oattr.rb +17 -0
- data/spec/oattr_spec.rb +37 -0
- data/spec/spec_helper.rb +1 -0
- metadata +6 -4
- data/applix.gemspec +0 -75
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/applix/oattr.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module OAttr
|
2
|
+
def self.included(base)
|
3
|
+
base.extend ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def oattr *names
|
8
|
+
container = "@options"
|
9
|
+
if names.last.kind_of? Hash
|
10
|
+
container = "@#{(names.pop)[:container]}"
|
11
|
+
end
|
12
|
+
names.each do |name|
|
13
|
+
class_eval "def #{name}; #{container}['#{name}'.to_sym]; end"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/oattr_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "OAttr" do
|
4
|
+
it "should define a module" do
|
5
|
+
OAttr.should_not == nil
|
6
|
+
end
|
7
|
+
|
8
|
+
#it "should define a oattr class method" do
|
9
|
+
# OAttr.oattr.should_not == nil
|
10
|
+
#end
|
11
|
+
|
12
|
+
describe "with an included OAttr module" do
|
13
|
+
before :each do
|
14
|
+
class Foo; include OAttr; end
|
15
|
+
end
|
16
|
+
it "should include the oattr class method" do
|
17
|
+
Foo.oattr.should_not == nil
|
18
|
+
end
|
19
|
+
it "should define a bar method" do
|
20
|
+
class Foo;
|
21
|
+
oattr :bar
|
22
|
+
def initialize; @options = { :bar => 123}; end;
|
23
|
+
end
|
24
|
+
(Foo.new.respond_to? :bar).should == true
|
25
|
+
Foo.new.bar.should == 123
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should handle container options" do
|
29
|
+
class Foo;
|
30
|
+
oattr :xxx, :foo, :container => :params
|
31
|
+
def initialize; @params = { :xxx => 321}; end;
|
32
|
+
end
|
33
|
+
(Foo.new.respond_to? :xxx).should == true
|
34
|
+
Foo.new.xxx.should == 321
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dirk luesebrink
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,9 +38,10 @@ files:
|
|
38
38
|
- README.markdown
|
39
39
|
- Rakefile
|
40
40
|
- VERSION
|
41
|
-
- applix.gemspec
|
42
41
|
- lib/applix.rb
|
42
|
+
- lib/applix/oattr.rb
|
43
43
|
- spec/applix_spec.rb
|
44
|
+
- spec/oattr_spec.rb
|
44
45
|
- spec/spec_helper.rb
|
45
46
|
has_rdoc: true
|
46
47
|
homepage: http://github.com/crux/applix
|
@@ -66,10 +67,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
67
|
requirements: []
|
67
68
|
|
68
69
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.3.
|
70
|
+
rubygems_version: 1.3.5
|
70
71
|
signing_key:
|
71
72
|
specification_version: 3
|
72
73
|
summary: build typed option hashed from command line arguments
|
73
74
|
test_files:
|
74
75
|
- spec/applix_spec.rb
|
76
|
+
- spec/oattr_spec.rb
|
75
77
|
- spec/spec_helper.rb
|
data/applix.gemspec
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
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 = %q{applix}
|
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 = ["dirk luesebrink"]
|
12
|
-
s.date = %q{2009-11-14}
|
13
|
-
s.description = %q{ ApplixHash#from_argv builds hashes from ARGV like argument vectors
|
14
|
-
according to following examples:
|
15
|
-
|
16
|
-
'-f' --> { :f => true }
|
17
|
-
'--flag' --> { :flag => true }
|
18
|
-
'--flag:false' --> { :flag => false }
|
19
|
-
'--flag=false' --> { :flag => 'false' }
|
20
|
-
'--option=value' --> { :option => "value" }
|
21
|
-
'--int=1' --> { :int => "1" }
|
22
|
-
'--float=2.3' --> { :float => "2.3" }
|
23
|
-
'--float:2.3' --> { :float => 2.3 }
|
24
|
-
'--txt="foo bar"' --> { :txt => "foo bar" }
|
25
|
-
'--txt:'"foo bar"'' --> { :txt => "foo bar" }
|
26
|
-
'--txt:%w{foo bar}' --> { :txt => ["foo", "bar"] }
|
27
|
-
'--now:Time.now' --> { :now => #<Date: 3588595/2,0,2299161> }
|
28
|
-
|
29
|
-
remaining arguments(non flag/options) are inserted as [:arguments,
|
30
|
-
args], eg:
|
31
|
-
Hash.from_argv %w(--foo --bar=loo 123 now)
|
32
|
-
becomes
|
33
|
-
{ :foo => true, :bar => 'loo', :arguments => ["123", "now"] }
|
34
|
-
|
35
|
-
}
|
36
|
-
s.email = %q{dirk@sebrink.de}
|
37
|
-
s.extra_rdoc_files = [
|
38
|
-
"LICENSE",
|
39
|
-
"README.markdown"
|
40
|
-
]
|
41
|
-
s.files = [
|
42
|
-
".document",
|
43
|
-
".gitignore",
|
44
|
-
"LICENSE",
|
45
|
-
"README.markdown",
|
46
|
-
"Rakefile",
|
47
|
-
"VERSION",
|
48
|
-
"applix.gemspec",
|
49
|
-
"lib/applix.rb",
|
50
|
-
"spec/applix_spec.rb",
|
51
|
-
"spec/spec_helper.rb"
|
52
|
-
]
|
53
|
-
s.homepage = %q{http://github.com/crux/applix}
|
54
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
55
|
-
s.require_paths = ["lib"]
|
56
|
-
s.rubygems_version = %q{1.3.4}
|
57
|
-
s.summary = %q{build typed option hashed from command line arguments}
|
58
|
-
s.test_files = [
|
59
|
-
"spec/applix_spec.rb",
|
60
|
-
"spec/spec_helper.rb"
|
61
|
-
]
|
62
|
-
|
63
|
-
if s.respond_to? :specification_version then
|
64
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
-
s.specification_version = 3
|
66
|
-
|
67
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
69
|
-
else
|
70
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
71
|
-
end
|
72
|
-
else
|
73
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
74
|
-
end
|
75
|
-
end
|