gather 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,5 @@
1
+ == 0.0.4
2
+ * Allow properties which have a block to have that block as a value
3
+
1
4
  == 0.0.3
2
5
  * Make into a rubyforge gem
data/README CHANGED
@@ -1,4 +1,8 @@
1
- == gather
1
+ = gather
2
+
3
+ http://gather.rubyforge.org
4
+
5
+ == DESCRIPTION:
2
6
 
3
7
  A gem that provides modules to make working with properties a bit easier.
4
8
 
@@ -20,3 +24,41 @@ Or
20
24
  s.troob = %w{one two three four}
21
25
  s.gumf = 15 % 4
22
26
  end
27
+
28
+ == FEATURES:
29
+
30
+ Changes emits on_change for each property
31
+
32
+ == PROBLEMS:
33
+
34
+ See TODO file.
35
+
36
+ == SYNOPSIS:
37
+
38
+ == REQUIREMENTS:
39
+
40
+ == INSTALL:
41
+
42
+ sudo gem install gather
43
+
44
+ == THANKS:
45
+
46
+ == LICENSE:
47
+
48
+ (The GPL-2 License)
49
+
50
+ Copyright (C) 2008 John Anderson
51
+
52
+ This program is free software; you can redistribute it and/or
53
+ modify it under the terms of the GNU Library General Public License
54
+ as published by the Free Software Foundation; either version 2
55
+ of the License, or (at your option) any later version.
56
+
57
+ This program is distributed in the hope that it will be useful,
58
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
59
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60
+ GNU General Public License for more details.
61
+
62
+ You should have received a copy of the GNU Library General Public License
63
+ along with this program; if not, write to the Free Software
64
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -71,16 +71,20 @@ module Gather
71
71
  end
72
72
 
73
73
  def property( *symbols )
74
- @stripper ||= /^([^\= ]+)\s*\=?\s*$/
74
+ @stripper_re ||= /^([^\= ]+)\s*\=?\s*$/
75
75
  symbols.each do |sym|
76
- stripped = @stripper.match( sym.to_s )[1]
76
+ stripped = @stripper_re.match( sym.to_s )[1]
77
77
  own_properties << stripped.to_sym
78
78
  line, st = __LINE__, <<-EOF
79
- def #{stripped}(*val)
80
- if val.empty?
81
- @#{stripped}
79
+ def #{stripped}(*val, &block)
80
+ if block.nil?
81
+ if val.empty?
82
+ @#{stripped}
83
+ else
84
+ @#{stripped} = val.size == 1 ? val[0] : val
85
+ end
82
86
  else
83
- @#{stripped} = val.size == 1 ? val[0] : val
87
+ @#{stripped} = block
84
88
  end
85
89
  end
