obf 0.6.22 → 0.6.23

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obf/external.rb +16 -1
  3. data/lib/obf/utils.rb +4 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71e30f866a01995e08ca6c519b7a80799ef40d02
4
- data.tar.gz: 6625177ac355eec234625152fac7abbacaff4515
3
+ metadata.gz: 4ce715d0852c7bb87bb8584ea041a8c5d24f403d
4
+ data.tar.gz: 103949c6a331ba5ad318fea97fc8d680499776fc
5
5
  SHA512:
6
- metadata.gz: 8dc5b6b126eac50c4dc1051760b00519b7868a68b04dc165ad8eb1a3f29e02a326165de638891c1ae2049d5b467f389e81d6fc1b56c4bdbdd7beb67c79aa53fb
7
- data.tar.gz: 7260b87077c93b60ecc73ecf918dbab60ca09ea385c8df55ed6b3ff41e6228a2149fca2ae474ac2f492773247ce1d9cfb4ffdb71632bc6780c6bcb52bac306f8
6
+ metadata.gz: b6c190232522bd729c0aa578b85726db245e29369f835af659f7cb66d3dc3900c064b11ef3f8f9172f38e04d477552a4fdb01063dd140608ddb8c7262a4a9cb5
7
+ data.tar.gz: fe1fcea209a1be6f2e652ff77258481bb14410fd146f8fed9770c1d63cf0101848c49b26f2a8cac14db6b042b2b81791856db1359c6c2ba9962adc699c675622
data/lib/obf/external.rb CHANGED
@@ -98,19 +98,34 @@ module OBF::External
98
98
  }
99
99
  if !path_hash
100
100
  image['data'] ||= OBF::Utils.image_base64(image['url']) if image['url']
101
+ if image['data'] && (!image['content_type'] || !image['width'] || !image['height'])
102
+ attrs = OBF::Utils.image_attrs(image['data'])
103
+ image['content_type'] ||= attrs['content_type']
104
+ image['width'] ||= attrs['width']
105
+ image['height'] ||= attrs['height']
106
+ end
101
107
  else
102
108
  if path_hash['images'] && path_hash['images'][image['id']]
103
109
  image['path'] = path_hash['images'][image['id']]['path']
110
+ image['content_type'] ||= path_hash['images'][image['id']]['content_type']
111
+ image['width'] ||= path_hash['images'][image['id']]['width']
112
+ image['height'] ||= path_hash['images'][image['id']]['height']
104
113
  else
105
114
  image_fetch = OBF::Utils.image_raw(image['url'] || image['data'])
106
115
  if image_fetch
107
116
  zip_path = "images/image_#{image['id']}#{image_fetch['extension']}"
108
117
  path_hash['images'] ||= {}
109
118
  path_hash['images'][image['id']] = {
110
- 'path' => zip_path
119
+ 'path' => zip_path,
120
+ 'content_type' => image_fetch['content_type'],
121
+ 'width' => image_fetch['width'],
122
+ 'height' => image_fetch['height']
111
123
  }
112
124
  path_hash['zip'].add(zip_path, image_fetch['data'])
113
125
  image['path'] = zip_path
126
+ image['content_type'] ||= image_fetch['content_type']
127
+ image['width'] ||= image_fetch['width']
128
+ image['height'] ||= image_fetch['height']
114
129
  end
115
130
  end
116
131
  end
data/lib/obf/utils.rb CHANGED
@@ -110,10 +110,10 @@ module OBF::Utils
110
110
  'data' => File.read(url),
111
111
  'content_type' => types[0] && types[0].to_s
112
112
  }
113
- attrs = image_attrs(url)
114
- image['content_type'] ||= attrs['content_type']
115
- image['width'] ||= attrs['width']
116
- image['height'] ||= attrs['height']
113
+ if !image['content_type']
114
+ attrs = image_attrs(url)
115
+ image['content_type'] ||= attrs['content_type']
116
+ end
117
117
  end
118
118
  return nil unless image
119
119
  str = "data:" + image['content_type']
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.6.22
4
+ version: 0.6.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer