ice 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,135 @@
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
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ice}
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
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"]
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".gitignore",
21
+ ".specification",
21
22
  "LICENSE",
22
23
  "README.markdown",
23
24
  "Rakefile",
@@ -35,11 +36,13 @@ Gem::Specification.new do |s|
35
36
  "ice_js/spec/unit/spec.helper.js",
36
37
  "ice_js/spec/unit/spec.js",
37
38
  "init.rb",
39
+ "lib/extras/ice_view.rb",
38
40
  "lib/ice.rb",
39
41
  "lib/ice/base_cube.rb",
40
42
  "lib/ice/cube_association.rb",
41
43
  "lib/ice/cubeable.rb",
42
44
  "lib/parser.js",
45
+ "rails/init.rb",
43
46
  "spec/base_cube_spec.rb",
44
47
  "spec/cube_spec.rb",
45
48
  "spec/ice_spec.rb",
data/init.rb CHANGED
@@ -1 +1,4 @@
1
- ActiveRecord::Base.send(:include, Ice::Cubeable)
1
+ require 'ice'
2
+ require 'ice/cubeable'
3
+ require 'ice/cube_association'
4
+ require 'ice/base_cube'
@@ -0,0 +1,53 @@
1
+ # IceView is a action view extension class. You can register it with rails
2
+ # and use ice as an template system for .ice files
3
+ #
4
+ # Example
5
+ #
6
+ # ActionView::Base::register_template_handler :ice, IceView
7
+ class IceView
8
+ PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
9
+ _response url _request _cookies variables_added _flash params _headers request cookies
10
+ ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
11
+ PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
12
+ @helpers @assigns_added @template @_render_stack @template_format @assigns )
13
+
14
+ def self.call(template)
15
+ "IceView.new(self).render(template, local_assigns)"
16
+ end
17
+
18
+ def initialize(view)
19
+ @view = view
20
+ end
21
+
22
+ def render(template, local_assigns = nil)
23
+ @view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
24
+
25
+
26
+
27
+ # Rails 2.2 Template has source, but not locals
28
+ if template.respond_to?(:source) && !template.respond_to?(:locals)
29
+ assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
30
+ hash[ivar[1..-1]] = @view.instance_variable_get(ivar)
31
+ hash
32
+ end
33
+ else
34
+ assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
35
+ end
36
+
37
+ source = template.respond_to?(:source) ? template.source : template
38
+ local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
39
+
40
+ if content_for_layout = @view.instance_variable_get("@content_for_layout")
41
+ assigns['content_for_layout'] = content_for_layout
42
+ end
43
+ assigns.merge!(local_assigns.stringify_keys)
44
+ Ice.convert_template(source, assigns)
45
+ #ice = Ice::Template.parse(source)
46
+ #ice.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
47
+ end
48
+
49
+ def compilable?
50
+ false
51
+ end
52
+
53
+ end
@@ -1,22 +1,23 @@
1
- class BaseCube
1
+ module Ice
2
+ class BaseCube
2
3
 
3
- def self.revealing(* attributes)
4
- attributes.each do |attr|
4
+ def self.revealing(* attributes)
5
+ attributes.each do |attr|
5
6
 
6
- define_method attr.to_sym do
7
- @source.send(attr).to_ice
7
+ define_method attr.to_sym do
8
+ @source.send(attr).to_ice
9
+ end
8
10
  end
9
11
  end
10
- end
11
12
 
12
- attr_reader :source
13
+ attr_reader :source
13
14
 
14
- def to_ice
15
- self
16
- end
15
+ def to_ice
16
+ self
17
+ end
17
18
 
18
- def initialize(source)
19
- @source = source
19
+ def initialize(source)
20
+ @source = source
21
+ end
20
22
  end
21
-
22
23
  end
@@ -0,0 +1,10 @@
1
+ ActiveRecord::Base.send(:include, Ice::Cubeable)
2
+
3
+ require File.dirname(__FILE__) + "/../init"
4
+ require 'extras/ice_view'
5
+
6
+ if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
7
+ ActionView::Template
8
+ else
9
+ ActionView::Base
10
+ end.register_template_handler(:ice, IceView)
@@ -1,7 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
 
4
- class FooClassCube < BaseCube
4
+
5
+ class FooClassCube < Ice::BaseCube
5
6
  revealing :first, :second
6
7
  end
7
8
 
@@ -1,9 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'ice'
4
- require 'ice/cubeable'
5
- require 'ice/cube_association'
6
- require 'ice/base_cube'
3
+
4
+ require File.dirname(__FILE__) + "/../init"
7
5
  require 'spec'
8
6
  require 'spec/autorun'
9
7
  require 'active_support'
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nate Kidwell
@@ -70,6 +70,7 @@ extra_rdoc_files:
70
70
  - README.markdown
71
71
  files:
72
72
  - .gitignore
73
+ - .specification
73
74
  - LICENSE
74
75
  - README.markdown
75
76
  - Rakefile
@@ -87,11 +88,13 @@ files:
87
88
  - ice_js/spec/unit/spec.helper.js
88
89
  - ice_js/spec/unit/spec.js
89
90
  - init.rb
91
+ - lib/extras/ice_view.rb
90
92
  - lib/ice.rb
91
93
  - lib/ice/base_cube.rb
92
94
  - lib/ice/cube_association.rb
93
95
  - lib/ice/cubeable.rb
94
96
  - lib/parser.js
97
+ - rails/init.rb
95
98
  - spec/base_cube_spec.rb
96
99
  - spec/cube_spec.rb
97
100
  - spec/ice_spec.rb