fancy-open-struct 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,9 @@
1
+ 0.3.0
2
+ - Deprecated the display_recursive_open_hash alias for debug_inspect
3
+ - Removed some unnecessary code from the to_h method
4
+
1
5
  0.2.0
2
6
  - Replaced the display_recursive_open_hash method with functionality from the awesome_print gem.
3
- Note: This fundamentally changes the way how this method operates, and is not backwards compatible.
4
7
  - Aliased the display_recursive_open_hash method to the debug_inspect method.
5
8
  - Changed method_missing so that it is private
6
9
 
data/README.rdoc CHANGED
@@ -4,6 +4,7 @@
4
4
  {<img src="http://allthebadges.io/tomchapin/fancy-open-struct/gemnasium.png" alt="Dependencies" />}[http://allthebadges.io/tomchapin/fancy-open-struct/gemnasium]
5
5
  {<img src="http://allthebadges.io/tomchapin/fancy-open-struct/travis.png" alt="Build Status" />}[http://allthebadges.io/tomchapin/fancy-open-struct/travis]
6
6
  {<img src="http://allthebadges.io/tomchapin/fancy-open-struct/coveralls.png" alt="Coverage" />}[http://allthebadges.io/tomchapin/fancy-open-struct/coveralls]
7
+ {<img src="http://allthebadges.io/tomchapin/fancy-open-struct/code_climate.png" alt="Code Climate" />}[http://allthebadges.io/tomchapin/fancy-open-struct/code_climate]
7
8
 
8
9
  FancyOpenStruct is a subclass of OpenStruct, and is a variant of RecursiveOpenStruct.
9
10
 
@@ -59,8 +59,6 @@ class FancyOpenStruct < OpenStruct
59
59
  newval.to_h
60
60
  elsif newval.kind_of?(Array)
61
61
  newval.map { |a| a.kind_of?(self.class) ? a.to_h : a }
62
- else
63
- raise "Cached value of unsupported type: #{newval.inspect}"
64
62
  end
65
63
  end
66
64
  end
@@ -73,8 +71,6 @@ class FancyOpenStruct < OpenStruct
73
71
  ap(@table, options)
74
72
  end
75
73
 
76
- alias_method :display_recursive_open_hash, :debug_inspect
77
-
78
74
  # Hash getter method which translates the key to a Symbol
79
75
  def [](key)
80
76
  @table[key.to_sym]
@@ -1,5 +1,5 @@
1
1
  require 'ostruct'
2
2
 
3
3
  class FancyOpenStruct < OpenStruct
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -49,9 +49,11 @@ describe FancyOpenStruct do
49
49
  describe "improvements on OpenStruct" do
50
50
 
51
51
  it "can be converted back to a hash" do
52
- h = {:asdf => 'John Smith'}
52
+ blank_obj = Object.new
53
+ h = {:asdf => 'John Smith', :foo => [{:bar => blank_obj}, {:baz => nil}]}
53
54
  fos = FancyOpenStruct.new(h)
54
55
  fos.to_h.should == h
56
+ fos.to_hash.should == h
55
57
  end
56
58
 
57
59
  describe 'hash methods' do
@@ -273,11 +275,6 @@ describe FancyOpenStruct do
273
275
  fos.debug_inspect(:indent => 1, :plain => true)
274
276
  end
275
277
  debug_inspect.string.should == expected_result
276
-
277
- display_recursive_open_hash = capture_stdout do
278
- fos.display_recursive_open_hash(:indent => 1, :plain => true)
279
- end
280
- display_recursive_open_hash.string.should == expected_result
281
278
  end
282
279
 
283
280
  it "creates nested objects via subclass" do
@@ -287,6 +284,12 @@ describe FancyOpenStruct do
287
284
 
288
285
  fossc.one.first.class.should == FancyOpenStructSubClass
289
286
  end
287
+
288
+ describe 'method aliases' do
289
+ it 'responds to #to_hash' do
290
+ FancyOpenStruct.new.respond_to?(:to_hash).should be_true
291
+ end
292
+ end
290
293
  end # additionnel features
291
294
 
292
295
  end # describe FancyOpenStruct
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy-open-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: