gather 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -0
- data/lib/changes.rb +3 -2
- data/lib/gather.rb +8 -8
- data/test/test_changes.rb +24 -12
- data/test/test_gather.rb +6 -0
- data/test/test_helper.rb +4 -0
- data/version.txt +1 -1
- metadata +33 -57
- data/lib/version.rb +0 -3
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/lib/changes.rb
CHANGED
@@ -163,7 +163,8 @@ module Changes
|
|
163
163
|
if val.empty?
|
164
164
|
@#{property}
|
165
165
|
else
|
166
|
-
|
166
|
+
unwrapped_value = val.size == 1 ? val[0] : val
|
167
|
+
self.#{property} = unwrapped_value
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
@@ -179,7 +180,7 @@ module Changes
|
|
179
180
|
@before_#{property}_block = block
|
180
181
|
end
|
181
182
|
|
182
|
-
def #{property}=(*new_value)
|
183
|
+
def #{property}=(*new_value)
|
183
184
|
unwrapped_value = new_value.size == 1 ? new_value[0] : new_value
|
184
185
|
return if unwrapped_value == @#{property}
|
185
186
|
|
data/lib/gather.rb
CHANGED
@@ -122,24 +122,24 @@ module Gather
|
|
122
122
|
def property( *symbols )
|
123
123
|
@stripper_re ||= /^([^\= ]+)\s*\=?\s*$/
|
124
124
|
symbols.each do |sym|
|
125
|
-
|
126
|
-
own_properties <<
|
125
|
+
method_name = @stripper_re.match( sym.to_s )[1]
|
126
|
+
own_properties << method_name.to_sym
|
127
127
|
line, st = __LINE__, <<-EOF
|
128
|
-
def #{
|
128
|
+
def #{method_name}(*val, &block)
|
129
129
|
if block.nil?
|
130
130
|
if val.empty?
|
131
|
-
@#{
|
131
|
+
@#{method_name}
|
132
132
|
else
|
133
133
|
# use the assignment, so only it has to be overloaded
|
134
|
-
self.#{
|
134
|
+
self.#{method_name} = val.size == 1 ? val[0] : val
|
135
135
|
end
|
136
136
|
else
|
137
|
-
@#{
|
137
|
+
@#{method_name} = block
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
def #{
|
142
|
-
@#{
|
141
|
+
def #{method_name}=( value )
|
142
|
+
@#{method_name} = value
|
143
143
|
end
|
144
144
|
EOF
|
145
145
|
class_eval st, __FILE__, line + 1
|
data/test/test_changes.rb
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'changes'
|
2
3
|
|
3
|
-
class
|
4
|
-
|
5
|
-
end
|
4
|
+
class SumDumClass
|
5
|
+
include Changes
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
property :aac
|
8
|
+
property :ben
|
9
|
+
property :civ
|
10
|
+
end
|
11
|
+
|
12
|
+
class TestChanges < Test::Unit::TestCase
|
13
|
+
context "instantiated with hash" do
|
14
|
+
setup do
|
15
|
+
@instance = SumDumClass.new(
|
16
|
+
:aac => 'hey',
|
17
|
+
:ben => 'thewre',
|
18
|
+
:civ => 'dude'
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
should 'have correct values' do
|
23
|
+
assert_equal 'hey', @instance.aac
|
24
|
+
assert_equal 'thewre', @instance.ben
|
25
|
+
assert_equal 'dude', @instance.civ
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
|
-
should_eventually "do
|
29
|
+
should_eventually "do more tests"
|
18
30
|
end
|
data/test/test_gather.rb
CHANGED
@@ -103,6 +103,12 @@ class TestGather < Test::Unit::TestCase
|
|
103
103
|
assert_equal arr, @instance.to_a
|
104
104
|
assert_equal arr, @instance.values
|
105
105
|
end
|
106
|
+
|
107
|
+
should 'be correct' do
|
108
|
+
assert_equal 'hey', @instance.aac
|
109
|
+
assert_equal 'thewre', @instance.ben
|
110
|
+
assert_equal 'dude', @instance.civ
|
111
|
+
end
|
106
112
|
end
|
107
113
|
|
108
114
|
should_eventually "test merge with a hash"
|
data/test/test_helper.rb
CHANGED
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
metadata
CHANGED
@@ -1,58 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gather
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.7
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- John Anderson
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-06-21 00:00:00.000000000 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
16
|
name: bones
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &69263020 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
23
22
|
version: 3.7.0
|
24
23
|
type: :development
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
For example:
|
30
|
-
|
31
|
-
class SumThing
|
32
|
-
include Gather
|
33
|
-
property :thing, :spla, :gumf, :troob
|
34
|
-
end
|
35
|
-
|
36
|
-
s = SumThing.new.gather :spla => 'five', :thing => 'sigma' do
|
37
|
-
troob %w{one two three four}
|
38
|
-
gumf 15 % 4
|
39
|
-
end
|
40
|
-
|
41
|
-
Or
|
42
|
-
|
43
|
-
s = SumThing.new.gather :spla => 'five', :thing => 'sigma' do |s|
|
44
|
-
s.troob = %w{one two three four}
|
45
|
-
s.gumf = 15 % 4
|
46
|
-
end
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *69263020
|
26
|
+
description: A gem that provides modules to make working with properties a bit easier.
|
47
27
|
email: panic@semiosix.com
|
48
28
|
executables: []
|
49
|
-
|
50
29
|
extensions: []
|
51
|
-
|
52
|
-
extra_rdoc_files:
|
30
|
+
extra_rdoc_files:
|
53
31
|
- History.txt
|
54
32
|
- Manifest.txt
|
55
|
-
files:
|
33
|
+
files:
|
56
34
|
- .gitignore
|
57
35
|
- History.txt
|
58
36
|
- LICENSE
|
@@ -62,42 +40,40 @@ files:
|
|
62
40
|
- TODO
|
63
41
|
- lib/changes.rb
|
64
42
|
- lib/gather.rb
|
65
|
-
- lib/version.rb
|
66
43
|
- script/destroy
|
67
44
|
- script/generate
|
68
45
|
- test/test_changes.rb
|
69
46
|
- test/test_gather.rb
|
70
47
|
- test/test_helper.rb
|
71
48
|
- version.txt
|
49
|
+
has_rdoc: true
|
72
50
|
homepage: https://rubygems.org/gems/gather
|
73
51
|
licenses: []
|
74
|
-
|
75
52
|
post_install_message:
|
76
|
-
rdoc_options:
|
53
|
+
rdoc_options:
|
77
54
|
- --main
|
78
55
|
- README
|
79
|
-
require_paths:
|
56
|
+
require_paths:
|
80
57
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
59
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
65
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version:
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
93
70
|
requirements: []
|
94
|
-
|
95
71
|
rubyforge_project: gather
|
96
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.6.2
|
97
73
|
signing_key:
|
98
74
|
specification_version: 3
|
99
75
|
summary: http://gather.
|
100
|
-
test_files:
|
101
|
-
- test/test_changes.rb
|
76
|
+
test_files:
|
102
77
|
- test/test_gather.rb
|
103
78
|
- test/test_helper.rb
|
79
|
+
- test/test_changes.rb
|
data/lib/version.rb
DELETED