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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datts_right (0.0.23)
4
+ datts_right (0.0.24)
5
5
  datts_right
6
6
 
7
7
  GEM
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.24
1
+ 0.0.25
data/datts_right.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datts_right}
8
- s.version = "0.0.24"
8
+ s.version = "0.0.25"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ramon Tayag"]
@@ -140,17 +140,21 @@ module DattsRight
140
140
  end
141
141
 
142
142
  def add_definitions(*args)
143
- args.compact! #remove the nil items
144
- #puts "args after compacting: #{args.inspect}"
145
- args.each do |item|
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}, #{v}"
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: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 24
10
- version: 0.0.24
9
+ - 25
10
+ version: 0.0.25
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ramon Tayag