ice 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +18 -0
- data/{LICENSE → MIT-LICENSE} +1 -1
- data/README.markdown +49 -77
- data/Rakefile +21 -34
- data/lib/ice.rb +8 -4
- data/lib/ice/base_cube.rb +32 -2
- data/lib/ice/cube_helpers.rb +29 -0
- data/lib/ice/cubeable.rb +12 -12
- data/lib/ice/eco_template/base.rb +17 -0
- data/lib/ice/eco_template/context.rb +76 -0
- data/lib/ice/eco_template/handler.rb +30 -0
- data/lib/ice/railtie.rb +6 -10
- metadata +22 -79
- data/.gitignore +0 -23
- data/.specification +0 -135
- data/VERSION +0 -1
- data/ice.gemspec +0 -87
- data/ice_js/History.md +0 -5
- data/ice_js/Readme.md +0 -29
- data/ice_js/lib/form_tag_inputs.js +0 -91
- data/ice_js/lib/path_helper.js +0 -49
- data/ice_js/spec/commands/example_command.rb +0 -19
- data/ice_js/spec/dom.html +0 -23
- data/ice_js/spec/node.js +0 -10
- data/ice_js/spec/rhino.js +0 -10
- data/ice_js/spec/server.html +0 -18
- data/ice_js/spec/server.rb +0 -4
- data/ice_js/spec/support/js.jar +0 -0
- data/ice_js/spec/unit/spec.helper.js +0 -0
- data/ice_js/spec/unit/spec.js +0 -180
- data/init.rb +0 -6
- data/lib/extras/ice_view.rb +0 -166
- data/lib/ice/base.rb +0 -50
- data/lib/parser.js +0 -320
- data/spec/base_cube_spec.rb +0 -45
- data/spec/cube_spec.rb +0 -119
- data/spec/ice_spec.rb +0 -97
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -12
- data/togo +0 -60
@@ -0,0 +1,76 @@
|
|
1
|
+
module Ice
|
2
|
+
module EcoTemplate
|
3
|
+
class Context < Hash
|
4
|
+
|
5
|
+
def initialize(hash)
|
6
|
+
add_routes
|
7
|
+
add_links
|
8
|
+
add_nav_bar
|
9
|
+
hash.each_pair do |key, value|
|
10
|
+
self[key] = value.to_ice
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def add_routes
|
17
|
+
Ice::BaseCube.subclasses.map(&:name).each do |cube_model_name|
|
18
|
+
model_name = cube_model_name.sub(/Cube/, "")
|
19
|
+
name = model_name[0].downcase + model_name[1..-1]
|
20
|
+
|
21
|
+
self["edit" + model_name + "Path"]= lambda do |object|
|
22
|
+
"/#{name.tableize}/#{object.id}/edit"
|
23
|
+
end
|
24
|
+
|
25
|
+
self["new" + model_name + "Path"]= lambda do
|
26
|
+
"/#{name.tableize}/new"
|
27
|
+
end
|
28
|
+
|
29
|
+
self[name + "Path"]= lambda do |object|
|
30
|
+
"/#{name.tableize}/#{object.id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
self[name.pluralize + "Path"]= lambda do
|
34
|
+
"/#{name.tableize}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_links
|
41
|
+
self["linkTo"] = lambda do |label, link|
|
42
|
+
if (!link)
|
43
|
+
link = label
|
44
|
+
end
|
45
|
+
%{<a href="#{link}">#{label}</a>}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def try_config(opts, var, config_class)
|
50
|
+
opts.first.try(var) ||
|
51
|
+
config_class.try(:[], var)
|
52
|
+
end
|
53
|
+
|
54
|
+
def try_nav_config(opts, sym)
|
55
|
+
try_config opts, sym, NavBarConfig
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_nav_bar
|
59
|
+
|
60
|
+
|
61
|
+
self["navBar"] = lambda do |*opts, yield_func|
|
62
|
+
nav_prefix = try_nav_config(opts, :nav_prefix) || '<ul class="linkBar">'
|
63
|
+
nav_postfix = try_nav_config(opts, :nav_postfix) || '</ul>'
|
64
|
+
link_prefix = try_nav_config(opts, :link_prefix) || '<li>'
|
65
|
+
link_postfix = try_nav_config(opts, :link_postfix) || '</li>'
|
66
|
+
ctx = {}
|
67
|
+
ctx['linkTo'] = lambda do |label, link = nil|
|
68
|
+
"#{link_prefix}#{self["linkTo"].call label, link}#{link_postfix}"
|
69
|
+
end
|
70
|
+
body = yield_func.call(ctx)
|
71
|
+
%{#{nav_prefix}#{body}#{nav_postfix}}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "ice/eco_template/base"
|
2
|
+
|
3
|
+
module Ice
|
4
|
+
module EcoTemplate
|
5
|
+
class Handler < ActionView::Template::Handler
|
6
|
+
|
7
|
+
include ActionView::Template::Handlers::Compilable
|
8
|
+
|
9
|
+
self.default_format = :eco
|
10
|
+
|
11
|
+
def compile(template)
|
12
|
+
<<-ECO
|
13
|
+
template_source = <<-ECO_TEMPLATE
|
14
|
+
#{template.source}
|
15
|
+
ECO_TEMPLATE
|
16
|
+
variables = {}
|
17
|
+
variable_names = controller.instance_variable_names
|
18
|
+
variable_names -= %w[@template]
|
19
|
+
if controller.respond_to?(:protected_instance_variables)
|
20
|
+
variable_names -= controller.protected_instance_variables
|
21
|
+
end
|
22
|
+
variable_names.each do |name|
|
23
|
+
variables[name.sub(/^@/, "")] = controller.instance_variable_get(name)
|
24
|
+
end
|
25
|
+
Ice::EcoTemplate.convert_template(template_source, variables.merge(local_assigns))
|
26
|
+
ECO
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/ice/railtie.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
+
require 'active_model/serialization'
|
2
|
+
require 'action_view'
|
3
|
+
|
1
4
|
module Ice
|
2
5
|
class Railtie < Rails::Railtie
|
3
6
|
initializer "ice.configure_rails_initialization" do
|
4
|
-
|
7
|
+
|
5
8
|
end
|
6
9
|
end
|
7
|
-
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
require 'extras/ice_view'
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
ActionView::Template
|
15
|
-
else
|
16
|
-
ActionView::Base
|
17
|
-
end.register_template_handler(:ice, IceView)
|
13
|
+
ActiveModel::Serialization.send(:include, Ice::Cubeable)
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
version: 0.3.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Nate Kidwell
|
@@ -14,23 +10,19 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2010-10-04 00:00:00 -
|
13
|
+
date: 2010-10-04 00:00:00 -04:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
17
|
+
name: eco
|
22
18
|
prerelease: false
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
20
|
none: false
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
- 2
|
31
|
-
- 9
|
32
|
-
version: 1.2.9
|
33
|
-
type: :development
|
24
|
+
version: 1.0.0
|
25
|
+
type: :runtime
|
34
26
|
version_requirements: *id001
|
35
27
|
- !ruby/object:Gem::Dependency
|
36
28
|
name: therubyracer
|
@@ -38,75 +30,33 @@ dependencies:
|
|
38
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
31
|
none: false
|
40
32
|
requirements:
|
41
|
-
- - "
|
33
|
+
- - ">="
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
- 0
|
45
|
-
- 7
|
46
|
-
- 5
|
47
|
-
version: 0.7.5
|
35
|
+
version: 0.8.2
|
48
36
|
type: :runtime
|
49
37
|
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rails
|
52
|
-
prerelease: false
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - "="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 3
|
60
|
-
- 0
|
61
|
-
- 0
|
62
|
-
version: 3.0.0
|
63
|
-
type: :runtime
|
64
|
-
version_requirements: *id003
|
65
38
|
description: User templates written in javascript
|
66
39
|
email: nate@ludicast.com
|
67
40
|
executables: []
|
68
41
|
|
69
42
|
extensions: []
|
70
43
|
|
71
|
-
extra_rdoc_files:
|
72
|
-
|
73
|
-
- README.markdown
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
74
46
|
files:
|
75
|
-
- .gitignore
|
76
|
-
- .specification
|
77
|
-
- LICENSE
|
78
|
-
- README.markdown
|
79
|
-
- Rakefile
|
80
|
-
- VERSION
|
81
|
-
- ice.gemspec
|
82
|
-
- ice_js/History.md
|
83
|
-
- ice_js/Readme.md
|
84
|
-
- ice_js/lib/form_tag_inputs.js
|
85
|
-
- ice_js/lib/path_helper.js
|
86
|
-
- ice_js/spec/commands/example_command.rb
|
87
|
-
- ice_js/spec/dom.html
|
88
|
-
- ice_js/spec/node.js
|
89
|
-
- ice_js/spec/rhino.js
|
90
|
-
- ice_js/spec/server.html
|
91
|
-
- ice_js/spec/server.rb
|
92
|
-
- ice_js/spec/support/js.jar
|
93
|
-
- ice_js/spec/unit/spec.helper.js
|
94
|
-
- ice_js/spec/unit/spec.js
|
95
|
-
- init.rb
|
96
|
-
- lib/extras/ice_view.rb
|
97
|
-
- lib/ice.rb
|
98
|
-
- lib/ice/base.rb
|
99
47
|
- lib/ice/base_cube.rb
|
100
48
|
- lib/ice/cube_association.rb
|
49
|
+
- lib/ice/cube_helpers.rb
|
101
50
|
- lib/ice/cubeable.rb
|
51
|
+
- lib/ice/eco_template/base.rb
|
52
|
+
- lib/ice/eco_template/context.rb
|
53
|
+
- lib/ice/eco_template/handler.rb
|
102
54
|
- lib/ice/railtie.rb
|
103
|
-
- lib/
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
- spec/spec_helper.rb
|
109
|
-
- togo
|
55
|
+
- lib/ice.rb
|
56
|
+
- MIT-LICENSE
|
57
|
+
- Rakefile
|
58
|
+
- Gemfile
|
59
|
+
- README.markdown
|
110
60
|
has_rdoc: true
|
111
61
|
homepage: http://github.com/ludicast/ice
|
112
62
|
licenses: []
|
@@ -121,26 +71,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
71
|
requirements:
|
122
72
|
- - ">="
|
123
73
|
- !ruby/object:Gem::Version
|
124
|
-
segments:
|
125
|
-
- 0
|
126
74
|
version: "0"
|
127
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
76
|
none: false
|
129
77
|
requirements:
|
130
78
|
- - ">="
|
131
79
|
- !ruby/object:Gem::Version
|
132
|
-
segments:
|
133
|
-
- 0
|
134
80
|
version: "0"
|
135
81
|
requirements: []
|
136
82
|
|
137
83
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.5.0
|
139
85
|
signing_key:
|
140
86
|
specification_version: 3
|
141
87
|
summary: User templates written in javascript
|
142
|
-
test_files:
|
143
|
-
|
144
|
-
- spec/cube_spec.rb
|
145
|
-
- spec/ice_spec.rb
|
146
|
-
- spec/spec_helper.rb
|
88
|
+
test_files: []
|
89
|
+
|
data/.gitignore
DELETED
data/.specification
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
name: ice
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
prerelease: false
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
version: 0.1.3
|
10
|
-
platform: ruby
|
11
|
-
authors:
|
12
|
-
- Nate Kidwell
|
13
|
-
autorequire:
|
14
|
-
bindir: bin
|
15
|
-
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-05-31 00:00:00 -04:00
|
18
|
-
default_executable:
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: rspec
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 2
|
30
|
-
- 9
|
31
|
-
version: 1.2.9
|
32
|
-
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: therubyracer
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 7
|
44
|
-
- 0
|
45
|
-
version: 0.7.0
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: activesupport
|
50
|
-
prerelease: false
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 2
|
57
|
-
- 2
|
58
|
-
- 0
|
59
|
-
version: 2.2.0
|
60
|
-
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
description: User templates written in javascript
|
63
|
-
email: nate@ludicast.com
|
64
|
-
executables: []
|
65
|
-
|
66
|
-
extensions: []
|
67
|
-
|
68
|
-
extra_rdoc_files:
|
69
|
-
- LICENSE
|
70
|
-
- README.markdown
|
71
|
-
files:
|
72
|
-
- .gitignore
|
73
|
-
- LICENSE
|
74
|
-
- README.markdown
|
75
|
-
- Rakefile
|
76
|
-
- VERSION
|
77
|
-
- ice.gemspec
|
78
|
-
- ice_js/History.md
|
79
|
-
- ice_js/Readme.md
|
80
|
-
- ice_js/lib/path_helper.js
|
81
|
-
- ice_js/spec/commands/example_command.rb
|
82
|
-
- ice_js/spec/dom.html
|
83
|
-
- ice_js/spec/node.js
|
84
|
-
- ice_js/spec/rhino.js
|
85
|
-
- ice_js/spec/server.html
|
86
|
-
- ice_js/spec/server.rb
|
87
|
-
- ice_js/spec/unit/spec.helper.js
|
88
|
-
- ice_js/spec/unit/spec.js
|
89
|
-
- init.rb
|
90
|
-
- lib/ice.rb
|
91
|
-
- lib/ice/base_cube.rb
|
92
|
-
- lib/ice/cube_association.rb
|
93
|
-
- lib/ice/cubeable.rb
|
94
|
-
- lib/parser.js
|
95
|
-
- spec/base_cube_spec.rb
|
96
|
-
- spec/cube_spec.rb
|
97
|
-
- spec/ice_spec.rb
|
98
|
-
- spec/spec.opts
|
99
|
-
- spec/spec_helper.rb
|
100
|
-
has_rdoc: true
|
101
|
-
homepage: http://github.com/ludicast/ice
|
102
|
-
licenses: []
|
103
|
-
|
104
|
-
post_install_message:
|
105
|
-
rdoc_options:
|
106
|
-
- --charset=UTF-8
|
107
|
-
require_paths:
|
108
|
-
- lib
|
109
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
requirements:
|
111
|
-
- - ">="
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
|
-
version: "0"
|
116
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
-
requirements:
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
version: "0"
|
123
|
-
requirements: []
|
124
|
-
|
125
|
-
rubyforge_project:
|
126
|
-
rubygems_version: 1.3.6
|
127
|
-
signing_key:
|
128
|
-
specification_version: 3
|
129
|
-
summary: User templates written in javascript
|
130
|
-
test_files:
|
131
|
-
- spec/base_cube_spec.rb
|
132
|
-
- spec/cube_spec.rb
|
133
|
-
- spec/ice_spec.rb
|
134
|
-
- spec/spec_helper.rb
|
135
|
-
|