gorillib 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.textile +6 -0
- data/Gemfile +5 -2
- data/{README.textile → README.md} +22 -22
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/gorillib.gemspec +14 -6
- data/lib/gorillib/dsl_object.rb +64 -0
- data/spec/dsl_object_spec.rb +99 -0
- metadata +41 -16
data/CHANGELOG.textile
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
h3. 2011-12-11 - Version 0.1.8: Gemfile fixes; Log.dump shows caller
|
2
|
+
|
3
|
+
* Gorillib has no real dependencies on spork, rcov, Redcloth, etc; these are only useful for rake tasks. Dialed down the urgency of version req's on rspec, yard, etc, and moved the esoterica (spork, rcov, watchr, RedCloth) into bundler groups. Bundler will still install them if you 'bundle install' from the gorillib directory, but the gemspec no longer forces upstream requirers to consider them dependencies
|
4
|
+
* Log.dump adds the immediate caller to the end of its output
|
5
|
+
* fix to Gemfile so that early versions of jruby don't hate on it
|
6
|
+
|
1
7
|
h3. 2011-08-21 - Version 0.1.6: Serialization and DeepHash
|
2
8
|
|
3
9
|
* Serialization with #to_wire -- like #to_hash, but hands #to_wire down the line to any element that contains it (as opposed to `#to_hash`, which should just do that)
|
data/Gemfile
CHANGED
@@ -9,6 +9,8 @@ group :development do
|
|
9
9
|
gem 'jeweler', "~> 1.6"
|
10
10
|
gem 'rspec', "~> 2.5"
|
11
11
|
gem 'yard', "~> 0.6"
|
12
|
+
gem 'cucumber', "~> 1"
|
13
|
+
gem 'aruba', "~> 0.4"
|
12
14
|
end
|
13
15
|
|
14
16
|
group :docs do
|
@@ -16,7 +18,8 @@ group :docs do
|
|
16
18
|
end
|
17
19
|
|
18
20
|
group :test do
|
19
|
-
gem 'spork', "
|
20
|
-
gem 'rcov', ">= 0.9.9"
|
21
|
+
gem 'spork', ">= 0.9.0", :platform => :mri
|
22
|
+
gem 'rcov', ">= 0.9.9", :platform => :ruby_18
|
23
|
+
gem 'simplecov', ">= 0.5", :platform => :ruby_19
|
21
24
|
gem 'watchr'
|
22
25
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
## Gorillib: infochimps' lightweight subset of ruby convenience methods
|
3
3
|
|
4
|
-
We love the conveniences provided by active_support and extlib
|
4
|
+
We love the conveniences provided by `active_support` and `extlib`, we just don't love them at the same time and on top of each other. active_support is slow to load, has many dependencies, and is all intertwingled. We had too many collisions between `active_support` 2.x and 3.x and `extlib`.
|
5
5
|
|
6
|
-
What gorillib gives you is clarity over what features are brought in. If you want to *just* get
|
6
|
+
What gorillib gives you is clarity over what features are brought in. If you want to *just* get `Object#blank?`, just `require 'gorillib/object/blank'`. No dependencies, no codependents.
|
7
7
|
|
8
8
|
* No creep: include only what you need
|
9
9
|
* No dependencies unless audaciously advertised.
|
10
|
-
* Upwards compatible with active_record and extlib
|
11
|
-
- the active_support components have significantly more robust internationalization, and some functions have rich option sets in active_support vs. basic functionality in gorillib
|
10
|
+
* Upwards compatible with `active_record` and `extlib`
|
11
|
+
- the `active_support` components have significantly more robust internationalization, and some functions have rich option sets in `active_support` vs. basic functionality in `gorillib`. So the rule is if you were happy with `gorillib` you'll be happy with `active_support`, but not vice-versa.
|
12
12
|
|
13
|
-
|
13
|
+
### require 'gorillib/receiver'
|
14
14
|
|
15
15
|
Gorillib has at least one powerful addition to the canon: the receiver mixin.
|
16
16
|
|
@@ -18,11 +18,11 @@ Gorillib has at least one powerful addition to the canon: the receiver mixin.
|
|
18
18
|
* gives you weak type safety but doesn't jack around with setters/getters.
|
19
19
|
* object/hash semantics
|
20
20
|
|
21
|
-
|
21
|
+
### require 'gorillib'
|
22
22
|
|
23
23
|
* require 'gorrillib/base'
|
24
24
|
|
25
|
-
|
25
|
+
### require 'gorillib/base'
|
26
26
|
|
27
27
|
requires the following libraries:
|
28
28
|
|
@@ -32,7 +32,7 @@ requires the following libraries:
|
|
32
32
|
* gorillib/array/compact_blank
|
33
33
|
* gorillib/object/try
|
34
34
|
|
35
|
-
|
35
|
+
### require 'gorillib/some'
|
36
36
|
|
37
37
|
requires @gorillib/base@ and the following additional libraries:
|
38
38
|
|
@@ -54,7 +54,7 @@ requires @gorillib/base@ and the following additional libraries:
|
|
54
54
|
|
55
55
|
---------------------------------------------------------------------------
|
56
56
|
|
57
|
-
|
57
|
+
### gorillib/array
|
58
58
|
|
59
59
|
* *gorrillib/array/extract_options*
|
60
60
|
- Array extract_options!
|
@@ -64,19 +64,19 @@ h3. gorillib/array
|
|
64
64
|
* *gorrillib/array/deep_compact*
|
65
65
|
- Array deep_compact, deep_compact!
|
66
66
|
|
67
|
-
|
67
|
+
### gorillib/datetime
|
68
68
|
|
69
69
|
* *gorillib/datetime/flat*
|
70
70
|
- Date, Time to_flat
|
71
71
|
* *gorillib/datetime/parse*
|
72
72
|
- Time parse_safely
|
73
73
|
|
74
|
-
|
74
|
+
### gorillib/enumerable
|
75
75
|
|
76
76
|
* *gorillib/enumerable/sum*
|
77
77
|
- Enumerable sum
|
78
78
|
|
79
|
-
|
79
|
+
### gorillib/hash
|
80
80
|
|
81
81
|
* *gorillib/hash/compact*
|
82
82
|
- Hash compact, compact!, compact_blank, compact_blank!
|
@@ -94,12 +94,12 @@ h3. gorillib/hash
|
|
94
94
|
* *gorillib/hash/zip*
|
95
95
|
- Hash Hash.zip
|
96
96
|
|
97
|
-
|
97
|
+
### gorillib/logger
|
98
98
|
|
99
99
|
* *gorillib/logger/log*
|
100
100
|
- Unless the top-level constant ::Log has been defined, opens a new Logger to STDERR and assigns it to ::Log
|
101
101
|
|
102
|
-
|
102
|
+
### gorillib/metaprogramming
|
103
103
|
|
104
104
|
* *gorillib/metaprogramming/aliasing*
|
105
105
|
- alias_method_chain
|
@@ -116,12 +116,12 @@ h3. gorillib/metaprogramming
|
|
116
116
|
* *gorillib/metaprogramming/delegation*
|
117
117
|
- Module# delegate
|
118
118
|
|
119
|
-
|
119
|
+
### gorillib/numeric
|
120
120
|
|
121
121
|
* *gorillib/numeric/clamp*
|
122
122
|
- Numeric clamp -- coerce a number to lie within a certain min/max
|
123
123
|
|
124
|
-
|
124
|
+
### gorillib/object
|
125
125
|
|
126
126
|
* *gorillib/object/blank*
|
127
127
|
- Object blank?, present? (and specialized for all other classes)
|
@@ -130,7 +130,7 @@ h3. gorillib/object
|
|
130
130
|
* *gorillib/object/try_dup*
|
131
131
|
- Object try_dup
|
132
132
|
|
133
|
-
|
133
|
+
### gorillib/string
|
134
134
|
|
135
135
|
* *gorillib/string/constantize*
|
136
136
|
- String constantize
|
@@ -148,9 +148,9 @@ h3. gorillib/string
|
|
148
148
|
|
149
149
|
---------------------------------------------------------------------------
|
150
150
|
|
151
|
-
|
151
|
+
## Maybe and No
|
152
152
|
|
153
|
-
|
153
|
+
#### Maybe
|
154
154
|
|
155
155
|
* *Mash*
|
156
156
|
* *Receiver*
|
@@ -162,7 +162,7 @@ h4. Maybe
|
|
162
162
|
* *extlib/module/find_const*
|
163
163
|
- Module find_const
|
164
164
|
|
165
|
-
|
165
|
+
#### No
|
166
166
|
|
167
167
|
* String classify -- this singularizes. You want camelize unless you're in ActiveSupport
|
168
168
|
* Object tap isn't necessary -- included in 1.8.7+
|
@@ -173,7 +173,7 @@ h4. No
|
|
173
173
|
|
174
174
|
---------------------------------------------------------------------------
|
175
175
|
|
176
|
-
|
176
|
+
## Credits & Copyright
|
177
177
|
|
178
178
|
Most of this code is ripped from active_support and extlib -- their license
|
179
179
|
carries over. Everything else is Copyright (c) 2011 Infochimps. See LICENSE.txt
|
data/Rakefile
CHANGED
@@ -44,8 +44,6 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
44
44
|
spec.rcov_opts = %w[ --exclude .rvm --no-comments --text-summary]
|
45
45
|
end
|
46
46
|
|
47
|
-
task :default => :spec
|
48
|
-
|
49
47
|
require 'yard'
|
50
48
|
YARD::Rake::YardocTask.new do
|
51
49
|
Bundler.setup(:default, :development, :docs)
|
@@ -54,3 +52,5 @@ end
|
|
54
52
|
|
55
53
|
# App-specific tasks
|
56
54
|
Dir[File.dirname(__FILE__)+'/lib/tasks/**/*.rake'].sort.each{|f| load f }
|
55
|
+
|
56
|
+
task :default => [:spec]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/gorillib.gemspec
CHANGED
@@ -5,16 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gorillib"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Infochimps"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-02-28"
|
13
13
|
s.description = "Gorillib: infochimps lightweight subset of ruby convenience methods"
|
14
14
|
s.email = "coders@infochimps.org"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.textile",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"CHANGELOG.textile",
|
23
23
|
"Gemfile",
|
24
24
|
"LICENSE.textile",
|
25
|
-
"README.
|
25
|
+
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"gorillib.gemspec",
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"lib/gorillib/base.rb",
|
35
35
|
"lib/gorillib/datetime/flat.rb",
|
36
36
|
"lib/gorillib/datetime/parse.rb",
|
37
|
+
"lib/gorillib/dsl_object.rb",
|
37
38
|
"lib/gorillib/enumerable/sum.rb",
|
38
39
|
"lib/gorillib/hash/compact.rb",
|
39
40
|
"lib/gorillib/hash/deep_compact.rb",
|
@@ -90,6 +91,7 @@ Gem::Specification.new do |s|
|
|
90
91
|
"spec/array/extract_options_spec.rb",
|
91
92
|
"spec/datetime/flat_spec.rb",
|
92
93
|
"spec/datetime/parse_spec.rb",
|
94
|
+
"spec/dsl_object_spec.rb",
|
93
95
|
"spec/enumerable/sum_spec.rb",
|
94
96
|
"spec/hash/compact_spec.rb",
|
95
97
|
"spec/hash/deep_compact_spec.rb",
|
@@ -138,9 +140,9 @@ Gem::Specification.new do |s|
|
|
138
140
|
s.homepage = "http://infochimps.com/labs"
|
139
141
|
s.licenses = ["MIT"]
|
140
142
|
s.require_paths = ["lib"]
|
141
|
-
s.rubygems_version = "1.8.
|
143
|
+
s.rubygems_version = "1.8.15"
|
142
144
|
s.summary = "include only what you need. No dependencies, no creep"
|
143
|
-
s.test_files = ["spec/array/compact_blank_spec.rb", "spec/array/extract_options_spec.rb", "spec/datetime/flat_spec.rb", "spec/datetime/parse_spec.rb", "spec/enumerable/sum_spec.rb", "spec/hash/compact_spec.rb", "spec/hash/deep_compact_spec.rb", "spec/hash/deep_merge_spec.rb", "spec/hash/indifferent_access_spec.rb", "spec/hash/keys_spec.rb", "spec/hash/reverse_merge_spec.rb", "spec/hash/slice_spec.rb", "spec/hash/zip_spec.rb", "spec/hashlike/behave_same_as_hash_spec.rb", "spec/hashlike/deep_hash_spec.rb", "spec/hashlike/hashlike_behavior_spec.rb", "spec/hashlike/hashlike_via_accessors_spec.rb", "spec/hashlike_spec.rb", "spec/logger/log_spec.rb", "spec/metaprogramming/aliasing_spec.rb", "spec/metaprogramming/cattr_accessor_spec.rb", "spec/metaprogramming/class_attribute_spec.rb", "spec/metaprogramming/delegation_spec.rb", "spec/metaprogramming/mattr_accessor_spec.rb", "spec/metaprogramming/singleton_class_spec.rb", "spec/numeric/clamp_spec.rb", "spec/object/blank_spec.rb", "spec/object/try_dup_spec.rb", "spec/object/try_spec.rb", "spec/receiver/acts_as_hash_spec.rb", "spec/receiver_spec.rb", "spec/spec_helper.rb", "spec/string/constantize_spec.rb", "spec/string/human_spec.rb", "spec/string/inflections_spec.rb", "spec/string/inflector_test_cases.rb", "spec/string/truncate_spec.rb", "spec/struct/acts_as_hash_fuzz_spec.rb", "spec/struct/acts_as_hash_spec.rb", "spec/support/hashlike_fuzzing_helper.rb", "spec/support/hashlike_helper.rb", "spec/support/hashlike_struct_helper.rb", "spec/support/hashlike_via_delegation.rb", "spec/support/kcode_test_helper.rb", "spec/support/matchers/be_array_eql.rb", "spec/support/matchers/be_hash_eql.rb", "spec/support/matchers/enumerate_method.rb", "spec/support/matchers/evaluate_to_true.rb"]
|
145
|
+
s.test_files = ["spec/array/compact_blank_spec.rb", "spec/array/extract_options_spec.rb", "spec/datetime/flat_spec.rb", "spec/datetime/parse_spec.rb", "spec/dsl_object_spec.rb", "spec/enumerable/sum_spec.rb", "spec/hash/compact_spec.rb", "spec/hash/deep_compact_spec.rb", "spec/hash/deep_merge_spec.rb", "spec/hash/indifferent_access_spec.rb", "spec/hash/keys_spec.rb", "spec/hash/reverse_merge_spec.rb", "spec/hash/slice_spec.rb", "spec/hash/zip_spec.rb", "spec/hashlike/behave_same_as_hash_spec.rb", "spec/hashlike/deep_hash_spec.rb", "spec/hashlike/hashlike_behavior_spec.rb", "spec/hashlike/hashlike_via_accessors_spec.rb", "spec/hashlike_spec.rb", "spec/logger/log_spec.rb", "spec/metaprogramming/aliasing_spec.rb", "spec/metaprogramming/cattr_accessor_spec.rb", "spec/metaprogramming/class_attribute_spec.rb", "spec/metaprogramming/delegation_spec.rb", "spec/metaprogramming/mattr_accessor_spec.rb", "spec/metaprogramming/singleton_class_spec.rb", "spec/numeric/clamp_spec.rb", "spec/object/blank_spec.rb", "spec/object/try_dup_spec.rb", "spec/object/try_spec.rb", "spec/receiver/acts_as_hash_spec.rb", "spec/receiver_spec.rb", "spec/spec_helper.rb", "spec/string/constantize_spec.rb", "spec/string/human_spec.rb", "spec/string/inflections_spec.rb", "spec/string/inflector_test_cases.rb", "spec/string/truncate_spec.rb", "spec/struct/acts_as_hash_fuzz_spec.rb", "spec/struct/acts_as_hash_spec.rb", "spec/support/hashlike_fuzzing_helper.rb", "spec/support/hashlike_helper.rb", "spec/support/hashlike_struct_helper.rb", "spec/support/hashlike_via_delegation.rb", "spec/support/kcode_test_helper.rb", "spec/support/matchers/be_array_eql.rb", "spec/support/matchers/be_hash_eql.rb", "spec/support/matchers/enumerate_method.rb", "spec/support/matchers/evaluate_to_true.rb"]
|
144
146
|
|
145
147
|
if s.respond_to? :specification_version then
|
146
148
|
s.specification_version = 3
|
@@ -151,12 +153,16 @@ Gem::Specification.new do |s|
|
|
151
153
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
|
152
154
|
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
|
153
155
|
s.add_development_dependency(%q<yard>, ["~> 0.6"])
|
156
|
+
s.add_development_dependency(%q<cucumber>, ["~> 1"])
|
157
|
+
s.add_development_dependency(%q<aruba>, ["~> 0.4"])
|
154
158
|
else
|
155
159
|
s.add_dependency(%q<json>, [">= 0"])
|
156
160
|
s.add_dependency(%q<bundler>, ["~> 1"])
|
157
161
|
s.add_dependency(%q<jeweler>, ["~> 1.6"])
|
158
162
|
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
159
163
|
s.add_dependency(%q<yard>, ["~> 0.6"])
|
164
|
+
s.add_dependency(%q<cucumber>, ["~> 1"])
|
165
|
+
s.add_dependency(%q<aruba>, ["~> 0.4"])
|
160
166
|
end
|
161
167
|
else
|
162
168
|
s.add_dependency(%q<json>, [">= 0"])
|
@@ -164,6 +170,8 @@ Gem::Specification.new do |s|
|
|
164
170
|
s.add_dependency(%q<jeweler>, ["~> 1.6"])
|
165
171
|
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
166
172
|
s.add_dependency(%q<yard>, ["~> 0.6"])
|
173
|
+
s.add_dependency(%q<cucumber>, ["~> 1"])
|
174
|
+
s.add_dependency(%q<aruba>, ["~> 0.4"])
|
167
175
|
end
|
168
176
|
end
|
169
177
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'gorillib'
|
2
|
+
|
3
|
+
class DslObject
|
4
|
+
|
5
|
+
class_attribute :properties
|
6
|
+
self.properties = {}
|
7
|
+
|
8
|
+
def self.property(name, opts={})
|
9
|
+
unless method_defined? name
|
10
|
+
define_method(name) do |val=nil|
|
11
|
+
set(name, val) unless val.nil?
|
12
|
+
get(name)
|
13
|
+
end
|
14
|
+
self.properties[name.to_sym] = opts[:default] || nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(attrs={})
|
19
|
+
define_properties!(attrs)
|
20
|
+
impose_defaults!
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def configure(attrs={}, &block)
|
25
|
+
define_properties!(attrs)
|
26
|
+
instance_eval(&block) if block
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def set(property, val)
|
31
|
+
instance_variable_set("@" + property.to_s, val)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(property)
|
35
|
+
instance_variable_get("@" + property.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
def set?(property)
|
39
|
+
instance_variable_defined?("@" + property.to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
def unset!(property)
|
43
|
+
remove_instance_variable("@" + property.to_s) if set?(property)
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_hash
|
47
|
+
self.properties.inject({}){ |hsh,(key,val)| hsh[key] = get(key) ; hsh }
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
"<#{self.class} #{to_hash.inspect}>"
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def impose_defaults!
|
57
|
+
self.class.properties.each{ |key, val| set(key, val) unless set?(key) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def define_properties!(hsh)
|
61
|
+
hsh.each{ |name,val| self.class.property(name); set(name, val) }
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gorillib/dsl_object'
|
3
|
+
|
4
|
+
|
5
|
+
describe DslObject do
|
6
|
+
let(:test_property) { :yo_momma }
|
7
|
+
let(:attrs) { { test_property => "is so fat" } }
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
DslObject.send(:remove_method, test_property) if DslObject.method_defined? test_property
|
11
|
+
DslObject.properties = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
context DslObject, ".new" do
|
15
|
+
subject { DslObject.new(attrs) }
|
16
|
+
|
17
|
+
it "transforms an attribute hash given as a constructor argument into properties" do
|
18
|
+
subject.to_hash.should include attrs
|
19
|
+
subject.should respond_to test_property
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context DslObject, ".property" do
|
24
|
+
subject { DslObject.new(attrs) }
|
25
|
+
|
26
|
+
it "defines a method on a DslObject instance" do
|
27
|
+
DslObject.property(test_property)
|
28
|
+
subject.should respond_to test_property
|
29
|
+
end
|
30
|
+
|
31
|
+
it "allows a default return value to be established for a property" do
|
32
|
+
DslObject.property(test_property, :default => "is so fat")
|
33
|
+
subject.send(test_property).should == "is so fat"
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:existing_method) { :class }
|
37
|
+
it "does not allow a property to override an existing method" do
|
38
|
+
DslObject.property(existing_method, :default => "override")
|
39
|
+
subject.send(existing_method).should_not == "override"
|
40
|
+
subject.should_not be_instance_variable_defined("@" + existing_method.to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context DslObject, "#configure" do
|
45
|
+
let(:dsl_object) { DslObject.new }
|
46
|
+
subject { double :context_obj, :delegate => dsl_object }
|
47
|
+
|
48
|
+
it "delegates the configure block to the DslObject instance" do
|
49
|
+
dsl_object.should_receive(test_property)
|
50
|
+
subject.should_not_receive(test_property)
|
51
|
+
subject.delegate.configure { yo_momma "is so fat" }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context DslObject, "#to_s" do
|
56
|
+
subject { DslObject.new(attrs) }
|
57
|
+
|
58
|
+
it "prints to the screen with its class name and properties" do
|
59
|
+
subject.to_s.should =~ /#{subject.class}.*#{attrs}/
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context DslObject, "#set" do
|
64
|
+
subject { DslObject.new(attrs) }
|
65
|
+
|
66
|
+
it "sets a property correctly" do
|
67
|
+
subject.set(test_property, "is so dumb")
|
68
|
+
subject.to_hash.should include(test_property => "is so dumb" )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context DslObject, "#get" do
|
73
|
+
subject { DslObject.new(attrs) }
|
74
|
+
|
75
|
+
it "returns a property correctly" do
|
76
|
+
subject.get(test_property).should == "is so fat"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context DslObject, "#set?" do
|
81
|
+
subject { DslObject.new(attrs) }
|
82
|
+
|
83
|
+
it "correctly determines if a property is set" do
|
84
|
+
subject.set?(test_property).should be_true
|
85
|
+
subject.set?(:not_set).should be_false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context DslObject, "#unset!" do
|
90
|
+
subject { DslObject.new(attrs) }
|
91
|
+
|
92
|
+
it "unsets a property" do
|
93
|
+
subject.unset!(test_property)
|
94
|
+
subject.set?(test_property).should be_false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorillib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2185903920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2185903920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2185903440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2185903440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2185902960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.6'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2185902960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2185902460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '2.5'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2185902460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard
|
60
|
-
requirement: &
|
60
|
+
requirement: &2185901980 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,21 +65,43 @@ dependencies:
|
|
65
65
|
version: '0.6'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2185901980
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: &2185901500 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2185901500
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: aruba
|
82
|
+
requirement: &2185901020 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.4'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2185901020
|
69
91
|
description: ! 'Gorillib: infochimps lightweight subset of ruby convenience methods'
|
70
92
|
email: coders@infochimps.org
|
71
93
|
executables: []
|
72
94
|
extensions: []
|
73
95
|
extra_rdoc_files:
|
74
96
|
- LICENSE.textile
|
75
|
-
- README.
|
97
|
+
- README.md
|
76
98
|
files:
|
77
99
|
- .gitignore
|
78
100
|
- .rspec
|
79
101
|
- CHANGELOG.textile
|
80
102
|
- Gemfile
|
81
103
|
- LICENSE.textile
|
82
|
-
- README.
|
104
|
+
- README.md
|
83
105
|
- Rakefile
|
84
106
|
- VERSION
|
85
107
|
- gorillib.gemspec
|
@@ -91,6 +113,7 @@ files:
|
|
91
113
|
- lib/gorillib/base.rb
|
92
114
|
- lib/gorillib/datetime/flat.rb
|
93
115
|
- lib/gorillib/datetime/parse.rb
|
116
|
+
- lib/gorillib/dsl_object.rb
|
94
117
|
- lib/gorillib/enumerable/sum.rb
|
95
118
|
- lib/gorillib/hash/compact.rb
|
96
119
|
- lib/gorillib/hash/deep_compact.rb
|
@@ -147,6 +170,7 @@ files:
|
|
147
170
|
- spec/array/extract_options_spec.rb
|
148
171
|
- spec/datetime/flat_spec.rb
|
149
172
|
- spec/datetime/parse_spec.rb
|
173
|
+
- spec/dsl_object_spec.rb
|
150
174
|
- spec/enumerable/sum_spec.rb
|
151
175
|
- spec/hash/compact_spec.rb
|
152
176
|
- spec/hash/deep_compact_spec.rb
|
@@ -206,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
230
|
version: '0'
|
207
231
|
segments:
|
208
232
|
- 0
|
209
|
-
hash:
|
233
|
+
hash: 387201475316777610
|
210
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
235
|
none: false
|
212
236
|
requirements:
|
@@ -215,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
239
|
version: '0'
|
216
240
|
requirements: []
|
217
241
|
rubyforge_project:
|
218
|
-
rubygems_version: 1.8.
|
242
|
+
rubygems_version: 1.8.15
|
219
243
|
signing_key:
|
220
244
|
specification_version: 3
|
221
245
|
summary: include only what you need. No dependencies, no creep
|
@@ -224,6 +248,7 @@ test_files:
|
|
224
248
|
- spec/array/extract_options_spec.rb
|
225
249
|
- spec/datetime/flat_spec.rb
|
226
250
|
- spec/datetime/parse_spec.rb
|
251
|
+
- spec/dsl_object_spec.rb
|
227
252
|
- spec/enumerable/sum_spec.rb
|
228
253
|
- spec/hash/compact_spec.rb
|
229
254
|
- spec/hash/deep_compact_spec.rb
|