datts_right 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/datts_right.gemspec +1 -1
- data/lib/datts_right/instance_methods.rb +8 -4
- data/spec/datts_right/add_definitions_spec.rb +4 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.25
|
data/datts_right.gemspec
CHANGED
@@ -140,17 +140,21 @@ module DattsRight
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def add_definitions(*args)
|
143
|
-
|
144
|
-
#
|
145
|
-
args
|
143
|
+
attributes = args
|
144
|
+
attributes.compact! if attributes#remove the nil items
|
145
|
+
#puts "args after compacting: #{attributes.inspect}"
|
146
|
+
attributes.flatten! if args.first.is_a?(Array) && attributes
|
147
|
+
#puts "args after flattening: #{attributes.inspect}"
|
148
|
+
attributes.each do |item|
|
146
149
|
#puts "Working on #{item.inspect} is is a hash? (#{item.is_a?(Hash)}) or something else?"
|
147
150
|
item.each do |k, v|
|
148
|
-
#puts "Working on this k,v pair: #{k}
|
151
|
+
#puts "Working on this k,v pair: #{k.inspect} => #{v.inspect}"
|
149
152
|
if v.is_a?(Hash) # item is like :robot => {:object_type => "text"}, :robot@ => {:object_type => "text"}
|
150
153
|
#puts "#{v} IS a hash"
|
151
154
|
add_definition k, v
|
152
155
|
else # v is not a hash; item is like {"name"=>"A key", "attr_key"=>"a_key"}, {"name"=>"B key", "attr_key"=>"b_key"}
|
153
156
|
#puts "#{v} is not a hash"
|
157
|
+
#puts "item is: #{item.inspect}. item.first: #{item.first.inspect}"
|
154
158
|
item.symbolize_keys! # {:name=>"A key", :description=>"asd", :attr_key=>"a_key"}
|
155
159
|
#puts "item is symbolized: #{item.inspect}"
|
156
160
|
attr_key = item.delete(:attr_key)
|
@@ -18,6 +18,10 @@ describe DattsRight, ".add_definitions(hash)" do
|
|
18
18
|
c.should_receive(:add_definition).with(:a_key, {:name=>"A key"})
|
19
19
|
c.should_receive(:add_definition).with(:b_key, {:name=>"B key"})
|
20
20
|
c.add_definitions({"name"=>"A key", "attr_key"=>"a_key"}, {"name"=>"B key", "attr_key"=>"b_key"})
|
21
|
+
c = Category.create
|
22
|
+
c.should_receive(:add_definition).with(:a_key, {:name=>"A key"})
|
23
|
+
c.should_receive(:add_definition).with(:b_key, {:name=>"B key"})
|
24
|
+
c.add_definitions([{"name"=>"A key", "attr_key"=>"a_key"}, {"name"=>"B key", "attr_key"=>"b_key"}])
|
21
25
|
end
|
22
26
|
|
23
27
|
it "should not explode if nil is passed" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datts_right
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 45
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 25
|
10
|
+
version: 0.0.25
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ramon Tayag
|