bulldog 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/VERSION +1 -1
- data/bulldog.gemspec +3 -2
- data/lib/bulldog/processor/one_shot.rb +1 -1
- data/lib/bulldog/reflection.rb +2 -4
- data/lib/bulldog/style_set.rb +23 -16
- data/spec/unit/processor/one_shot_spec.rb +10 -0
- data/spec/unit/style_set_spec.rb +18 -0
- metadata +3 -2
data/CHANGELOG
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/bulldog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bulldog}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["George Ogata"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-16}
|
13
13
|
s.description = %q{= Bulldog
|
14
14
|
|
15
15
|
Flexible file attachments for active record.
|
@@ -21,6 +21,7 @@ Flexible file attachments for active record.
|
|
21
21
|
]
|
22
22
|
s.files = [
|
23
23
|
".gitignore",
|
24
|
+
"CHANGELOG",
|
24
25
|
"DESCRIPTION.txt",
|
25
26
|
"LICENSE",
|
26
27
|
"README.rdoc",
|
data/lib/bulldog/reflection.rb
CHANGED
@@ -151,15 +151,13 @@ module Bulldog
|
|
151
151
|
:callback => callback)
|
152
152
|
end
|
153
153
|
|
154
|
-
def process_once(
|
155
|
-
options = types.extract_options!
|
154
|
+
def process_once(options={}, &callback)
|
156
155
|
options[:with] and
|
157
156
|
raise ArgumentError, "cannot specify a processor (:with option) with #process_once"
|
158
157
|
options[:styles] and
|
159
158
|
raise ArgumentError, "no :styles available for #process_once"
|
160
159
|
options[:with] = :one_shot
|
161
|
-
|
162
|
-
process(*types, &callback)
|
160
|
+
process(options, &callback)
|
163
161
|
end
|
164
162
|
|
165
163
|
def store_attributes(*args)
|
data/lib/bulldog/style_set.rb
CHANGED
@@ -52,7 +52,8 @@ module Bulldog
|
|
52
52
|
#
|
53
53
|
# Return true if the given object has the same styles as this one.
|
54
54
|
#
|
55
|
-
# The argument must have #to_a defined.
|
55
|
+
# The argument must have #to_a defined. Style comparison is done
|
56
|
+
# by name only.
|
56
57
|
#
|
57
58
|
def ==(other)
|
58
59
|
other.to_a == @styles
|
@@ -66,35 +67,41 @@ module Bulldog
|
|
66
67
|
end
|
67
68
|
|
68
69
|
#
|
69
|
-
# Return
|
70
|
+
# Return the number of styles in the set.
|
70
71
|
#
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
# The :original style is not taken into account.
|
73
|
+
#
|
74
|
+
delegate :length, :to => :@styles
|
75
|
+
alias size length
|
74
76
|
|
75
77
|
#
|
76
|
-
# Return
|
78
|
+
# Return true if there are no styles in the set, false otherwise.
|
77
79
|
#
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
80
|
+
# The :original style is not taken into account.
|
81
|
+
#
|
82
|
+
delegate :empty?, :to => :@styles
|
82
83
|
|
83
84
|
#
|
84
85
|
# Clear all styles out of the style set.
|
85
86
|
#
|
86
|
-
# The original will still be retrievable.
|
87
|
+
# The original style will still be retrievable.
|
87
88
|
#
|
88
|
-
|
89
|
-
|
89
|
+
delegate :clear, :to => :@styles
|
90
|
+
|
91
|
+
#
|
92
|
+
# Return the style with the given names.
|
93
|
+
#
|
94
|
+
def slice(*names)
|
95
|
+
styles = names.map{|name| self[name]}
|
96
|
+
StyleSet[*styles]
|
90
97
|
end
|
91
98
|
|
92
99
|
#
|
93
100
|
# Yield each style.
|
94
101
|
#
|
95
|
-
|
96
|
-
|
97
|
-
|
102
|
+
# The :original style is not included.
|
103
|
+
#
|
104
|
+
delegate :each, :to => :@styles
|
98
105
|
|
99
106
|
include Enumerable
|
100
107
|
end
|
@@ -67,4 +67,14 @@ describe Processor::OneShot do
|
|
67
67
|
|
68
68
|
it_should_behave_like "any one shot processor"
|
69
69
|
end
|
70
|
+
|
71
|
+
describe "A standalone processor" do
|
72
|
+
it "should not affect the other processes' styles" do
|
73
|
+
style = Style.new(:style)
|
74
|
+
styles = StyleSet[style]
|
75
|
+
processor = Processor::OneShot.new(mock, styles, mock)
|
76
|
+
processor.process{}
|
77
|
+
styles.should have(1).style
|
78
|
+
end
|
79
|
+
end
|
70
80
|
end
|
data/spec/unit/style_set_spec.rb
CHANGED
@@ -41,4 +41,22 @@ describe StyleSet do
|
|
41
41
|
@style_set[:original].should == @original
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
describe "#size" do
|
46
|
+
it "should return the number of styles in the set, excluding the :original style" do
|
47
|
+
style_set = StyleSet[]
|
48
|
+
style_set.size.should == 0
|
49
|
+
style_set << Style.new(:style)
|
50
|
+
style_set.size.should == 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#length" do
|
55
|
+
it "should return the number of styles in the set, excluding the :original style" do
|
56
|
+
style_set = StyleSet[]
|
57
|
+
style_set.length.should == 0
|
58
|
+
style_set << Style.new(:style)
|
59
|
+
style_set.length.should == 1
|
60
|
+
end
|
61
|
+
end
|
44
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulldog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Ogata
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-16 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ extra_rdoc_files:
|
|
57
57
|
- README.rdoc
|
58
58
|
files:
|
59
59
|
- .gitignore
|
60
|
+
- CHANGELOG
|
60
61
|
- DESCRIPTION.txt
|
61
62
|
- LICENSE
|
62
63
|
- README.rdoc
|