confetti 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/LICENSE +19 -0
- data/lib/confetti/config.rb +3 -1
- data/lib/confetti/version.rb +1 -1
- data/lib/typedset.rb +7 -10
- data/spec/config_spec.rb +7 -0
- metadata +4 -3
data/Gemfile.lock
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Andrew Lunny
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/lib/confetti/config.rb
CHANGED
data/lib/confetti/version.rb
CHANGED
data/lib/typedset.rb
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
require "set"
|
2
2
|
|
3
|
-
# based on RestricedSet from Ruby's stdlib, cf
|
4
|
-
# http://github.com/ruby/ruby/blob/72ef219804e5524848170a197887a95718334e2a/lib/set.rb#L627-717
|
5
|
-
# not sure why it's been commented out
|
6
|
-
# I should follow these things
|
7
|
-
|
8
3
|
class TypedSet < Set
|
9
|
-
attr_reader :
|
10
|
-
alias set_class klass
|
4
|
+
attr_reader :set_class
|
11
5
|
|
12
6
|
def initialize (klass, *args)
|
13
|
-
raise ArgumentError, "require a
|
14
|
-
@
|
7
|
+
raise ArgumentError, "require a class object" unless klass.class == Class
|
8
|
+
@set_class = klass
|
15
9
|
super args
|
16
10
|
end
|
17
11
|
|
18
12
|
def add o
|
19
|
-
|
13
|
+
unless o.class == @set_class
|
14
|
+
raise ArgumentError, "members must be of class #{ @set_class }"
|
15
|
+
end
|
16
|
+
|
20
17
|
super o
|
21
18
|
end
|
22
19
|
alias << add
|
data/spec/config_spec.rb
CHANGED
@@ -174,6 +174,13 @@ describe Confetti::Config do
|
|
174
174
|
}.should raise_error Confetti::Config::XMLError
|
175
175
|
end
|
176
176
|
|
177
|
+
it "should raise an error if no root node is found" do
|
178
|
+
File.stub(:read).and_return(nil)
|
179
|
+
lambda {
|
180
|
+
@config.populate_from_xml("#{ fixture_dir }/empty_non_existent.xml")
|
181
|
+
}.should raise_error Confetti::Config::XMLError
|
182
|
+
end
|
183
|
+
|
177
184
|
describe "when setting attributes from config.xml" do
|
178
185
|
before do
|
179
186
|
@config.populate_from_xml(fixture_dir + "/config.xml")
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andrew Lunny
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-10-13 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- .gitignore
|
99
99
|
- Gemfile
|
100
100
|
- Gemfile.lock
|
101
|
+
- LICENSE
|
101
102
|
- README.md
|
102
103
|
- Rakefile
|
103
104
|
- bin/confetti
|