center_image_tag 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmJiMWMzZDJhMDdjMmRjZDFiYzBmMGJjZTY3NmIwZmMwNmE4NTMwYQ==
4
+ MTdkOGMzOWFhNGIzYjgzZDE3Y2ZhMTc1ZTg5ZjYzY2I0NzhhNDBkOA==
5
5
  data.tar.gz: !binary |-
6
- N2FhZGJmZTgzNmZiMWEyMDQzZjA0NmQxZjJiZTg0YTQwZmRhODY5Mg==
6
+ YjNlOGQxMjU2OTRhNThhZGExY2M1YjYxMDgyNjFjNGM1ODQwNTIxNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODE5Y2UzZDA5ODQwOWVjZjQ3YTRkMzYwOWYxNDE5ODc2ZTNmZTVhYzkxMWFh
10
- YzJmNjc1OTYzM2Q2ZmZjMjdlNjljNGE3OWE5YzNmYWExNzM2ZDZmZjliY2E2
11
- ZGRlZjJlOGNhN2I1OTJmZjQ3YjlkMGQxZmRkN2FhZjM2MDE4ZWU=
9
+ NmIwZDRlNmIxMmJlNzgxYTZhOWRiYmMwM2JlYTI3ZTcwYzVmNjIyZGJjOGIw
10
+ YmFmNmZjZjJlNDhhOTUxYjBkM2MxZjljZmM5YjIzZjg2NmVmYTg3MzRjYTlk
11
+ ODYzODI1YmMwODM1MjY0NDk5ZjBkMDdhY2VjZTQ0NDUwYjgwZTc=
12
12
  data.tar.gz: !binary |-
13
- NzU1NTQxNWRlNWQ1MjE3OTEzOGFmYjAyMjFmYjFkZjA1ZmZjNWUzMTY1NDE5
14
- MTI5M2Q5MWZiODEyYTI2YzdlMzA1MTNiODlhM2U4Y2E4YWEzZWVlOWJkY2Uw
15
- ZTQxYWRmNDMzMjQ2ZWU5NzBlM2JjNDFlYTFkZjQ4OThmOWNkMTg=
13
+ MzIzOTdiOWM0ZTNmYThkNzRiOWU5YjI0YzE4Mzc3ODEwZTRhMWFlNjQ2Njk4
14
+ OWFmMWJjZWFlODVmZTFjNzZkNjhlNTc4M2EwOGRlNmQ5NDMwZjBjNjU4YTQy
15
+ Y2VkNWJhZmVkZmNlNTFkYTAwMDgwY2M1NTgzM2Y5N2MyMWU0MzA=
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  *.iml
19
19
  .idea
20
+ .rvmrc
@@ -18,6 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'actionpack', '>= 3.0'
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec', '~> 2.12'
26
+ spec.add_development_dependency 'rspec-mocks', '>= 2.12.1'
27
+ spec.add_development_dependency 'rspec-rails', '~> 2.12'
23
28
  end
@@ -1,3 +1,3 @@
1
1
  module CenterImageTag
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,24 @@
1
+ require "action_view"
2
+
3
+ module CenterImageTag
4
+ module ViewHelper
5
+ include ActionView::Context
6
+ include ActionView::Helpers::TagHelper
7
+ include ActionView::Helpers::AssetTagHelper
8
+
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
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ ActionView::Base.send :include, CenterImageTag::ViewHelper
@@ -1,5 +1,6 @@
1
- require "center_image_tag/version"
2
-
3
1
  module CenterImageTag
4
- # Your code goes here...
2
+
5
3
  end
4
+
5
+ require "center_image_tag/version"
6
+ require 'center_image_tag/view_helper'
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ require 'center_image_tag'
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.expect_with(:rspec) {|c| c.syntax = :expect}
7
+ config.order = :random
8
+ end
9
+
10
+ class View; include CenterImageTag::ViewHelper; end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module CenterImageTag
4
+ describe ViewHelper do
5
+ it 'renders the html correctly' do
6
+ output = View.new.center_image_tag 'image.png'
7
+ expected = "<div class=\"standard-thumb thumb-fluid\">" +
8
+ "<div class=\"thumb-default\">" +
9
+ "<div class=\"thumb-clip\">" +
10
+ "<div class=\"thumb-clip-inner\">" +
11
+ "<img alt=\"Image\" src=\"/images/image.png\" />" +
12
+ "<span class=\"vertical-align\" />" +
13
+ "</div>" +
14
+ "</div>" +
15
+ "</div>" +
16
+ "</div>"
17
+ expect(output).to eq expected
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,56 @@
1
+ .standard-thumb {
2
+ display: inline-block;
3
+ vertical-align: middle;
4
+ overflow: hidden;
5
+
6
+ img {
7
+ outline: none;
8
+ }
9
+
10
+ .vertical-align {
11
+ height: 100%;
12
+ }
13
+ }
14
+
15
+ .thumb-fluid {
16
+ width: 100%;
17
+
18
+ .thumb-clip {
19
+ left: 0;
20
+ right: 0;
21
+
22
+ img {
23
+ width: 100%;
24
+ }
25
+ }
26
+ }
27
+
28
+ .thumb-default {
29
+ padding-bottom: 56.25%;
30
+ display: block;
31
+ height: auto;
32
+ }
33
+
34
+ .thumb-clip {
35
+ position: absolute;
36
+ top: -100px;
37
+ bottom: -100px;
38
+ left: -100px;
39
+ right: -100px;
40
+ text-align: center;
41
+ white-space: nowrap;
42
+ word-break: normal;
43
+
44
+ img, .vertical-align {
45
+ display: inline-block;
46
+ vertical-align: middle;
47
+ }
48
+ }
49
+
50
+ .thumb-clip-inner {
51
+ position: absolute;
52
+ width: 100%;
53
+ height: 100%;
54
+ top: 0;
55
+ left: 0;
56
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: center_image_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anh Nguyen
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,48 @@ dependencies:
38
52
  - - ! '>='
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-mocks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.12.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.12.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2.12'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.12'
41
97
  description: center_image_tag helps your Rails app to center your images easily.
42
98
  email:
43
99
  - anhkind@gmail.com
@@ -53,6 +109,10 @@ files:
53
109
  - center_image_tag.gemspec
54
110
  - lib/center_image_tag.rb
55
111
  - lib/center_image_tag/version.rb
112
+ - lib/center_image_tag/view_helper.rb
113
+ - spec/spec_helper.rb
114
+ - spec/view_helper_spec.rb
115
+ - vendor/assets/stylesheets/center_image_tag.scss
56
116
  homepage: ''
57
117
  licenses:
58
118
  - MIT
@@ -77,5 +137,6 @@ rubygems_version: 2.1.10
77
137
  signing_key:
78
138
  specification_version: 4
79
139
  summary: Center your images without js.
80
- test_files: []
81
- has_rdoc:
140
+ test_files:
141
+ - spec/spec_helper.rb
142
+ - spec/view_helper_spec.rb