86
90
 
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestChanges < Test::Unit::TestCase
4
+ def self.startup
5
+ end
6
+
7
+ def self.shutdown
8
+ end
9
+
10
+ def setup
11
+ end
12
+
13
+ should "be true" do
14
+ assert true
15
+ end
16
+
17
+ should_eventually "do some real tests"
18
+ end
@@ -0,0 +1,89 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require 'gather'
3
+
4
+ class SumDumClass
5
+ include Gather
6
+
7
+ property :aac
8
+ property :ben
9
+ property :civ
10
+ end
11
+
12
+ class Child < SumDumClass
13
+ property :epi
14
+ end
15
+
16
+ class TestGather < Test::Unit::TestCase
17
+ def self.startup
18
+ end
19
+
20
+ def self.shutdown
21
+ end
22
+
23
+ def setup
24
+ @instance = SumDumClass.new
25
+ @properties = [:aac, :ben, :civ]
26
+ @child_properties = [ :epi ]
27
+ end
28
+
29
+ should "have properties" do
30
+ assert_equal @properties, SumDumClass.properties.to_a
31
+ end
32
+
33
+ should "have methods" do
34
+ @properties.each do |prop|
35
+ assert @instance.respond_to?( prop )
36
+ assert @instance.respond_to?( "#{prop}=" )
37
+ end
38
+ end
39
+
40
+ should "have assigned values" do
41
+ @instance.aac = 'one'
42
+ assert_equal 'one', @instance.aac
43
+ end
44
+
45
+ should "have DSL assigned values" do
46
+ @instance.aac 'two'
47
+ assert_equal 'two', @instance.aac
48
+ end
49
+
50
+ should "have [] values" do
51
+ @instance[:aac] = 'two'
52
+ assert_equal 'two', @instance[:aac]
53
+ end
54
+
55
+ should "take a block" do
56
+ @instance.aac do |one,two|
57
+ "This is a block"
58
+ end
59
+
60
+ assert_equal Proc, @instance.aac.class
61
+ assert_equal 2, @instance.aac.arity
62
+ assert_equal "This is a block", @instance.aac.call(1,2)
63
+ end
64
+
65
+ should "be assigned a lambda" do
66
+ @instance.aac = lambda do |three,four,five|
67
+ "This is another block"
68
+ end
69
+
70
+ assert_equal Proc, @instance.aac.class
71
+ assert_equal 3, @instance.aac.arity
72
+ assert_equal "This is another block", @instance.aac.call(1,2,3)
73
+ end
74
+
75
+ should "have hash values" do
76
+ @instance.aac = 'hey'
77
+ @instance.ben = 'thewre'
78
+ @instance.civ = 'dude'
79
+
80
+ hash = {:aac => 'hey', :ben => 'thewre', :civ => 'dude'}
81
+ assert_equal hash, @instance.to_hash
82
+ end
83
+
84
+ should_eventually "test merge with a hash"
85
+ should_eventually "test gather with a block"
86
+ should_eventually "test gather with a self-block"
87
+ should_eventually "test gather with a hash"
88
+ should_eventually "test gather with everything"
89
+ end
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require 'shoulda'
3
+ require 'pathname'
4
+
5
+ $: << ( Pathname.new(__FILE__).parent.parent + 'lib' ).realpath.to_s
6
+
7
+ # Allow running of startup and shutdown things before
8
+ # an entire suite, instead of just one per test.
9
+ # Creation of a database would be an example.
10
+ class SuiteWrapper < Test::Unit::TestSuite
11
+ attr_accessor :tests
12
+
13
+ def initialize( name, test_case )
14
+ super( name )
15
+ @test_case = test_case
16
+ end
17
+
18
+ def startup
19
+ end
20
+
21
+ def shutdown
22
+ end
23
+
24
+ def run( *args )
25
+ startup
26
+ @test_case.startup if @test_case.respond_to? :startup
27
+ retval = super
28
+ @test_case.shutdown if @test_case.respond_to? :shutdown
29
+ shutdown
30
+ retval
31
+ end
32
+ end
33
+
34
+ module Test
35
+ module Unit
36
+ class TestCase
37
+ unless respond_to? :old_suite
38
+ class << self
39
+ alias_method :old_suite, :suite
40
+ end
41
+
42
+ def self.suite
43
+ os = old_suite
44
+ sw = SuiteWrapper.new( os.name, self )
45
+ sw.tests = os.tests
46
+ sw
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Anderson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-30 00:00:00 +02:00
12
+ date: 2009-09-02 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.3
23
+ version: 1.3.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
@@ -32,7 +32,27 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.8.0
34
34
  version:
35
- description: ""
35
+ description: |-
36
+ A gem that provides modules to make working with properties a bit easier.
37
+
38
+ For example:
39
+
40
+ class SumThing
41
+ include Gather
42
+ property :thing, :spla, :gumf, :troob
43
+ end
44
+
45
+ s = SumThing.new.gather :spla => 'five', :thing => 'sigma' do
46
+ troob %w{one two three four}
47
+ gumf 15 % 4
48
+ end
49
+
50
+ Or
51
+
52
+ s = SumThing.new.gather :spla => 'five', :thing => 'sigma' do |s|
53
+ s.troob = %w{one two three four}
54
+ s.gumf = 15 % 4
55
+ end
36
56
  email:
37
57
  - panic@semiosix.com
38
58
  executables: []
@@ -52,7 +72,9 @@ files:
52
72
  - script/destroy
53
73
  - script/generate
54
74
  has_rdoc: true
55
- homepage: A gem that provides modules to make working with properties a bit easier.
75
+ homepage: http://gather.rubyforge.org
76
+ licenses: []
77
+
56
78
  post_install_message:
57
79
  rdoc_options:
58
80
  - --main
@@ -74,9 +96,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
96
  requirements: []
75
97
 
76
98
  rubyforge_project: clevic
77
- rubygems_version: 1.3.1
99
+ rubygems_version: 1.3.5
78
100
  signing_key:
79
- specification_version: 2
80
- summary: ""
81
- test_files: []
82
-
101
+ specification_version: 3
102
+ summary: A gem that provides modules to make working with properties a bit easier
103
+ test_files:
104
+ - test/test_helper.rb
105
+ - test/test_changes.rb
106
+ - test/test_gather.rb