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
- MTdkOGMzOWFhNGIzYjgzZDE3Y2ZhMTc1ZTg5ZjYzY2I0NzhhNDBkOA==
4
+ MWY0ODc3MzcyYTZiYzgxMThjZjQ4MDc2YzkwYjVhMjdkODZhMmU1Yg==
5
5
  data.tar.gz: !binary |-
6
- YjNlOGQxMjU2OTRhNThhZGExY2M1YjYxMDgyNjFjNGM1ODQwNTIxNg==
6
+ OTZlNTIyNzEzZjczZWI3MjgzZTlhYWFlNGE4MjhiNjQ3ZGYxNDhjMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmIwZDRlNmIxMmJlNzgxYTZhOWRiYmMwM2JlYTI3ZTcwYzVmNjIyZGJjOGIw
10
- YmFmNmZjZjJlNDhhOTUxYjBkM2MxZjljZmM5YjIzZjg2NmVmYTg3MzRjYTlk
11
- ODYzODI1YmMwODM1MjY0NDk5ZjBkMDdhY2VjZTQ0NDUwYjgwZTc=
9
+ MDJjNzA1MzU4NGIzYTU2MTg3OGM1MzM4ZTAzMGVhM2NlMmE2MTQzMzc4ZDgx
10
+ MTliZDhhNjFkNTFmZTM1NGNjZjI3ZGRlNWYyOTFjY2JkMzU1NGIwNTc3YzY1
11
+ OTFjNmU5Y2IzNTA4YjIyZDdkNTQ3MjJjZjk2NTM1ODcyZjA0MDg=
12
12
  data.tar.gz: !binary |-
13
- MzIzOTdiOWM0ZTNmYThkNzRiOWU5YjI0YzE4Mzc3ODEwZTRhMWFlNjQ2Njk4
14
- OWFmMWJjZWFlODVmZTFjNzZkNjhlNTc4M2EwOGRlNmQ5NDMwZjBjNjU4YTQy
15
- Y2VkNWJhZmVkZmNlNTFkYTAwMDgwY2M1NTgzM2Y5N2MyMWU0MzA=
13
+ YjdjZDBmMDE5OTgwZDE2NGUzYmYyNzE0MTBiYzZiN2Y0OTdlMjYwMTc2MDE1
14
+ NDhiZTlkNjk4M2JkZTYyMGVmNDU2MWIwYjMyYjdmZDc4Y2ZiOGZhMTFkYjMx
15
+ ZThiNmZiMjVkMTk5YzI4ODE3OTVhMTM5N2VkODYxMmQxZTZjMjk=
@@ -1,3 +1,3 @@
1
1
  module CenterImageTag
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -7,16 +7,33 @@ module CenterImageTag
7
7
  include ActionView::Helpers::AssetTagHelper
8
8
 
9
9
  def center_image_tag(source, options = {})
10
- content_tag :div, class: 'standard-thumb thumb-fluid' do
11
- content_tag :div, class: 'thumb-default' do
12
- content_tag :div, class: 'thumb-clip' do
13
- content_tag :div, class: 'thumb-clip-inner' do
14
- image_tag(source, options) +
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
@@ -2,10 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  module CenterImageTag
4
4
  describe ViewHelper do
5
- it 'renders the html correctly' do
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\" />" +
@@ -26,7 +26,6 @@
26
26
  }
27
27
 
28
28
  .thumb-default {
29
- padding-bottom: 56.25%;
30
29
  display: block;
31
30
  height: auto;
32
31
  }
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.2
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-27 00:00:00.000000000 Z
11
+ date: 2013-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack