check_tag 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +9 -0
- data/check_tag.gemspec +7 -1
- data/lib/check_tag/version.rb +1 -1
- data/lib/check_tag.rb +2 -35
- data/spec/check_tag_spec.rb +76 -0
- data/spec/fixtures/application.rb +25 -0
- data/spec/fixtures/controllers.rb +5 -0
- metadata +94 -6
data/.gitignore
CHANGED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2@check_tag --create
|
data/.travis.yml
ADDED
data/check_tag.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Dan Bickford"]
|
6
6
|
gem.email = ["danbickford007@yahoo.com"]
|
7
7
|
gem.description = %q{Check box tag that submits value whether checked or unchecked}
|
8
|
-
gem.summary = %q{Form helper check box tag that will submit a value whether the box is checked or not. Call
|
8
|
+
gem.summary = %q{Form helper check box tag that will submit a value whether the box is checked or not. Call chech_tag('id', 'checked value', 'unchecked value', 'default value') and your checkbox will be created. It will submit your values according whether checked or not.}
|
9
9
|
gem.homepage = ""
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
@@ -14,4 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "check_tag"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = CheckTag::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec"
|
19
|
+
gem.add_development_dependency "rspec-rails"
|
20
|
+
gem.add_development_dependency "actionpack"
|
21
|
+
gem.add_development_dependency "activesupport"
|
22
|
+
gem.add_development_dependency "rails"
|
17
23
|
end
|
data/lib/check_tag/version.rb
CHANGED
data/lib/check_tag.rb
CHANGED
@@ -5,40 +5,7 @@ ActiveSupport.on_load(:action_view) do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module CheckTag
|
8
|
-
|
9
|
-
|
10
|
-
begin
|
11
|
-
@id = id
|
12
|
-
@check = check
|
13
|
-
@uncheck = uncheck
|
14
|
-
@defaulted = defaulted
|
15
|
-
defaults
|
16
|
-
string_now
|
17
|
-
hidden_tag = hidden_field_tag(@id, @uncheck)
|
18
|
-
return_objects = check_box_tag(@id, @check, (@defaulted == @check ? true : false))
|
19
|
-
return hidden_tag + " " + return_objects
|
20
|
-
rescue Exception => exc
|
21
|
-
puts "CHECK TAG ERROR.........#{exc}"
|
22
|
-
end
|
8
|
+
def check_tag(id, check=true, uncheck=false, defaulted=false)
|
9
|
+
hidden_field_tag(id, uncheck) + check_box_tag(id, check, defaulted)
|
23
10
|
end
|
24
|
-
|
25
|
-
def defaults
|
26
|
-
if !@check
|
27
|
-
@check = 'true'
|
28
|
-
end
|
29
|
-
if !@uncheck
|
30
|
-
@uncheck = 'false'
|
31
|
-
end
|
32
|
-
if !@defaulted
|
33
|
-
@defaulted = @uncheck
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def string_now
|
38
|
-
@id = @id.to_s
|
39
|
-
@check = @check.to_s
|
40
|
-
@uncheck = @uncheck.to_s
|
41
|
-
@defaulted = @defaulted.to_s
|
42
|
-
end
|
43
|
-
|
44
11
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require_relative "../lib/check_tag"
|
3
|
+
require 'fixtures/application'
|
4
|
+
require 'rspec/rails'
|
5
|
+
include CheckTag
|
6
|
+
include ActionView::Helpers
|
7
|
+
|
8
|
+
describe CheckTag do
|
9
|
+
describe "#check_tag" do
|
10
|
+
context "new check tag with only the id" do
|
11
|
+
let(:ct) { check_tag("my_id") }
|
12
|
+
|
13
|
+
it "returns a hidden tag set to false" do
|
14
|
+
ct.should include('<input id="my_id" name="my_id" type="hidden" value="false" />')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns a check tag set to true" do
|
18
|
+
ct.should include('<input id="my_id" name="my_id" type="checkbox" value="true" />')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
context "check tag with check set to true" do
|
24
|
+
let(:ct) { check_tag("my_id", 'true') }
|
25
|
+
|
26
|
+
it "returns a hidden tag set to false" do
|
27
|
+
ct.should include('<input id="my_id" name="my_id" type="hidden" value="false" />')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns a check tag set to true" do
|
31
|
+
ct.should include('<input id="my_id" name="my_id" type="checkbox" value="true" />')
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "check tag with check set to false" do
|
37
|
+
let(:ct) { check_tag("my_id", 'false', 'true') }
|
38
|
+
|
39
|
+
it "returns a hidden tag set to false" do
|
40
|
+
ct.should include('<input id="my_id" name="my_id" type="hidden" value="true" />')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns a check tag set to false" do
|
44
|
+
ct.should include('<input id="my_id" name="my_id" type="checkbox" value="false" />')
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context "check tag with uncheck set to false" do
|
50
|
+
let(:ct) { check_tag("my_id", 'true', 'false') }
|
51
|
+
|
52
|
+
it "returns a hidden tag set to false" do
|
53
|
+
ct.should include('<input id="my_id" name="my_id" type="hidden" value="false" />')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns a check tag set to true" do
|
57
|
+
ct.should include('<input id="my_id" name="my_id" type="checkbox" value="true" />')
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context "check tag with defaulted set to true" do
|
63
|
+
let(:ct) { check_tag("my_id", 'true', 'false', 'true') }
|
64
|
+
|
65
|
+
it "returns a hidden tag set to false" do
|
66
|
+
ct.should include('<input id="my_id" name="my_id" type="hidden" value="false" />')
|
67
|
+
end
|
68
|
+
|
69
|
+
it "returns a check tag set to true" do
|
70
|
+
ct.should include('<input checked="checked" id="my_id" name="my_id" type="checkbox" value="true" />')
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'action_dispatch'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
class App
|
7
|
+
def env_config; {} end
|
8
|
+
def routes
|
9
|
+
return @routes if defined?(@routes)
|
10
|
+
@routes = ActionDispatch::Routing::RouteSet.new
|
11
|
+
@routes.draw do
|
12
|
+
resources :posts # Replace with your own needs
|
13
|
+
end
|
14
|
+
@routes
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.application
|
19
|
+
@app ||= App.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.version
|
23
|
+
'3.0.7'
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,88 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: actionpack
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: activesupport
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
14
94
|
description: Check box tag that submits value whether checked or unchecked
|
15
95
|
email:
|
16
96
|
- danbickford007@yahoo.com
|
@@ -19,6 +99,8 @@ extensions: []
|
|
19
99
|
extra_rdoc_files: []
|
20
100
|
files:
|
21
101
|
- .gitignore
|
102
|
+
- .rvmrc
|
103
|
+
- .travis.yml
|
22
104
|
- Gemfile
|
23
105
|
- LICENSE
|
24
106
|
- README.md
|
@@ -26,6 +108,9 @@ files:
|
|
26
108
|
- check_tag.gemspec
|
27
109
|
- lib/check_tag.rb
|
28
110
|
- lib/check_tag/version.rb
|
111
|
+
- spec/check_tag_spec.rb
|
112
|
+
- spec/fixtures/application.rb
|
113
|
+
- spec/fixtures/controllers.rb
|
29
114
|
homepage: ''
|
30
115
|
licenses: []
|
31
116
|
post_install_message:
|
@@ -46,11 +131,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
131
|
version: '0'
|
47
132
|
requirements: []
|
48
133
|
rubyforge_project:
|
49
|
-
rubygems_version: 1.8.
|
134
|
+
rubygems_version: 1.8.25
|
50
135
|
signing_key:
|
51
136
|
specification_version: 3
|
52
137
|
summary: Form helper check box tag that will submit a value whether the box is checked
|
53
|
-
or not. Call
|
138
|
+
or not. Call chech_tag('id', 'checked value', 'unchecked value', 'default value')
|
54
139
|
and your checkbox will be created. It will submit your values according whether
|
55
140
|
checked or not.
|
56
|
-
test_files:
|
141
|
+
test_files:
|
142
|
+
- spec/check_tag_spec.rb
|
143
|
+
- spec/fixtures/application.rb
|
144
|
+
- spec/fixtures/controllers.rb
|