center_image_tag 0.0.2 → 0.0.3
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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWY0ODc3MzcyYTZiYzgxMThjZjQ4MDc2YzkwYjVhMjdkODZhMmU1Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTZlNTIyNzEzZjczZWI3MjgzZTlhYWFlNGE4MjhiNjQ3ZGYxNDhjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDJjNzA1MzU4NGIzYTU2MTg3OGM1MzM4ZTAzMGVhM2NlMmE2MTQzMzc4ZDgx
|
10
|
+
MTliZDhhNjFkNTFmZTM1NGNjZjI3ZGRlNWYyOTFjY2JkMzU1NGIwNTc3YzY1
|
11
|
+
OTFjNmU5Y2IzNTA4YjIyZDdkNTQ3MjJjZjk2NTM1ODcyZjA0MDg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjdjZDBmMDE5OTgwZDE2NGUzYmYyNzE0MTBiYzZiN2Y0OTdlMjYwMTc2MDE1
|
14
|
+
NDhiZTlkNjk4M2JkZTYyMGVmNDU2MWIwYjMyYjdmZDc4Y2ZiOGZhMTFkYjMx
|
15
|
+
ZThiNmZiMjVkMTk5YzI4ODE3OTVhMTM5N2VkODYxMmQxZTZjMjk=
|
@@ -7,16 +7,33 @@ module CenterImageTag
|
|
7
7
|
include ActionView::Helpers::AssetTagHelper
|
8
8
|
|
9
9
|
def center_image_tag(source, options = {})
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
tag(:span, class: 'vertical-align')
|
16
|
-
end
|
10
|
+
if fluid_percentage = options.delete(:fluid)
|
11
|
+
return container_fluid fluid_percentage do
|
12
|
+
clip do
|
13
|
+
image_tag(source, options) +
|
14
|
+
tag(:span, class: "vertical-align")
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
19
|
+
image_tag(source, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def container_fluid(fluid_percentage, &block)
|
24
|
+
div class: "standard-thumb thumb-fluid" do
|
25
|
+
div class: "thumb-default", style: "padding-bottom: #{fluid_percentage}", &block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def clip(&block)
|
30
|
+
div class: "thumb-clip" do
|
31
|
+
div class: "thumb-clip-inner", &block
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def div(options = {}, &block)
|
36
|
+
content_tag :div, options, &block
|
20
37
|
end
|
21
38
|
end
|
22
39
|
end
|
data/spec/view_helper_spec.rb
CHANGED
@@ -2,10 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module CenterImageTag
|
4
4
|
describe ViewHelper do
|
5
|
-
it 'renders the
|
5
|
+
it 'renders the image normally if it\'s not fluid or width x height set' do
|
6
6
|
output = View.new.center_image_tag 'image.png'
|
7
|
+
expected = "<img alt=\"Image\" src=\"/images/image.png\" />"
|
8
|
+
expect(output).to eq expected
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'renders the fluid image correctly' do
|
12
|
+
output = View.new.center_image_tag 'image.png', fluid: "56.25%"
|
7
13
|
expected = "<div class=\"standard-thumb thumb-fluid\">" +
|
8
|
-
"<div class=\"thumb-default\">" +
|
14
|
+
"<div class=\"thumb-default\" style=\"padding-bottom: 56.25%\">" +
|
9
15
|
"<div class=\"thumb-clip\">" +
|
10
16
|
"<div class=\"thumb-clip-inner\">" +
|
11
17
|
"<img alt=\"Image\" src=\"/images/image.png\" />" +
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: center_image_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anh Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|