styled_inputs 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +27 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/{README → README.rdoc} +15 -6
- data/Rakefile +44 -36
- data/lib/styled_inputs/extensions/instance_tag.rb +14 -13
- data/lib/styled_inputs/extensions/tag_helper.rb +14 -13
- data/lib/styled_inputs.rb +34 -34
- data/test/helpers/form_helper_test.rb +43 -0
- data/test/helpers/form_tag_helper_test.rb +42 -0
- data/test/helpers/styled_inputs_test.rb +39 -0
- data/test/helpers/tag_helper_test.rb +21 -0
- data/test/test_helper.rb +3 -6
- metadata +18 -11
- data/CHANGELOG +0 -23
- data/test/styled_inputs_test.rb +0 -150
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
== master
|
2
|
+
|
3
|
+
== 0.1.0 / 2008-12-14
|
4
|
+
|
5
|
+
* Remove the PluginAWeek namespace
|
6
|
+
* Update tests to use ActionView::TestCase
|
7
|
+
|
8
|
+
== 0.0.5 / 2008-06-22
|
9
|
+
|
10
|
+
* Remove log files from gems
|
11
|
+
|
12
|
+
== 0.0.4 / 2008-06-03
|
13
|
+
|
14
|
+
* Add support for Rails 2.0+
|
15
|
+
|
16
|
+
== 0.0.3 / 2008-06-01
|
17
|
+
|
18
|
+
* Remove dependency on set_or_append
|
19
|
+
|
20
|
+
== 0.0.2 / 2008-05-05
|
21
|
+
|
22
|
+
* Updated documentation
|
23
|
+
|
24
|
+
== 0.0.1 / 2007-08-17
|
25
|
+
|
26
|
+
* Add documentation
|
27
|
+
* Convert dos newlines to unix newlines
|
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/{README → README.rdoc}
RENAMED
@@ -4,21 +4,21 @@
|
|
4
4
|
|
5
5
|
== Resources
|
6
6
|
|
7
|
-
Wiki
|
8
|
-
|
9
|
-
* http://wiki.pluginaweek.org/Styled_inputs
|
10
|
-
|
11
7
|
API
|
12
8
|
|
13
9
|
* http://api.pluginaweek.org/styled_inputs
|
14
10
|
|
11
|
+
Bugs
|
12
|
+
|
13
|
+
* http://pluginaweek.lighthouseapp.com/projects/13289-styled_inputs
|
14
|
+
|
15
15
|
Development
|
16
16
|
|
17
|
-
* http://
|
17
|
+
* http://github.com/pluginaweek/styled_inputs
|
18
18
|
|
19
19
|
Source
|
20
20
|
|
21
|
-
*
|
21
|
+
* git://github.com/pluginaweek/styled_inputs.git
|
22
22
|
|
23
23
|
== Description
|
24
24
|
|
@@ -40,6 +40,15 @@ specified is the type of input being generated.
|
|
40
40
|
text_field(:person, :name) # => <input class="text" id="person_name" name="person[name]" size="30" type="text" />
|
41
41
|
hidden_field(:person, :name) # => <input class="hidden" id="person_name" name="person[name]" type="hidden" />
|
42
42
|
|
43
|
+
== Testing
|
44
|
+
|
45
|
+
Before you can run any tests, the following gem must be installed:
|
46
|
+
* plugin_test_helper[http://github.com/pluginaweek/plugin_test_helper]
|
47
|
+
|
48
|
+
To run against a specific version of Rails:
|
49
|
+
|
50
|
+
rake test RAILS_FRAMEWORK_ROOT=/path/to/rails
|
51
|
+
|
43
52
|
== Dependencies
|
44
53
|
|
45
54
|
* Rails 2.0 or later
|
data/Rakefile
CHANGED
@@ -3,46 +3,54 @@ require 'rake/rdoctask'
|
|
3
3
|
require 'rake/gempackagetask'
|
4
4
|
require 'rake/contrib/sshpublisher'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.name = 'styled_inputs'
|
8
|
+
s.version = '0.1.0'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'Adds automated styling of input fields with css classes'
|
11
|
+
|
12
|
+
s.files = FileList['{lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.test_files = Dir['test/**/*_test.rb']
|
16
|
+
|
17
|
+
s.author = 'Aaron Pfeifer'
|
18
|
+
s.email = 'aaron@pluginaweek.org'
|
19
|
+
s.homepage = 'http://www.pluginaweek.org'
|
20
|
+
s.rubyforge_project = 'pluginaweek'
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Default: run all tests.'
|
12
24
|
task :default => :test
|
13
25
|
|
14
|
-
desc
|
26
|
+
desc "Test the #{spec.name} plugin."
|
15
27
|
Rake::TestTask.new(:test) do |t|
|
16
28
|
t.libs << 'lib'
|
17
|
-
t.
|
29
|
+
t.test_files = spec.test_files
|
18
30
|
t.verbose = true
|
19
31
|
end
|
20
32
|
|
21
|
-
|
33
|
+
begin
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
namespace :test do
|
36
|
+
desc "Test the #{spec.name} plugin with Rcov."
|
37
|
+
Rcov::RcovTask.new(:rcov) do |t|
|
38
|
+
t.libs << 'lib'
|
39
|
+
t.test_files = spec.test_files
|
40
|
+
t.rcov_opts << '--exclude="^(?!lib/)"'
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Generate documentation for the #{spec.name} plugin."
|
22
48
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
23
49
|
rdoc.rdoc_dir = 'rdoc'
|
24
|
-
rdoc.title =
|
50
|
+
rdoc.title = spec.name
|
25
51
|
rdoc.template = '../rdoc_template.rb'
|
26
52
|
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
-
rdoc.rdoc_files.include('README')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
-
end
|
30
|
-
|
31
|
-
spec = Gem::Specification.new do |s|
|
32
|
-
s.name = PKG_NAME
|
33
|
-
s.version = PKG_VERSION
|
34
|
-
s.platform = Gem::Platform::RUBY
|
35
|
-
s.summary = 'Adds automated styling of input fields with css classes'
|
36
|
-
|
37
|
-
s.files = FileList['{lib,test}/**/*'].to_a - FileList['test/app_root/log/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
|
38
|
-
s.require_path = 'lib'
|
39
|
-
s.autorequire = 'styled_inputs'
|
40
|
-
s.has_rdoc = true
|
41
|
-
s.test_files = Dir['test/**/*_test.rb']
|
42
|
-
|
43
|
-
s.author = 'Aaron Pfeifer'
|
44
|
-
s.email = 'aaron@pluginaweek.org'
|
45
|
-
s.homepage = 'http://www.pluginaweek.org'
|
53
|
+
rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
|
46
54
|
end
|
47
55
|
|
48
56
|
Rake::GemPackageTask.new(spec) do |p|
|
@@ -51,14 +59,14 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
51
59
|
p.need_zip = true
|
52
60
|
end
|
53
61
|
|
54
|
-
desc 'Publish the beta gem'
|
62
|
+
desc 'Publish the beta gem.'
|
55
63
|
task :pgem => [:package] do
|
56
|
-
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{
|
64
|
+
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
|
57
65
|
end
|
58
66
|
|
59
|
-
desc 'Publish the API documentation'
|
67
|
+
desc 'Publish the API documentation.'
|
60
68
|
task :pdoc => [:rdoc] do
|
61
|
-
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{
|
69
|
+
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
|
62
70
|
end
|
63
71
|
|
64
72
|
desc 'Publish the API docs and gem'
|
@@ -71,10 +79,10 @@ task :release => [:gem, :package] do
|
|
71
79
|
ruby_forge = RubyForge.new.configure
|
72
80
|
ruby_forge.login
|
73
81
|
|
74
|
-
%w(
|
75
|
-
file = "pkg/#{
|
82
|
+
%w(gem tgz zip).each do |ext|
|
83
|
+
file = "pkg/#{spec.name}-#{spec.version}.#{ext}"
|
76
84
|
puts "Releasing #{File.basename(file)}..."
|
77
85
|
|
78
|
-
ruby_forge.add_release(
|
86
|
+
ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
|
79
87
|
end
|
80
88
|
end
|
@@ -1,21 +1,22 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def tag_with_styled_inputs(name, options, *args) #:nodoc:
|
12
|
-
tag_without_styled_inputs(name, styled_input(name, options), *args)
|
1
|
+
module StyledInputs
|
2
|
+
module Extensions #:nodoc:
|
3
|
+
# Adds support for hooking calls to +tag+ for form fields
|
4
|
+
module InstanceTag
|
5
|
+
def self.included(base) #:nodoc:
|
6
|
+
base.class_eval do
|
7
|
+
alias_method_chain :tag, :styled_inputs
|
13
8
|
end
|
14
9
|
end
|
10
|
+
|
11
|
+
# Ensure that the options are updated for input tags before generating
|
12
|
+
# the html for the tag
|
13
|
+
def tag_with_styled_inputs(name, options, *args) #:nodoc:
|
14
|
+
tag_without_styled_inputs(name, styled_input(name, options), *args)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
ActionView::Helpers::InstanceTag.class_eval do
|
20
|
-
include
|
21
|
+
include StyledInputs::Extensions::InstanceTag
|
21
22
|
end
|
@@ -1,21 +1,22 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def tag_with_styled_inputs(name, options = nil, *args) #:nodoc:
|
12
|
-
tag_without_styled_inputs(name, styled_input(name, options), *args)
|
1
|
+
module StyledInputs
|
2
|
+
module Extensions #:nodoc:
|
3
|
+
# Adds support for hooking calls to +tag+
|
4
|
+
module TagHelper
|
5
|
+
def self.included(base) #:nodoc:
|
6
|
+
base.class_eval do
|
7
|
+
alias_method_chain :tag, :styled_inputs
|
13
8
|
end
|
14
9
|
end
|
10
|
+
|
11
|
+
# Ensure that the options are updated for input tags before generating
|
12
|
+
# the html for the tag
|
13
|
+
def tag_with_styled_inputs(name, options = nil, *args) #:nodoc:
|
14
|
+
tag_without_styled_inputs(name, styled_input(name, options), *args)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
ActionView::Helpers::TagHelper.class_eval do
|
20
|
-
include
|
21
|
+
include StyledInputs::Extensions::TagHelper
|
21
22
|
end
|
data/lib/styled_inputs.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
1
|
require 'styled_inputs/extensions/tag_helper'
|
2
2
|
require 'styled_inputs/extensions/instance_tag'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
options
|
4
|
+
# Automatically adds css classes to input tags so that fields can be
|
5
|
+
# easily styled.
|
6
|
+
#
|
7
|
+
# == Tag examples
|
8
|
+
#
|
9
|
+
# text_field_tag('name') # => <input class="text" id="name" name="name" type="text" />
|
10
|
+
# hidden_field_tag('name') # => <input class="hidden" id="name" name="name" type="hidden" />
|
11
|
+
# radio_button_tag('agree', 1) # => <input class="radio" id="agree_1" name="agree" type="radio" value="1" />
|
12
|
+
#
|
13
|
+
# == Form helper examples
|
14
|
+
#
|
15
|
+
# text_field(:person, :name) # => <input class="text" id="person_name" name="person[name]" size="30" type="text" />
|
16
|
+
# hidden_field(:person, :name) # => <input class="hidden" id="person_name" name="person[name]" type="hidden" />
|
17
|
+
# radio_button(:person, :agree, 1) # => <input class="radio" id="person_agree_1" name="person[agree]" type="radio" value="1" />
|
18
|
+
#
|
19
|
+
# == Merging options
|
20
|
+
#
|
21
|
+
# If you specify additional classes when creating a tag, the automated css
|
22
|
+
# classes will be prepended to the current ones. For example,
|
23
|
+
#
|
24
|
+
# text_field_tag('name', :class => 'selected') # => <input class="text selected" id="name" name="name" type="text" />
|
25
|
+
# text_field_tag('name', :class => 'selected shadow') # => <input class="text selected shadow" id="name" name="name" type="text" />
|
26
|
+
module StyledInputs
|
27
|
+
# Appends the input type to the value currently stored in the html options
|
28
|
+
# for the tag.
|
29
|
+
def styled_input(name, options = nil)
|
30
|
+
options = (options || {}).stringify_keys
|
31
|
+
|
32
|
+
if name.to_s == 'input' && options.include?('type')
|
33
|
+
options['class'] = (options['class'].to_s + " #{options['type']}").strip
|
36
34
|
end
|
35
|
+
|
36
|
+
options
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
ActionController::Base.class_eval do
|
41
|
-
helper
|
41
|
+
helper StyledInputs
|
42
42
|
end
|
43
43
|
|
44
44
|
ActionView::Helpers::InstanceTag.class_eval do
|
45
|
-
include
|
45
|
+
include StyledInputs
|
46
46
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class FormHelperTest < ActionView::TestCase
|
4
|
+
class Person
|
5
|
+
attr_accessor :name,
|
6
|
+
:agree,
|
7
|
+
:picture,
|
8
|
+
:secret
|
9
|
+
end
|
10
|
+
|
11
|
+
tests StyledInputs
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@person = Person.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_style_text_field
|
18
|
+
assert_equal '<input class="text" id="person_name" name="person[name]" size="30" type="text" />', text_field(:person, :name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_style_password_field
|
22
|
+
assert_equal '<input class="password" id="person_secret" name="person[secret]" size="30" type="password" />', password_field(:person, :secret)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_style_hidden_field
|
26
|
+
assert_equal '<input class="hidden" id="person_name" name="person[name]" type="hidden" />', hidden_field(:person, :name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_style_file_field
|
30
|
+
assert_equal '<input class="file" id="person_picture" name="person[picture]" size="30" type="file" />', file_field(:person, :picture)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_should_style_check_box
|
34
|
+
expected =
|
35
|
+
'<input class="checkbox" id="person_agree" name="person[agree]" type="checkbox" value="1" />' +
|
36
|
+
'<input class="hidden" name="person[agree]" type="hidden" value="0" />'
|
37
|
+
assert_equal expected, check_box(:person, :agree)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_style_radio_button
|
41
|
+
assert_equal '<input class="radio" id="person_agree_1" name="person[agree]" type="radio" value="1" />', radio_button(:person, :agree, 1)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class FormTagHelperTest < ActionView::TestCase
|
4
|
+
tests StyledInputs
|
5
|
+
|
6
|
+
def test_should_style_text_field_tag
|
7
|
+
assert_equal '<input class="text" id="name" name="name" type="text" />', text_field_tag('name')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_style_hidden_field_tag
|
11
|
+
assert_equal '<input class="hidden" id="name" name="name" type="hidden" />', hidden_field_tag('name')
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_style_file_field_tag
|
15
|
+
assert_equal '<input class="file" id="picture" name="picture" type="file" />', file_field_tag('picture')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_style_password_field_tag
|
19
|
+
assert_equal '<input class="password" id="secret" name="secret" type="password" />', password_field_tag('secret')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_style_check_box_tag
|
23
|
+
assert_equal '<input class="checkbox" id="agree" name="agree" type="checkbox" value="1" />', check_box_tag('agree')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_style_radio_button_tag
|
27
|
+
assert_equal '<input class="radio" id="agree_1" name="agree" type="radio" value="1" />', radio_button_tag('agree', 1)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_style_submit_tag
|
31
|
+
assert_equal '<input class="submit" name="commit" type="submit" value="Submit" />', submit_tag('Submit')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_style_image_submit_tag
|
35
|
+
assert_equal '<input class="image" src="button.png" type="image" />', image_submit_tag('button.png')
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def path_to_image(source)
|
40
|
+
source
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class StyledInputsTest < ActionView::TestCase
|
4
|
+
tests StyledInputs
|
5
|
+
|
6
|
+
def test_should_not_style_input_if_tag_is_not_input
|
7
|
+
expected = {}
|
8
|
+
assert_equal expected, styled_input('td', expected)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_not_style_input_if_correct_type_but_tag_is_not_input
|
12
|
+
expected = {'type' => 'text'}
|
13
|
+
assert_equal expected, styled_input('td', expected)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_style_input_if_tag_is_input
|
17
|
+
expected = {'type' => 'text', 'class' => 'text'}
|
18
|
+
assert_equal expected, styled_input('input', {'type' => 'text'})
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_style_input_if_tag_is_symbolic_input
|
22
|
+
expected = {'type' => 'text', 'class' => 'text'}
|
23
|
+
assert_equal expected, styled_input(:input, {'type' => 'text'})
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_not_style_input_if_tag_is_input_but_type_not_specified
|
27
|
+
expected = {}
|
28
|
+
assert_equal expected, styled_input('input', expected)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_append_style_if_class_is_already_populated
|
32
|
+
expected = {'type' => 'text', 'class' => 'selected text'}
|
33
|
+
assert_equal expected, styled_input('input', {'type' => 'text', 'class' => 'selected'})
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_style_general_tag_builder
|
37
|
+
assert_equal '<input class="text" type="text" />', tag('input', {'type' => 'text'})
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TagHelperTest < ActionView::TestCase
|
4
|
+
tests StyledInputs
|
5
|
+
|
6
|
+
def test_should_allow_no_options_to_be_specified
|
7
|
+
assert_equal '<br />', tag('br')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_allow_options_to_be_specified
|
11
|
+
assert_equal '<input class="text" disabled="disabled" type="text" />', tag('input', {:type => 'text', :disabled => true})
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_allow_open_to_be_specified
|
15
|
+
assert_equal '<br>', tag('br', nil, true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_allow_escape_to_be_specified
|
19
|
+
assert_equal '<img src="open & shut.png" />', tag('img', {:src => 'open & shut.png'}, false, false)
|
20
|
+
end
|
21
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
1
|
+
# Load the plugin testing framework
|
2
|
+
$:.unshift("#{File.dirname(__FILE__)}/../../plugin_test_helper/lib")
|
2
3
|
require 'rubygems'
|
3
|
-
require '
|
4
|
-
require 'action_view'
|
5
|
-
|
6
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
7
|
-
require File.dirname(__FILE__) + '/../init'
|
4
|
+
require 'plugin_test_helper'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: styled_inputs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-14 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,18 +22,22 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- lib/styled_inputs.rb
|
26
25
|
- lib/styled_inputs
|
27
26
|
- lib/styled_inputs/extensions
|
28
27
|
- lib/styled_inputs/extensions/tag_helper.rb
|
29
28
|
- lib/styled_inputs/extensions/instance_tag.rb
|
30
|
-
-
|
29
|
+
- lib/styled_inputs.rb
|
31
30
|
- test/test_helper.rb
|
32
|
-
-
|
31
|
+
- test/helpers
|
32
|
+
- test/helpers/tag_helper_test.rb
|
33
|
+
- test/helpers/styled_inputs_test.rb
|
34
|
+
- test/helpers/form_helper_test.rb
|
35
|
+
- test/helpers/form_tag_helper_test.rb
|
36
|
+
- CHANGELOG.rdoc
|
33
37
|
- init.rb
|
34
|
-
-
|
38
|
+
- LICENSE
|
35
39
|
- Rakefile
|
36
|
-
- README
|
40
|
+
- README.rdoc
|
37
41
|
has_rdoc: true
|
38
42
|
homepage: http://www.pluginaweek.org
|
39
43
|
post_install_message:
|
@@ -55,10 +59,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
59
|
version:
|
56
60
|
requirements: []
|
57
61
|
|
58
|
-
rubyforge_project:
|
59
|
-
rubygems_version: 1.
|
62
|
+
rubyforge_project: pluginaweek
|
63
|
+
rubygems_version: 1.2.0
|
60
64
|
signing_key:
|
61
65
|
specification_version: 2
|
62
66
|
summary: Adds automated styling of input fields with css classes
|
63
67
|
test_files:
|
64
|
-
- test/
|
68
|
+
- test/helpers/tag_helper_test.rb
|
69
|
+
- test/helpers/styled_inputs_test.rb
|
70
|
+
- test/helpers/form_helper_test.rb
|
71
|
+
- test/helpers/form_tag_helper_test.rb
|
data/CHANGELOG
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
*SVN*
|
2
|
-
|
3
|
-
*0.0.5* (June 22nd, 2008)
|
4
|
-
|
5
|
-
* Remove log files from gems
|
6
|
-
|
7
|
-
*0.0.4* (June 3rd, 2008)
|
8
|
-
|
9
|
-
* Add support for Rails 2.0+
|
10
|
-
|
11
|
-
*0.0.3* (June 1st, 2008)
|
12
|
-
|
13
|
-
* Remove dependency on set_or_append
|
14
|
-
|
15
|
-
*0.0.2* (May 5th, 2008)
|
16
|
-
|
17
|
-
* Updated documentation
|
18
|
-
|
19
|
-
*0.0.1* (August 17th, 2007)
|
20
|
-
|
21
|
-
* Add documentation
|
22
|
-
|
23
|
-
* Convert dos newlines to unix newlines
|
data/test/styled_inputs_test.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class StyledInputsTest < Test::Unit::TestCase
|
4
|
-
include PluginAWeek::StyledInputs
|
5
|
-
include ActionView::Helpers::TagHelper
|
6
|
-
|
7
|
-
def test_should_not_style_input_if_tag_is_not_input
|
8
|
-
expected = {}
|
9
|
-
assert_equal expected, styled_input('td', expected)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_should_not_style_input_if_correct_type_but_tag_is_not_input
|
13
|
-
expected = {'type' => 'text'}
|
14
|
-
assert_equal expected, styled_input('td', expected)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_should_style_input_if_tag_is_input
|
18
|
-
expected = {'type' => 'text', 'class' => 'text'}
|
19
|
-
assert_equal expected, styled_input('input', {'type' => 'text'})
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_should_style_input_if_tag_is_symbolic_input
|
23
|
-
expected = {'type' => 'text', 'class' => 'text'}
|
24
|
-
assert_equal expected, styled_input(:input, {'type' => 'text'})
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_should_not_style_input_if_tag_is_input_but_type_not_specified
|
28
|
-
expected = {}
|
29
|
-
assert_equal expected, styled_input('input', expected)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_should_append_style_if_class_is_already_populated
|
33
|
-
expected = {'type' => 'text', 'class' => 'selected text'}
|
34
|
-
assert_equal expected, styled_input('input', {'type' => 'text', 'class' => 'selected'})
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_should_style_general_tag_builder
|
38
|
-
assert_equal '<input class="text" type="text" />', tag('input', {'type' => 'text'})
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class FormTagHelperTest < Test::Unit::TestCase
|
43
|
-
include PluginAWeek::StyledInputs
|
44
|
-
include ActionView::Helpers::TagHelper
|
45
|
-
include ActionView::Helpers::FormTagHelper
|
46
|
-
include ActionView::Helpers::FormHelper
|
47
|
-
|
48
|
-
def test_should_style_text_field_tag
|
49
|
-
assert_equal '<input class="text" id="name" name="name" type="text" />', text_field_tag('name')
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_should_style_hidden_field_tag
|
53
|
-
assert_equal '<input class="hidden" id="name" name="name" type="hidden" />', hidden_field_tag('name')
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_should_style_file_field_tag
|
57
|
-
assert_equal '<input class="file" id="picture" name="picture" type="file" />', file_field_tag('picture')
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_should_style_password_field_tag
|
61
|
-
assert_equal '<input class="password" id="secret" name="secret" type="password" />', password_field_tag('secret')
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_should_style_check_box_tag
|
65
|
-
assert_equal '<input class="checkbox" id="agree" name="agree" type="checkbox" value="1" />', check_box_tag('agree')
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_should_style_radio_button_tag
|
69
|
-
assert_equal '<input class="radio" id="agree_1" name="agree" type="radio" value="1" />', radio_button_tag('agree', 1)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_should_style_submit_tag
|
73
|
-
assert_equal '<input class="submit" name="commit" type="submit" value="Submit" />', submit_tag('Submit')
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_should_style_image_submit_tag
|
77
|
-
assert_equal '<input class="image" src="button.png" type="image" />', image_submit_tag('button.png')
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
def path_to_image(source)
|
82
|
-
source
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
class FormHelperTest < Test::Unit::TestCase
|
87
|
-
class Person
|
88
|
-
attr_accessor :name,
|
89
|
-
:agree,
|
90
|
-
:picture,
|
91
|
-
:secret
|
92
|
-
end
|
93
|
-
|
94
|
-
include PluginAWeek::StyledInputs
|
95
|
-
include ActionView::Helpers::TagHelper
|
96
|
-
include ActionView::Helpers::FormTagHelper
|
97
|
-
include ActionView::Helpers::FormHelper
|
98
|
-
|
99
|
-
def setup
|
100
|
-
@person = Person.new
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_should_style_text_field
|
104
|
-
assert_equal '<input class="text" id="person_name" name="person[name]" size="30" type="text" />', text_field(:person, :name)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_should_style_password_field
|
108
|
-
assert_equal '<input class="password" id="person_secret" name="person[secret]" size="30" type="password" />', password_field(:person, :secret)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_should_style_hidden_field
|
112
|
-
assert_equal '<input class="hidden" id="person_name" name="person[name]" type="hidden" />', hidden_field(:person, :name)
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_should_style_file_field
|
116
|
-
assert_equal '<input class="file" id="person_picture" name="person[picture]" size="30" type="file" />', file_field(:person, :picture)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_should_style_check_box
|
120
|
-
expected =
|
121
|
-
'<input class="checkbox" id="person_agree" name="person[agree]" type="checkbox" value="1" />' +
|
122
|
-
'<input class="hidden" name="person[agree]" type="hidden" value="0" />'
|
123
|
-
assert_equal expected, check_box(:person, :agree)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_should_style_radio_button
|
127
|
-
assert_equal '<input class="radio" id="person_agree_1" name="person[agree]" type="radio" value="1" />', radio_button(:person, :agree, 1)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class TagHelperTest < Test::Unit::TestCase
|
132
|
-
include PluginAWeek::StyledInputs
|
133
|
-
include ActionView::Helpers::TagHelper
|
134
|
-
|
135
|
-
def test_should_allow_no_options_to_be_specified
|
136
|
-
assert_equal '<br />', tag('br')
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_should_allow_options_to_be_specified
|
140
|
-
assert_equal '<input class="text" disabled="disabled" type="text" />', tag('input', {:type => 'text', :disabled => true})
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_should_allow_open_to_be_specified
|
144
|
-
assert_equal '<br>', tag('br', nil, true)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_should_allow_escape_to_be_specified
|
148
|
-
assert_equal '<img src="open & shut.png" />', tag('img', {:src => 'open & shut.png'}, false, false)
|
149
|
-
end
|
150
|
-
end
|