clear_helper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @rubygems
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rails', '> 3.2.0'
5
+ end
6
+
7
+ # Specify your gem's dependencies in clear_helper.gemspec
8
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Philip Hallstrom
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # ClearHelper
2
+
3
+ ClearHelper is a simple method helper to make creating a "cleared" div
4
+ simple and consistent across platforms. You can specify whether you want to
5
+ clear 'both', 'left', or 'right' and set the height of the div in any unit you
6
+ want (defaults to pixels).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'clear_helper'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install clear_helper
21
+
22
+ ## Usage
23
+
24
+ <%= clear %>
25
+ <div style="clear:both; height: 0; max-height: 0; line-height: 0;">&nbsp;</div>
26
+
27
+ <%= clear(:left) %>
28
+ <div style="clear:left; height: 0px; max-height: 0px; line-height: 0px;">&nbsp;</div>
29
+
30
+ Failure to specify the unit for the height will default to 'px'.
31
+
32
+ <%= clear(:right, 10) %>
33
+ <div style="clear:left; height: 10px; max-height: 10px; line-height: 10px;">&nbsp;</div>
34
+
35
+ If the first value is not one of 'both', 'left', or 'right' it will be assumed to be the height
36
+ and will default to 'both'.
37
+
38
+ <%= clear('2.5em') %>
39
+ <div style="clear:both; height: 2.5em; max-height: 2.5em; line-height: 2.5em;">&nbsp;</div>
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib'
6
+ test.libs << 'test'
7
+ test.pattern = 'test/**/test_*.rb'
8
+ test.verbose = true
9
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'clear_helper/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "clear_helper"
8
+ gem.version = ClearHelper::VERSION
9
+ gem.authors = ["Philip Hallstrom"]
10
+ gem.email = ["philip@pjkh.com"]
11
+ gem.description = %q{A Rails helper method to simplify generation of "clear" divs}
12
+ gem.summary = %q{ClearHelper is a simple method helper to make creating a "cleared" div simple and consistent across platforms. You can specify whether you want to clear 'both', 'left', or 'right' and set the height of the div in any unit you want (defaults to pixels)}
13
+ gem.homepage = "https://github.com/phallstrom/clear_helper"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,33 @@
1
+ require "clear_helper/version"
2
+
3
+ module ClearHelper
4
+ module TagHelper
5
+
6
+ def clear(clear = 'both', height = '0')
7
+ options = {}
8
+ if clear.is_a?(Hash)
9
+ options = clear.stringify_keys.reverse_merge!('clear' => 'both', 'height' => '0')
10
+ else
11
+ unless %w[left right both].include?(clear.to_s)
12
+ height = clear
13
+ clear = 'both'
14
+ end
15
+ options['height'] = height
16
+ options['clear'] = clear
17
+ end
18
+ if options['height'].to_i.to_s == options['height'].to_s
19
+ options['height'] = "#{options['height']}px" unless options['height'].to_s == '0'
20
+ end
21
+
22
+ options.reverse_merge!('max-height' => options['height'],
23
+ 'font-size' => options['height'],
24
+ 'line-height' => options['height'])
25
+
26
+ # the sort is really just so the tests pass easily
27
+ %Q{<div style="#{options.map {|e| "#{e.first}: #{e.last}" }.sort.join('; ')}">&nbsp;</div>}.try(:html_safe)
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ ActionView::Base.send :include, ClearHelper::TagHelper
@@ -0,0 +1,3 @@
1
+ module ClearHelper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'action_controller'
4
+ require 'clear_helper'
5
+
6
+ class ClearHelperTest < Test::Unit::TestCase
7
+ include ActionView::Helpers::TagHelper
8
+ include ClearHelper::TagHelper
9
+
10
+ def test_clear_helper
11
+ assert_equal '<div style="clear: both; font-size: 0; height: 0; line-height: 0; max-height: 0">&nbsp;</div>', clear
12
+ assert_equal '<div style="clear: left; font-size: 0; height: 0; line-height: 0; max-height: 0">&nbsp;</div>', clear(:left)
13
+ assert_equal '<div style="clear: left; font-size: 0; height: 0; line-height: 0; max-height: 0">&nbsp;</div>', clear('left')
14
+ assert_equal '<div style="clear: right; font-size: 10px; height: 10px; line-height: 10px; max-height: 10px">&nbsp;</div>', clear(:right, 10)
15
+ assert_equal '<div style="clear: both; font-size: 2.5em; height: 2.5em; line-height: 2.5em; max-height: 2.5em">&nbsp;</div>', clear('2.5em')
16
+ assert_equal '<div style="clear: both; font-size: 5px; height: 5px; line-height: 5px; max-height: 5px">&nbsp;</div>', clear(5)
17
+ assert_equal '<div style="clear: both; font-size: 0; height: 0; line-height: 0; max-height: 0">&nbsp;</div>', clear(:clear => :both)
18
+ assert_equal '<div style="clear: both; font-size: 0; height: 0; line-height: 0; max-height: 0">&nbsp;</div>', clear(:clear => :both)
19
+ assert_equal '<div style="clear: both; font-size: 5px; height: 5px; line-height: 5px; max-height: 5px; width: 99%">&nbsp;</div>', clear(:clear => :both, :height => 5, :width => '99%')
20
+ assert_equal '<div style="clear: both; font-size: 0; height: 0; line-height: 0; max-height: 0; width: 99%">&nbsp;</div>', clear(:width => '99%')
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clear_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Philip Hallstrom
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A Rails helper method to simplify generation of "clear" divs
15
+ email:
16
+ - philip@pjkh.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rvmrc
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - clear_helper.gemspec
28
+ - lib/clear_helper.rb
29
+ - lib/clear_helper/version.rb
30
+ - test/test_clear_helper.rb
31
+ homepage: https://github.com/phallstrom/clear_helper
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ segments:
44
+ - 0
45
+ hash: -3985196232265350545
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ segments:
53
+ - 0
54
+ hash: -3985196232265350545
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.24
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: ClearHelper is a simple method helper to make creating a "cleared" div simple
61
+ and consistent across platforms. You can specify whether you want to clear 'both',
62
+ 'left', or 'right' and set the height of the div in any unit you want (defaults
63
+ to pixels)
64
+ test_files:
65
+ - test/test_clear_helper.rb