obf 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obf/utils.rb +10 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 368ad009533dd8a70b513b9cffc3d8237ef3819d
4
- data.tar.gz: d3ff6264d754fc2a6acfb5af1b524a2adc84f632
3
+ metadata.gz: 3eb08a3e8bb4fa68e9e15ad947027c620d61289d
4
+ data.tar.gz: 7df6db4d7ab3f7d887f17ce16384730b4503c400
5
5
  SHA512:
6
- metadata.gz: 7cef727a163b99d897cbe8dda35c21694525d17c66f9437b73d1610b004b22c5df85b78316d86f7333d1b095ac728ca0a819af3ab1e873842960820efc110c0e
7
- data.tar.gz: bb0284122c5e6b8f8ea9bef4713e4e888a636b7f6525da8409a46a4bb15b230d0a36adf203576c363a568ea449d30c6a938c80a73bdfd09893dbe0431d23beb4
6
+ metadata.gz: 1e45782603c6b1b07b03627bafa42740e6e2a5cd9a89262187fdc5903128cbaaa59fc3eafaa6d4bd07fea4d6cf83f8f63586b2fc669305cd4d720b9486499b6d
7
+ data.tar.gz: b7ce1bcbd8c3cecf1f7ccc12222555422cf83d4349741fb87a2f1fb37bea82007ea758e408d236a16a400e9348f7d8e687f8bfc64ee59661f203bc8c0bc04964
data/lib/obf/utils.rb CHANGED
@@ -14,7 +14,11 @@ module OBF::Utils
14
14
  type = MIME::Types[content_type]
15
15
  type = type && type[0]
16
16
  extension = ""
17
- extension = ("." + type.preferred_extension) if type && type.extensions && type.extensions.length > 0
17
+ if type.respond_to?(:preferred_extension)
18
+ extension = ("." + type.preferred_extension) if type.preferred_extension
19
+ elsif type.respond_to?(:extensions)
20
+ extension = ("." + type.extensions[0]) if type && type.extensions && type.extensions.length > 0
21
+ end
18
22
  {
19
23
  'content_type' => content_type,
20
24
  'data' => data,
@@ -106,7 +110,11 @@ module OBF::Utils
106
110
  end
107
111
  type = MIME::Types[image['content_type']]
108
112
  type = type && type[0]
109
- extension = type && ("." + type.extensions.first)
113
+ if type.respond_to?(:preferred_extension)
114
+ extension = type && ("." + type.preferred_extension)
115
+ elsif type.respond_to?(:extensions)
116
+ extension = type && ("." + type.extensions.first)
117
+ end
110
118
  file = Tempfile.new(["image_stash", extension.to_s])
111
119
  file.binmode
112
120
  if image['data']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer