opium 1.1.6 → 1.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 544c54e1dac7cf8a8adb4f02fc4335c33c9778b7
4
- data.tar.gz: 81bab9d1dbd8139fd8c73d830b16476e1e6b42d2
3
+ metadata.gz: d5e7b88ef5afc4f4bb9899031776ef2947c8043c
4
+ data.tar.gz: 6d53e858f5ebfc9b448e7a9d98344ca4b2c30fc9
5
5
  SHA512:
6
- metadata.gz: c6c906d84d6b3499c0c531fda9966e19e06b80c91e31a850b147bc6c11887120ece07ae9c54b931b6b05496adf0fcdbc8aacfa2d78b9284026c974b424cf4449
7
- data.tar.gz: c9a2d427d4f7b961382eeed079fd1400ef2304ea2861577f2cf67354657cc462b673c7fe59c9cad4714d307d11296bdabd9b934091e9c9277b7712ce83878da4
6
+ metadata.gz: 85938d9d4858f607cc93c87b4f212cef1e5812f1bce17b6fc9a18b9f268dc50755ea3f24375ed07dc5e038a96bcb99c79198698a0e09b6da0fa21d6f074f6b14
7
+ data.tar.gz: 25eec023d9656b0a965da55b39c101a1b3fc551e419784cee75798bd07cb77809b0037dbbf262b3e418fa817415560951ce276fe2426e5fa4fee5660fd1c4ace
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## 1.1.7
2
+ ### Resolved Issues
3
+ - #40: `Opium::File.to_ruby` now correctly handles JSON string representation of hashes.
4
+
1
5
  ## 1.1.6
2
6
  ### Resolved Issues
3
- - #39: `Opium::File#upload` now paramterizes the file name.
7
+ - #39: `Opium::File.upload` now paramterizes the file name.
4
8
  - #38: Added Content-Length and Transfer-Encoding headers to file uploads.
5
9
 
6
10
  ## 1.1.5
data/lib/opium/file.rb CHANGED
@@ -23,6 +23,7 @@ module Opium
23
23
  def to_ruby( object )
24
24
  return unless object
25
25
  return object if object.is_a?( self )
26
+ object = ::JSON.parse( object ) if object.is_a?( String )
26
27
  if object.is_a?( Hash ) && (has_key_of_value( object, :__type, 'File' ) || has_keys( object, :url, :name ))
27
28
  new( object )
28
29
  else
@@ -58,7 +59,7 @@ module Opium
58
59
  end
59
60
 
60
61
  def has_keys( object, *keys )
61
- object.keys.all? {|key| keys.include? key}
62
+ object.keys.all? {|key| keys.include?( key.to_s ) || keys.include?( key.to_sym )}
62
63
  end
63
64
 
64
65
  def parameterize_name( name )
data/lib/opium/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opium
2
- VERSION = "1.1.6"
2
+ VERSION = "1.1.7"
3
3
  end
@@ -125,6 +125,13 @@ describe Opium::File do
125
125
  it { expect( result ).to be_nil }
126
126
  end
127
127
 
128
+ context 'when given a JSON string' do
129
+ let(:object) { { url: location, name: 'chunky_bacon.jpg' }.to_json }
130
+
131
+ it { expect { result }.to_not raise_exception }
132
+ it { expect( result ).to be_a Opium::File }
133
+ end
134
+
128
135
  context 'when not given a hash' do
129
136
  let(:object) { 42 }
130
137
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bowers