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 +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/opium/file.rb +2 -1
- data/lib/opium/version.rb +1 -1
- data/spec/opium/file_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5e7b88ef5afc4f4bb9899031776ef2947c8043c
|
4
|
+
data.tar.gz: 6d53e858f5ebfc9b448e7a9d98344ca4b2c30fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
data/spec/opium/file_spec.rb
CHANGED
@@ -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
|
|