dugway 0.10.4 → 0.10.5
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 598df617fd2f3808e13f02534a7bc0c37565f1a4
|
|
4
|
+
data.tar.gz: ef91ee5c5c39ca4dbddb27fcd16023d737c88c11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fd2fc3af1ab70430c5203af1da553d5139ed48622092b3712c1ef5822366ae29b6bc4b16396150eb605d2a33a14b3345dc08a4f06661f8a8ec922d415b4ba14
|
|
7
|
+
data.tar.gz: 6fe7dbbd2264902e3ea462f34bc4286feee5e85954131e6277c63c80af9a84c4b9a0b50f18509bb7627274f29eb7d5c30ed3d73cfbb5975a3a250223c9d8b7da
|
|
@@ -8,14 +8,20 @@ module Dugway
|
|
|
8
8
|
content_tag :a, text, options
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def constrain(url = nil, width =
|
|
12
|
-
|
|
11
|
+
def constrain(url = nil, width = '-', height = '-')
|
|
12
|
+
return unless url
|
|
13
|
+
uri = URI.parse(url)
|
|
14
|
+
query = Rack::Utils.parse_nested_query uri.query
|
|
15
|
+
query.update('w' => width, 'h' => height)
|
|
16
|
+
query.delete_if { |k,v| v.nil? || v == '-' }
|
|
17
|
+
uri.query = query.to_query
|
|
18
|
+
uri.to_s
|
|
13
19
|
end
|
|
14
20
|
|
|
15
21
|
def product_image_url(image = nil, size = nil)
|
|
16
22
|
url = image ? image['url'] : 'http://images.bigcartel.com/missing.png'
|
|
17
23
|
size = legacy_size_for(size)
|
|
18
|
-
|
|
24
|
+
constrain url, size, size
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
def theme_js_url(name)
|
|
@@ -52,13 +58,6 @@ module Dugway
|
|
|
52
58
|
options
|
|
53
59
|
end
|
|
54
60
|
|
|
55
|
-
def image_url(url, width, height)
|
|
56
|
-
uri = URI.parse(url)
|
|
57
|
-
query_hash = Rack::Utils.parse_nested_query uri.query
|
|
58
|
-
uri.query = query_hash.update('w' => width, 'h' => height).to_query
|
|
59
|
-
uri.to_s
|
|
60
|
-
end
|
|
61
|
-
|
|
62
61
|
def legacy_size_for(size)
|
|
63
62
|
case size
|
|
64
63
|
when 'large' then 300
|
data/lib/dugway/version.rb
CHANGED
|
@@ -43,10 +43,20 @@ describe Dugway::Filters::UrlFilters do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
describe "#constrain" do
|
|
46
|
-
it
|
|
46
|
+
it "should constrain the image to the specified size" do
|
|
47
47
|
template = rendered_template("{{ image | product_image_url | constrain: '123', '456' }}", 'image' => product_image)
|
|
48
48
|
template.should include("#{image_url}?h=456&w=123")
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
it "should support an optional width argument" do
|
|
52
|
+
template = rendered_template("{{ image | product_image_url | constrain: '-', '456' }}", 'image' => product_image)
|
|
53
|
+
template.should include("#{image_url}?h=456")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should support an optional height argument" do
|
|
57
|
+
template = rendered_template("{{ image | product_image_url | constrain: '123' }}", 'image' => product_image)
|
|
58
|
+
template.should include("#{image_url}?w=123")
|
|
59
|
+
end
|
|
50
60
|
end
|
|
51
61
|
end
|
|
52
62
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dugway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Big Cartel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|