mbleigh-mash 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.5 / 2008-04-29
2
+
3
+ * [bugfix] Mashes do not infinite loop when initialized with another Mash.
4
+
1
5
  === 0.0.4 / 2008-04-25
2
6
 
3
7
  * Setting up for GitHub gem hosting instead of Rubyforge.
data/README.txt CHANGED
@@ -46,7 +46,8 @@ http://mbleigh.lighthouseapp.com/projects/10112-mash
46
46
 
47
47
  == LICENSE:
48
48
 
49
- Copyright (c) 2008 Michael Bleigh
49
+ Copyright (c) 2008 Michael Bleigh (http://mbleigh.com/)
50
+ and Intridea Inc. (http://intridea.com/), released under the MIT license
50
51
 
51
52
  Permission is hereby granted, free of charge, to any person obtaining
52
53
  a copy of this software and associated documentation files (the
data/lib/mash.rb CHANGED
@@ -128,14 +128,14 @@ class Mash < Hash
128
128
  # Recursively merges this mash with the passed
129
129
  # in hash, merging each hash in the hierarchy.
130
130
  def deep_update(other_hash)
131
- stringified_hash = other_hash.stringify_keys
132
- stringified_hash.each_pair do |k,v|
131
+ other_hash = other_hash.stringify_keys unless other_hash.is_a?(Mash)
132
+ other_hash.each_pair do |k,v|
133
133
  k = convert_key(k)
134
134
  self[k] = self[k].to_mash if self[k].is_a?(Hash) unless self[k].is_a?(Mash)
135
- if self[k].is_a?(Hash) && stringified_hash[k].is_a?(Hash)
136
- self[k].deep_merge!(stringified_hash[k])
135
+ if self[k].is_a?(Hash) && other_hash[k].is_a?(Hash)
136
+ self[k].deep_merge!(other_hash[k])
137
137
  else
138
- self.send(k + "=", convert_value(stringified_hash[k]))
138
+ self.send(k + "=", convert_value(other_hash[k]))
139
139
  end
140
140
  end
141
141
  end
data/mash.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mash"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
4
4
  s.date = "2008-04-26"
5
5
  s.summary = "An extended Hash that gives simple pseudo-object functionality that can be built from hashes and easily extended"
6
6
  s.email = "michael@intridea.com"
data/spec/mash_spec.rb CHANGED
@@ -88,6 +88,13 @@ describe Mash do
88
88
  converted.a.first.b.should == 12
89
89
  converted.a.last.should == 23
90
90
  end
91
+
92
+ it "should convert an existing Mash into a Mash" do
93
+ initial = Mash.new(:name => 'randy')
94
+ copy = Mash.new(initial)
95
+ initial.name.should == copy.name
96
+ end
97
+
91
98
  end
92
99
  end
93
100
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbleigh-mash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh