ice 0.2.3 → 0.2.4
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.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ice.gemspec +7 -6
- data/ice_js/lib/form_tag_inputs.js +91 -0
- data/ice_js/spec/dom.html +1 -0
- data/ice_js/spec/unit/spec.js +80 -0
- metadata +19 -37
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/ludicast/ice"
|
12
12
|
gem.authors = ["Nate Kidwell"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "therubyracer", "0.7.
|
14
|
+
gem.add_dependency "therubyracer", "0.7.4"
|
15
15
|
gem.add_dependency "activesupport", ">= 2.2.0"
|
16
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/ice.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ice}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nate Kidwell"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-17}
|
13
13
|
s.description = %q{User templates written in javascript}
|
14
14
|
s.email = %q{nate@ludicast.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"ice.gemspec",
|
27
27
|
"ice_js/History.md",
|
28
28
|
"ice_js/Readme.md",
|
29
|
+
"ice_js/lib/form_tag_inputs.js",
|
29
30
|
"ice_js/lib/path_helper.js",
|
30
31
|
"ice_js/spec/commands/example_command.rb",
|
31
32
|
"ice_js/spec/dom.html",
|
@@ -54,7 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
s.homepage = %q{http://github.com/ludicast/ice}
|
55
56
|
s.rdoc_options = ["--charset=UTF-8"]
|
56
57
|
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.3.
|
58
|
+
s.rubygems_version = %q{1.3.5}
|
58
59
|
s.summary = %q{User templates written in javascript}
|
59
60
|
s.test_files = [
|
60
61
|
"spec/base_cube_spec.rb",
|
@@ -69,16 +70,16 @@ Gem::Specification.new do |s|
|
|
69
70
|
|
70
71
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
71
72
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
72
|
-
s.add_runtime_dependency(%q<therubyracer>, ["= 0.7.
|
73
|
+
s.add_runtime_dependency(%q<therubyracer>, ["= 0.7.4"])
|
73
74
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.0"])
|
74
75
|
else
|
75
76
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
76
|
-
s.add_dependency(%q<therubyracer>, ["= 0.7.
|
77
|
+
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
77
78
|
s.add_dependency(%q<activesupport>, [">= 2.2.0"])
|
78
79
|
end
|
79
80
|
else
|
80
81
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
81
|
-
s.add_dependency(%q<therubyracer>, ["= 0.7.
|
82
|
+
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
82
83
|
s.add_dependency(%q<activesupport>, [">= 2.2.0"])
|
83
84
|
end
|
84
85
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
function humanize(name) {
|
2
|
+
match = name.match(/(.*)_id$/)
|
3
|
+
if (match) {
|
4
|
+
name = match[1]
|
5
|
+
}
|
6
|
+
|
7
|
+
return name.split('_').join(' ')
|
8
|
+
}
|
9
|
+
|
10
|
+
function get_type_value(type, opts){
|
11
|
+
switch (type) {
|
12
|
+
case "disabled":
|
13
|
+
return opts[type] ? "disabled" : ""
|
14
|
+
case "checked":
|
15
|
+
return opts[type] ? "checked" : ""
|
16
|
+
}
|
17
|
+
return opts[type]
|
18
|
+
}
|
19
|
+
|
20
|
+
function get_attribute_string(type, opts) {
|
21
|
+
return (opts && opts[type] && type + "=\"" + get_type_value(type,opts) + "\" ") || ""
|
22
|
+
}
|
23
|
+
|
24
|
+
function get_size_string(opts) {
|
25
|
+
return get_attribute_string('size', opts)
|
26
|
+
}
|
27
|
+
|
28
|
+
function get_class_string(opts) {
|
29
|
+
return get_attribute_string('class', opts)
|
30
|
+
}
|
31
|
+
|
32
|
+
function get_disabled_string(opts) {
|
33
|
+
return get_attribute_string('disabled', opts)
|
34
|
+
}
|
35
|
+
|
36
|
+
function get_checked_string(opts) {
|
37
|
+
return get_attribute_string('checked', opts)
|
38
|
+
}
|
39
|
+
|
40
|
+
function get_maxlength_string(opts) {
|
41
|
+
return get_attribute_string('maxlength', opts)
|
42
|
+
}
|
43
|
+
|
44
|
+
function label_tag(name, opts) {
|
45
|
+
label = ((typeof opts == 'string') && opts) || humanize(name)
|
46
|
+
class_string = get_class_string(opts)
|
47
|
+
return "<label "+ class_string + "for=\"" + name + "\">" + label.charAt(0).toUpperCase() + label.substr(1) + "</label>"
|
48
|
+
}
|
49
|
+
|
50
|
+
var BaseInputTag = function(tag_type) {
|
51
|
+
this.tag_type = tag_type
|
52
|
+
}
|
53
|
+
|
54
|
+
BaseInputTag.prototype.render = function () {
|
55
|
+
return "<input "+ this.checked_string + this.disabled_string + this.class_string +"id=\"" + this.name +"\" " + this.maxlength_string + "name=\"" + this.name +"\" " + this.size_string + "type=\"" + this.tag_type + "\" " + this.value + "/>"
|
56
|
+
}
|
57
|
+
|
58
|
+
BaseInputTag.prototype.set_opts = function () {
|
59
|
+
this.class_string = get_class_string(opts)
|
60
|
+
this.size_string = get_size_string(opts)
|
61
|
+
this.disabled_string = get_disabled_string(opts)
|
62
|
+
this.maxlength_string = get_maxlength_string(opts)
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
function password_field_tag(name) {
|
67
|
+
tag = new BaseInputTag("password")
|
68
|
+
tag.name = name
|
69
|
+
tag.value = ((typeof arguments[1] == 'string') && "value=\"" + arguments[1] + "\" ") || ""
|
70
|
+
opts = arguments[2] || arguments[1]
|
71
|
+
|
72
|
+
|
73
|
+
tag.set_opts(opts)
|
74
|
+
tag.checked_string = ""
|
75
|
+
return tag.render()
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
function check_box_tag(name) {
|
80
|
+
tag = new BaseInputTag("checkbox")
|
81
|
+
tag.name = name
|
82
|
+
tag.value = "value=\"" + (((typeof arguments[1] == 'string') && arguments[1]) || 1) + "\" "
|
83
|
+
tag.checked_string = (arguments[2] === true) ? "checked=\"checked\" " : ""
|
84
|
+
|
85
|
+
opts = arguments[2] || arguments[1]
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
tag.set_opts(opts)
|
90
|
+
return tag.render()
|
91
|
+
}
|
data/ice_js/spec/dom.html
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
<script src="/Users/natekidwell/.rvm/gems/ruby-1.9.1-p378/gems/jspec-4.3.1/lib/jspec.js"></script>
|
5
5
|
<script src="/Users/natekidwell/.rvm/gems/ruby-1.9.1-p378/gems/jspec-4.3.1/lib/jspec.xhr.js"></script>
|
6
6
|
<script src="../lib/path_helper.js"></script>
|
7
|
+
<script src="../lib/form_tag_inputs.js"></script>
|
7
8
|
<script src="unit/spec.helper.js"></script>
|
8
9
|
<script>
|
9
10
|
function runSuites() {
|
data/ice_js/spec/unit/spec.js
CHANGED
@@ -98,3 +98,83 @@ describe "NavBar"
|
|
98
98
|
|
99
99
|
end
|
100
100
|
|
101
|
+
|
102
|
+
describe "Form Builder Tags"
|
103
|
+
describe "label_tag"
|
104
|
+
it "assigns default value"
|
105
|
+
tag = label_tag('name')
|
106
|
+
tag.should.eql '<label for="name">Name</label>'
|
107
|
+
end
|
108
|
+
it "assigns humanized default value"
|
109
|
+
tag = label_tag('supervising_boss_id')
|
110
|
+
tag.should.eql '<label for="supervising_boss_id">Supervising boss</label>'
|
111
|
+
end
|
112
|
+
it "allows alternative value"
|
113
|
+
tag = label_tag('name', 'Your Name')
|
114
|
+
tag.should.eql '<label for="name">Your Name</label>'
|
115
|
+
end
|
116
|
+
it "allows class to be assigned"
|
117
|
+
tag = label_tag('name', {'class':'small_label'})
|
118
|
+
tag.should.eql '<label class="small_label" for="name">Name</label>'
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "for password_field_tag"
|
124
|
+
it "should generate regular password tag"
|
125
|
+
tag = password_field_tag('pass')
|
126
|
+
tag.should.eql '<input id="pass" name="pass" type="password" />'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should have alternate value"
|
130
|
+
tag = password_field_tag('secret', 'Your secret here')
|
131
|
+
tag.should.eql '<input id="secret" name="secret" type="password" value="Your secret here" />'
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should take class"
|
135
|
+
tag = password_field_tag('masked', {'class':'masked_input_field'})
|
136
|
+
tag.should.eql '<input class="masked_input_field" id="masked" name="masked" type="password" />'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should take size"
|
140
|
+
tag = password_field_tag('token','', {size:15})
|
141
|
+
tag.should.eql '<input id="token" name="token" size="15" type="password" value="" />'
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should take maxlength"
|
145
|
+
tag = password_field_tag('key',{maxlength:16})
|
146
|
+
tag.should.eql '<input id="key" maxlength="16" name="key" type="password" />'
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
it "should take disabled option"
|
151
|
+
tag = password_field_tag('confirm_pass',{disabled:true})
|
152
|
+
tag.should.eql '<input disabled="disabled" id="confirm_pass" name="confirm_pass" type="password" />'
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should take multiple options"
|
156
|
+
tag = password_field_tag('pin','1234',{maxlength:4,size:6, 'class':'pin-input'})
|
157
|
+
tag.should.eql '<input class="pin-input" id="pin" maxlength="4" name="pin" size="6" type="password" value="1234" />'
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "for check_box_tag"
|
163
|
+
|
164
|
+
it "should generate basic checkbox"
|
165
|
+
tag = check_box_tag('accept')
|
166
|
+
tag.should.eql '<input id="accept" name="accept" type="checkbox" value="1" />'
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should take alternate values"
|
170
|
+
tag = check_box_tag('rock', 'rock music')
|
171
|
+
tag.should.eql '<input id="rock" name="rock" type="checkbox" value="rock music" />'
|
172
|
+
end
|
173
|
+
it "should take parameter for checked"
|
174
|
+
tag = check_box_tag('receive_email', 'yes', true)
|
175
|
+
tag.should.eql '<input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" />'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
version: 0.2.3
|
4
|
+
version: 0.2.4
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Nate Kidwell
|
@@ -14,51 +9,39 @@ autorequire:
|
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
11
|
|
17
|
-
date: 2010-06-
|
12
|
+
date: 2010-06-17 00:00:00 -04:00
|
18
13
|
default_executable:
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: rspec
|
22
|
-
|
23
|
-
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 2
|
30
|
-
- 9
|
31
23
|
version: 1.2.9
|
32
|
-
|
33
|
-
version_requirements: *id001
|
24
|
+
version:
|
34
25
|
- !ruby/object:Gem::Dependency
|
35
26
|
name: therubyracer
|
36
|
-
|
37
|
-
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
30
|
requirements:
|
39
31
|
- - "="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
- 7
|
44
|
-
- 1
|
45
|
-
version: 0.7.1
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
33
|
+
version: 0.7.4
|
34
|
+
version:
|
48
35
|
- !ruby/object:Gem::Dependency
|
49
36
|
name: activesupport
|
50
|
-
|
51
|
-
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
40
|
requirements:
|
53
41
|
- - ">="
|
54
42
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 2
|
57
|
-
- 2
|
58
|
-
- 0
|
59
43
|
version: 2.2.0
|
60
|
-
|
61
|
-
version_requirements: *id003
|
44
|
+
version:
|
62
45
|
description: User templates written in javascript
|
63
46
|
email: nate@ludicast.com
|
64
47
|
executables: []
|
@@ -78,6 +61,7 @@ files:
|
|
78
61
|
- ice.gemspec
|
79
62
|
- ice_js/History.md
|
80
63
|
- ice_js/Readme.md
|
64
|
+
- ice_js/lib/form_tag_inputs.js
|
81
65
|
- ice_js/lib/path_helper.js
|
82
66
|
- ice_js/spec/commands/example_command.rb
|
83
67
|
- ice_js/spec/dom.html
|
@@ -115,20 +99,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
99
|
requirements:
|
116
100
|
- - ">="
|
117
101
|
- !ruby/object:Gem::Version
|
118
|
-
segments:
|
119
|
-
- 0
|
120
102
|
version: "0"
|
103
|
+
version:
|
121
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
105
|
requirements:
|
123
106
|
- - ">="
|
124
107
|
- !ruby/object:Gem::Version
|
125
|
-
segments:
|
126
|
-
- 0
|
127
108
|
version: "0"
|
109
|
+
version:
|
128
110
|
requirements: []
|
129
111
|
|
130
112
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.3.
|
113
|
+
rubygems_version: 1.3.5
|
132
114
|
signing_key:
|
133
115
|
specification_version: 3
|
134
116
|
summary: User templates written in javascript
|