volt 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Readme.md +97 -56
  4. data/VERSION +1 -1
  5. data/app/volt/assets/js/sockjs-0.3.4.min.js +27 -0
  6. data/app/volt/assets/js/vertxbus.js +216 -0
  7. data/app/volt/tasks/live_query/live_query.rb +5 -5
  8. data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
  9. data/app/volt/tasks/query_tasks.rb +5 -0
  10. data/app/volt/tasks/store_tasks.rb +44 -18
  11. data/docs/WHY.md +10 -0
  12. data/lib/volt/cli.rb +18 -7
  13. data/lib/volt/controllers/model_controller.rb +30 -8
  14. data/lib/volt/extra_core/inflections.rb +63 -0
  15. data/lib/volt/extra_core/inflector/inflections.rb +203 -0
  16. data/lib/volt/extra_core/inflector/methods.rb +63 -0
  17. data/lib/volt/extra_core/inflector.rb +4 -0
  18. data/lib/volt/extra_core/object.rb +9 -0
  19. data/lib/volt/extra_core/string.rb +10 -14
  20. data/lib/volt/models/array_model.rb +45 -27
  21. data/lib/volt/models/cursor.rb +6 -0
  22. data/lib/volt/models/model.rb +127 -12
  23. data/lib/volt/models/model_hash_behaviour.rb +8 -5
  24. data/lib/volt/models/model_helpers.rb +4 -4
  25. data/lib/volt/models/model_state.rb +22 -0
  26. data/lib/volt/models/persistors/array_store.rb +49 -35
  27. data/lib/volt/models/persistors/base.rb +3 -3
  28. data/lib/volt/models/persistors/model_store.rb +17 -6
  29. data/lib/volt/models/persistors/query/query_listener.rb +0 -2
  30. data/lib/volt/models/persistors/store.rb +0 -4
  31. data/lib/volt/models/persistors/store_state.rb +27 -0
  32. data/lib/volt/models/url.rb +2 -2
  33. data/lib/volt/models/validations/errors.rb +0 -0
  34. data/lib/volt/models/validations/length.rb +13 -0
  35. data/lib/volt/models/validations/validations.rb +82 -0
  36. data/lib/volt/models.rb +1 -1
  37. data/lib/volt/page/bindings/attribute_binding.rb +29 -14
  38. data/lib/volt/page/bindings/base_binding.rb +2 -2
  39. data/lib/volt/page/bindings/component_binding.rb +29 -25
  40. data/lib/volt/page/bindings/content_binding.rb +1 -0
  41. data/lib/volt/page/bindings/each_binding.rb +25 -33
  42. data/lib/volt/page/bindings/event_binding.rb +0 -1
  43. data/lib/volt/page/bindings/if_binding.rb +3 -1
  44. data/lib/volt/page/bindings/template_binding.rb +61 -28
  45. data/lib/volt/page/document_events.rb +3 -1
  46. data/lib/volt/page/draw_cycle.rb +22 -0
  47. data/lib/volt/page/page.rb +10 -1
  48. data/lib/volt/page/reactive_template.rb +23 -16
  49. data/lib/volt/page/sub_context.rb +1 -1
  50. data/lib/volt/page/targets/attribute_section.rb +3 -2
  51. data/lib/volt/page/targets/attribute_target.rb +0 -4
  52. data/lib/volt/page/targets/base_section.rb +25 -0
  53. data/lib/volt/page/targets/binding_document/component_node.rb +13 -14
  54. data/lib/volt/page/targets/binding_document/html_node.rb +4 -0
  55. data/lib/volt/page/targets/dom_section.rb +16 -67
  56. data/lib/volt/page/targets/dom_template.rb +99 -0
  57. data/lib/volt/page/targets/helpers/comment_searchers.rb +29 -0
  58. data/lib/volt/page/template_renderer.rb +2 -14
  59. data/lib/volt/reactive/array_extensions.rb +0 -1
  60. data/lib/volt/reactive/event_chain.rb +9 -2
  61. data/lib/volt/reactive/events.rb +44 -37
  62. data/lib/volt/reactive/object_tracking.rb +1 -1
  63. data/lib/volt/reactive/reactive_array.rb +18 -0
  64. data/lib/volt/reactive/reactive_count.rb +108 -0
  65. data/lib/volt/reactive/reactive_generator.rb +44 -0
  66. data/lib/volt/reactive/reactive_value.rb +73 -73
  67. data/lib/volt/reactive/string_extensions.rb +1 -1
  68. data/lib/volt/router/routes.rb +205 -88
  69. data/lib/volt/server/component_handler.rb +3 -1
  70. data/lib/volt/server/html_parser/view_parser.rb +20 -4
  71. data/lib/volt/server/rack/component_paths.rb +13 -10
  72. data/lib/volt/server/rack/index_files.rb +4 -4
  73. data/lib/volt/server/socket_connection_handler.rb +5 -1
  74. data/lib/volt/server.rb +10 -3
  75. data/spec/apps/kitchen_sink/.gitignore +8 -0
  76. data/spec/apps/kitchen_sink/Gemfile +32 -0
  77. data/spec/apps/kitchen_sink/app/home/views/index/index.html +3 -5
  78. data/spec/apps/kitchen_sink/config.ru +4 -0
  79. data/spec/apps/kitchen_sink/public/index.html +2 -2
  80. data/spec/extra_core/inflector_spec.rb +8 -0
  81. data/spec/models/event_chain_spec.rb +18 -0
  82. data/spec/models/model_buffers_spec.rb +9 -0
  83. data/spec/models/model_spec.rb +22 -9
  84. data/spec/models/reactive_array_spec.rb +26 -1
  85. data/spec/models/reactive_call_times_spec.rb +28 -0
  86. data/spec/models/reactive_value_spec.rb +19 -0
  87. data/spec/models/validations_spec.rb +39 -0
  88. data/spec/page/bindings/content_binding_spec.rb +1 -0
  89. data/spec/{templates → page/bindings}/template_binding_spec.rb +54 -0
  90. data/spec/router/routes_spec.rb +156 -8
  91. data/spec/server/html_parser/sandlebars_parser_spec.rb +55 -47
  92. data/spec/server/html_parser/view_parser_spec.rb +3 -0
  93. data/spec/server/rack/asset_files_spec.rb +1 -1
  94. data/spec/spec_helper.rb +25 -11
  95. data/spec/templates/targets/binding_document/component_node_spec.rb +12 -0
  96. data/templates/project/Gemfile.tt +11 -0
  97. data/templates/project/app/home/config/routes.rb +1 -1
  98. data/templates/project/app/home/controllers/index_controller.rb +5 -5
  99. data/templates/project/app/home/views/index/index.html +6 -6
  100. data/volt.gemspec +5 -6
  101. metadata +34 -76
  102. data/app/volt/assets/js/sockjs-0.2.1.min.js +0 -27
  103. data/lib/volt/reactive/object_tracker.rb +0 -107
@@ -7,18 +7,166 @@ def routes(&block)
7
7
  end
8
8
 
9
9
  describe Routes do
10
+ it "should setup direct routes" do
11
+ routes do
12
+ get '/', _view: 'index'
13
+ get '/page1', _view: 'first_page'
14
+ end
15
+
16
+ direct_routes = @routes.instance_variable_get(:@direct_routes)
17
+ expect(direct_routes).to eq({"/" => {:_view => "index"}, "/page1" => {:_view => "first_page"}})
18
+ end
19
+
20
+ it "should setup indiect routes" do
21
+ routes do
22
+ get '/blog/{_id}/edit', _view: 'blog/edit'
23
+ get '/blog/{_id}', _view: 'blog/show'
24
+ end
25
+
26
+ indirect_routes = @routes.instance_variable_get(:@indirect_routes)
27
+ expect(indirect_routes).to eq(
28
+ {
29
+ "blog" => {
30
+ "*" => {
31
+ "edit" => {
32
+ nil => {:_view => "blog/edit", :_id => 1}
33
+ },
34
+ nil => {:_view => "blog/show", :_id => 1}
35
+ }
36
+ }
37
+ }
38
+ )
39
+ end
40
+
10
41
  it "should match routes" do
11
- params = Model.new({}, persistor: Persistors::Params)
12
- params._controller = 'blog'
13
- params._index = '5'
42
+ routes do
43
+ get "/blog", _view: 'blog'
44
+ get '/blog/{_id}', _view: 'blog/show'
45
+ get '/blog/{_id}/draft', _view: 'blog/draft', _action: 'draft'
46
+ get '/blog/{_id}/edit', _view: 'blog/edit'
47
+ get '/blog/tags/{_tag}', _view: 'blog/tag'
48
+ get '/login/{_name}/user/{_id}', _view: 'login', _action: 'user'
49
+ end
50
+
51
+ params = @routes.url_to_params('/blog')
52
+ expect(params).to eq({:_view => "blog"})
53
+
54
+ params = @routes.url_to_params('/blog/55/edit')
55
+ expect(params).to eq({:_view => "blog/edit", :_id => "55"})
56
+
57
+ params = @routes.url_to_params('/blog/55')
58
+ expect(params).to eq({:_view => "blog/show", :_id => "55"})
14
59
 
60
+ params = @routes.url_to_params('/blog/tags/good')
61
+ expect(params).to eq({:_view => "blog/tag", :_tag => "good"})
62
+
63
+ params = @routes.url_to_params('/blog/55/draft')
64
+ expect(params).to eq({:_view => "blog/draft", :_id => "55", :_action => "draft"})
65
+
66
+ params = @routes.url_to_params('/login/jim/user/10')
67
+ expect(params).to eq({:_view => "login", :_action => "user", :_name => "jim", :_id => "10"})
68
+
69
+ params = @routes.url_to_params('/login/cool')
70
+ expect(params).to eq(false)
71
+
72
+ end
73
+
74
+ it "should setup param matchers" do
75
+ routes do
76
+ get "/blog", _view: 'blog'
77
+ get '/blog/{_id}', _view: 'blog/show'
78
+ get '/blog/{_id}/edit', _view: 'blog/edit'
79
+ get '/blog/tags/{_tag}', _view: 'blog/tag'
80
+ get '/login/{_name}/user/{_id}', _view: 'login', _action: 'user'
81
+ end
82
+
83
+ param_matches = @routes.instance_variable_get(:@param_matches)
84
+ expect(param_matches.map {|v| v[0] }).to eq([
85
+ {:_view => "blog"},
86
+ {:_view => "blog/show", :_id => nil},
87
+ {:_view => "blog/edit", :_id => nil},
88
+ {:_view => "blog/tag", :_tag => nil},
89
+ {:_view => "login", :_action => "user",:_name => nil, :_id => nil}
90
+ ])
91
+
92
+ end
93
+
94
+ it "should go from params to url" do
15
95
  routes do
16
- get '/', _controller: 'index'
17
- get '/blog', _controller: 'blog'
96
+ get "/blog", _view: 'blog'
97
+ get '/blog/{_id}', _view: 'blog/show'
98
+ get '/blog/{_id}/edit', _view: 'blog/edit'
99
+ get '/blog/tags/{_tag}', _view: 'blog/tag'
100
+ get '/login/{_name}/user/{_id}', _view: 'login', _action: 'user'
18
101
  end
19
102
 
20
- path, cleaned_params = @routes.url_for_params(params)
21
- expect(path).to eq('/blog')
22
- expect(cleaned_params).to eq({_index: '5'})
103
+ url, params = @routes.params_to_url({_view: 'blog/show', _id: '55'})
104
+ expect(url).to eq('/blog/55')
105
+ expect(params).to eq({})
106
+
107
+
108
+ url, params = @routes.params_to_url({_view: 'blog/edit', _id: '100'})
109
+ expect(url).to eq('/blog/100/edit')
110
+ expect(params).to eq({})
111
+
112
+ url, params = @routes.params_to_url({_view: 'blog/edit', _id: '100', _other: 'should_pass'})
113
+ expect(url).to eq('/blog/100/edit')
114
+ expect(params).to eq({_other: 'should_pass'})
23
115
  end
116
+
117
+ it "should test that params match a param matcher" do
118
+ routes = Routes.new
119
+ match, params = routes.send(:check_params_match, {_view: 'blog', _id: '55'}, {_view: 'blog', _id: nil})
120
+ expect(match).to eq(true)
121
+ expect(params).to eq({_id: '55'})
122
+
123
+ match, params = routes.send(:check_params_match, {_view: 'blog', _id: '55'}, {_view: 'blog', _id: '20'})
124
+ expect(match).to eq(false)
125
+
126
+ match, params = routes.send(:check_params_match, {_view: 'blog', _name: {_title: 'Mr', _name: 'Bob'}, _id: '55'}, {_view: 'blog', _id: nil, _name: {_title: 'Mr', _name: nil}})
127
+ expect(match).to eq(true)
128
+ expect(params).to eq({_id: '55'})
129
+
130
+ # Check with an extra value _name._name
131
+ match, params = routes.send(:check_params_match, {_view: 'blog', _name: {_title: 'Mr', _name: 'Bob'}, _id: '55'}, {_view: 'blog', _id: nil, _name: {_title: 'Mr'}})
132
+ expect(match).to eq(true)
133
+ expect(params).to eq({_id: '55'})
134
+
135
+ match, params = routes.send(:check_params_match, {_view: 'blog', _name: {_title: 'Mr', _name: 'Bob'}, _id: '55'}, {_view: 'blog', _id: nil, _name: {_title: 'Phd'}})
136
+ expect(match).to eq(false)
137
+
138
+ # Check to make sure extra values in the params pass it.
139
+ match, params = routes.send(:check_params_match, {_view: 'blog', _id: '55', _extra: 'some value'}, {_view: 'blog', _id: '55'})
140
+ expect(match).to eq(true)
141
+ expect(params).to eq({_extra: 'some value'})
142
+
143
+ end
144
+
145
+ # it "should match routes" do
146
+ # params = Model.new({}, persistor: Persistors::Params)
147
+ # params._controller = 'blog'
148
+ # params._index = '5'
149
+ #
150
+ # routes do
151
+ # get '/', _controller: 'index'
152
+ # get '/blog', _controller: 'blog'
153
+ # end
154
+ #
155
+ # path, cleaned_params = @routes.params_to_url(params)
156
+ # expect(path).to eq('/blog')
157
+ # expect(cleaned_params).to eq({_index: '5'})
158
+ # end
159
+ #
160
+ # it "should handle routes with bindings in them" do
161
+ # params = Model.new({}, persistor: Persistors::Params)
162
+ #
163
+ # routes do
164
+ # get '/', _controller: 'index'
165
+ # get '/blog/{_id}', _controller: 'blog'
166
+ # end
167
+ #
168
+ # params = @routes.url_to_params('/blog/20')
169
+ # puts params.inspect
170
+ #
171
+ # end
24
172
  end
@@ -1,25 +1,27 @@
1
+ if RUBY_PLATFORM == 'opal'
2
+ else
1
3
  require 'benchmark'
2
4
  require 'volt/server/html_parser/sandlebars_parser'
3
5
 
4
6
  class HTMLHandler
5
7
  attr_reader :html
6
-
8
+
7
9
  def initialize
8
10
  @html = ''
9
11
  end
10
-
12
+
11
13
  def comment(comment)
12
14
  @html << "<!--#{comment}-->"
13
15
  end
14
-
16
+
15
17
  def text(text)
16
18
  @html << text
17
19
  end
18
-
20
+
19
21
  def binding(binding)
20
22
  @html << "{#{binding}}"
21
23
  end
22
-
24
+
23
25
  def start_tag(tag_name, attributes, unary)
24
26
  attr_str = attributes.map {|v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
25
27
  if attr_str.size > 0
@@ -28,7 +30,7 @@ class HTMLHandler
28
30
  end
29
31
  @html << "<#{tag_name}#{attr_str}#{unary ? ' /' : ''}>"
30
32
  end
31
-
33
+
32
34
  def end_tag(tag_name)
33
35
  @html << "</#{tag_name}>"
34
36
  end
@@ -37,14 +39,14 @@ end
37
39
  def parse_url(url)
38
40
  require 'open-uri'
39
41
  html = open("http://#{url}").read
40
-
42
+
41
43
  # html = File.read("/Users/ryanstout/Desktop/tests/#{url}1.html")
42
-
44
+
43
45
  File.open("/Users/ryanstout/Desktop/tests/#{url}1.html", 'w') {|f| f.write(html) }
44
-
46
+
45
47
  handler = HTMLHandler.new
46
48
  SandlebarsParser.new(html, handler)
47
-
49
+
48
50
  File.open("/Users/ryanstout/Desktop/tests/#{url}2.html", 'w') {|f| f.write(handler.html) }
49
51
  end
50
52
 
@@ -52,141 +54,147 @@ describe SandlebarsParser do
52
54
  def test_html(html, match=nil)
53
55
  handler = HTMLHandler.new
54
56
  parser = SandlebarsParser.new(html, handler)
55
-
57
+
56
58
  expect(handler.html).to eq(match || html)
57
59
  end
58
-
60
+
59
61
  it "should handle a doctype" do
60
62
  html = "<!DOCTYPE html><p>text</p>"
61
-
63
+
62
64
  test_html(html)
63
65
  end
64
-
66
+
65
67
  it "should parse comments" do
66
68
  html = "<!-- my comment -->"
67
69
  test_html(html)
68
70
  end
69
-
71
+
70
72
  it "should handle text" do
71
73
  html = "some text, <!-- a comment -->, some more text"
72
74
  test_html(html)
73
75
  end
74
-
76
+
75
77
  it "should handle tags" do
76
78
  html = "<a name=\"cool\"></a>"
77
79
  test_html(html)
78
80
  end
79
-
81
+
80
82
  it "should close tags" do
81
83
  html = "<div><p>test</p>"
82
84
  match = "<div><p>test</p></div>"
83
-
85
+
84
86
  test_html(html, match)
85
87
  end
86
-
88
+
87
89
  it "should handle a script tag with html in it" do
88
90
  html = "<script><!-- some js code <a>cool</a> here --></script>"
89
91
  match = "<script> some js code <a>cool</a> here </script>"
90
92
  test_html(html, match)
91
93
  end
92
-
94
+
93
95
  it "should handle bindings" do
94
96
  html = "<p>some cool {text} is {awesome}</p>"
95
97
  test_html(html)
96
98
  end
97
-
99
+
98
100
  it "should handle bindings with nested { and }" do
99
101
  html = "<p>testing with {nested { 'binding stuff' }}</p>"
100
102
  test_html(html)
101
103
  end
102
-
104
+
103
105
  it "should raise an exception on an unclosed binding at the end of the document" do
104
106
  html = "<p>testing with {nested"
105
-
107
+
106
108
  handler = HTMLHandler.new
107
109
  expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError)
108
110
  end
109
-
111
+
110
112
  it "should raise an exception on an unclosed binding" do
111
113
  html = "<p>testing with {nested </p>\n<p>ok</p>"
112
-
114
+
113
115
  handler = HTMLHandler.new
114
- expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError)
116
+ expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError)
115
117
  end
116
-
118
+
117
119
  it "should report the line number" do
118
120
  html = "\n\n<p>some paragraph</p>\n\n<p>testing with {nested </p>\n<p>ok</p>"
119
-
121
+
120
122
  handler = HTMLHandler.new
121
- expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError, "unclosed binding: {nested </p> on line: 5")
123
+ expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError, "unclosed binding: {nested </p> on line: 5")
122
124
  end
123
-
125
+
124
126
  it "should handle a bunch of things" do
125
127
  html = <<-END
126
128
  <p class="some class">This is my text <a href="something.com">something.com</a></p>
127
129
  END
128
-
130
+
129
131
  test_html(html)
130
132
  end
131
-
133
+
132
134
  it "should not jump between script tags" do
133
135
  html = "\n<script>some text</script>\n\n<script>inside 2</script>\n"
134
-
136
+
135
137
  test_html(html)
136
138
  end
137
-
139
+
138
140
  it "should not jump bindings" do
139
141
  html = "<p>{some} text {binding}</p>"
140
142
  test_html(html)
141
143
  end
142
-
144
+
143
145
  it "should handle escaping things in a tripple escape" do
144
146
  html = "this is my {{{ tripple escape }}}"
145
147
  match = "this is my tripple escape "
146
- test_html(html, match)
148
+ test_html(html, match)
147
149
  end
148
-
150
+
149
151
  it "should let you escape { and }" do
150
152
  html = "should escape {{{{}}} and {{{}}}}"
151
153
  match = "should escape { and }"
152
- test_html(html, match)
154
+ test_html(html, match)
153
155
  end
154
-
156
+
155
157
  it "should handle sandlebar tags" do
156
158
  html = "custom tag <:awesome name=\"yes\" />"
157
- test_html(html)
159
+ test_html(html)
158
160
  end
159
-
161
+
160
162
  it "should keep the text after script" do
161
163
  html = "<ul><li>\n\n<script>\n\nsome js code\n\nmore\n\n</script> \n </li> \n \n </ul>"
162
164
  test_html(html)
163
165
  end
164
-
166
+
165
167
  it "should handle dashes in attributes" do
166
168
  html = "<form accept-charset=\"UTF-8\"></form>"
167
169
  test_html(html)
168
170
  end
169
-
171
+
170
172
  it "should handle conditional comments for IE" do
171
173
  html = "<!--[if ie6]>some ie only stuff<![endif]-->\n<br />"
172
174
  test_html(html)
173
175
  end
174
-
176
+
175
177
  it "should be fast" do
176
178
  html = File.read(File.join(File.dirname(__FILE__), 'sample_page.html'))
177
179
  handler = HTMLHandler.new
178
180
  time = Benchmark.measure do
179
181
  SandlebarsParser.new(html, handler)
180
182
  end
181
-
183
+
182
184
  # Less than 100ms
183
185
  expect(time.total).to be < 0.1
184
186
  end
185
-
187
+
188
+ it "should parse nested components" do
189
+ html = "custom tag <:awesome:cool name=\"yes\" />"
190
+ test_html(html)
191
+ end
192
+
186
193
  # it "should warn you when you over close tags" do
187
194
  # html = "<div><p>test</p></div></div>"
188
- #
195
+ #
189
196
  # handler = HTMLHandler.new
190
197
  # expect { SandlebarsParser.new(html, handler) }.to raise_error(HTMLParseError)
191
198
  # end
199
+ end
192
200
  end
@@ -1,3 +1,5 @@
1
+ if RUBY_PLATFORM == 'opal'
2
+ else
1
3
  require 'benchmark'
2
4
  require 'volt/server/html_parser/view_parser'
3
5
 
@@ -283,4 +285,5 @@ describe ViewParser do
283
285
  })
284
286
  end
285
287
 
288
+ end
286
289
  end
@@ -19,7 +19,7 @@ if RUBY_PLATFORM != 'opal'
19
19
  it "should list all JS files" do
20
20
  main = AssetFiles.new("main", @component_paths)
21
21
 
22
- expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.2.1.min.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/home.js"])
22
+ expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.3.4.min.js", "/assets/js/vertxbus.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/home.js"])
23
23
  end
24
24
  end
25
25
  end
data/spec/spec_helper.rb CHANGED
@@ -5,16 +5,20 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
 
8
+ ENV['SERVER'] = 'true'
8
9
  ENV['SAUCE_USERNAME'] = 'ryanstout'
9
10
  ENV['SAUCE_ACCESS_KEY'] = 'a537b01d-33ed-4028-9e80-eeb602748a5f'
10
11
 
11
12
  if ENV['IN_BROWSER']
12
- require 'capybara/rspec'
13
- # Needed at the moment to get chrome tests working
14
- require 'chromedriver2/helper'
15
- require 'capybara/poltergeist'
16
- # require "sauce/capybara"
17
- # require 'sauce/connect'
13
+ if RUBY_PLATFORM == 'opal'
14
+ else
15
+ require 'capybara/rspec'
16
+ # Needed at the moment to get chrome tests working
17
+ require 'chromedriver2/helper'
18
+ require 'capybara/poltergeist'
19
+ # require "sauce/capybara"
20
+ # require 'sauce/connect'
21
+ end
18
22
  end
19
23
 
20
24
  require 'volt'
@@ -36,15 +40,25 @@ require 'volt'
36
40
  # Capybara::Selenium::Driver.new(app, :browser => :chrome)
37
41
  # end
38
42
 
39
- # Capybara.default_driver = :selenium
40
43
  if ENV['IN_BROWSER']
41
- require 'volt/server'
44
+ if RUBY_PLATFORM == 'opal'
45
+ else
46
+ require 'volt/server'
47
+
42
48
 
49
+ kitchen_sink_path = File.expand_path(File.join(File.dirname(__FILE__), "apps/kitchen_sink"))
50
+ Capybara.app = Server.new(kitchen_sink_path).app
43
51
 
44
- kitchen_sink_path = File.expand_path(File.join(File.dirname(__FILE__), "apps/kitchen_sink"))
45
- Capybara.app = Server.new(kitchen_sink_path).app
52
+ Capybara.default_driver = :poltergeist
46
53
 
47
- Capybara.default_driver = :poltergeist
54
+ # Capybara.register_driver :chrome do |app|
55
+ # Capybara::Selenium::Driver.new(app, :browser => :chrome)
56
+ # end
57
+ #
58
+ # Capybara.default_driver = :chrome
59
+
60
+ # Capybara.default_driver = :selenium
61
+ end
48
62
  end
49
63
 
50
64
 
@@ -15,4 +15,16 @@ describe ComponentNode do
15
15
  expect(@component.find_by_binding_id(0).to_html).to eq('Before Inside After')
16
16
 
17
17
  end
18
+
19
+ # it "should render if blocks" do
20
+ # view = <<-END
21
+ # {#if _show}show{/} title
22
+ # END
23
+ #
24
+ # page = Page.new
25
+ #
26
+ # template = ViewParser.new(view, 'home/index/index/title')
27
+ #
28
+ # page.add_template
29
+ # end
18
30
  end
@@ -12,6 +12,17 @@ gem 'volt-bootstrap'
12
12
  gem 'volt-bootstrap-jumbotron-theme'
13
13
 
14
14
 
15
+ # Server for MRI
16
+ platform :mri do
17
+ gem 'thin', '~> 1.6.0'
18
+ gem 'bson_ext', '~> 1.9.0'
19
+ end
20
+
21
+ # Server for jruby
22
+ platform :jruby do
23
+ gem 'jubilee'
24
+ end
25
+
15
26
 
16
27
  #---------------------
17
28
  # Needed at the moment
@@ -1,4 +1,4 @@
1
- get "/about", _view: 'about'
1
+ get "/about", _controller: 'about'
2
2
 
3
3
  # The main route
4
4
  get '/'
@@ -1,9 +1,9 @@
1
1
  class IndexController < ModelController
2
- model :page
3
-
4
- def initialize
5
- super
2
+ def index
3
+ # Add code for when the main page is loaded
4
+ end
6
5
 
7
- # Add controller setup code here
6
+ def home
7
+ # Add code for when the home view is loaded
8
8
  end
9
9
  end
@@ -1,19 +1,19 @@
1
1
  <:Title>
2
- {#template params._view.or('home'), "title"}
2
+ {#template params._controller.or('home') + '/' + params._action.or(''), "title"}
3
3
 
4
4
  <:Body>
5
5
  <div class="container">
6
6
  <div class="header">
7
7
  <ul class="nav nav-pills pull-right">
8
- <:nav view="" text="Home" />
9
- <:nav view="about" text="About" />
8
+ <:nav controller="" text="Home" />
9
+ <:nav controller="about" text="About" />
10
10
  </ul>
11
11
  <h3 class="text-muted">Project name</h3>
12
12
  </div>
13
13
 
14
14
  <:volt:notices />
15
15
 
16
- {#template params._view.or('home')}
16
+ {#template params._controller.or('home') + '/' + params._action.or('')}
17
17
 
18
18
  <div class="footer">
19
19
  <p>&copy; Company 2014</p>
@@ -23,7 +23,7 @@
23
23
 
24
24
 
25
25
  <:Nav>
26
- <li class="{#if params._view.or('') == view}active{/}">
27
- <a href="/{view}">{text}</a>
26
+ <li class="{#if params._controller.or('') == @controller}active{/}">
27
+ <a href="/{@controller}">{@text}</a>
28
28
  </li>
29
29
 
data/volt.gemspec CHANGED
@@ -22,19 +22,18 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "thor", "~> 0.18.0"
23
23
  spec.add_dependency "pry", "~> 0.9.12.0"
24
24
  spec.add_dependency "rspec", "3.0.0.beta1"
25
- spec.add_dependency "nokogiri", "~> 1.6.0"
26
25
  spec.add_dependency "rack", "~> 1.5.0"
27
26
  spec.add_dependency "sprockets-sass", "~> 1.0.0"
28
27
  spec.add_dependency "sass", "~> 3.2.5"
29
28
  spec.add_dependency "mongo", "~> 1.9.0"
30
- spec.add_dependency "bson_ext", "~> 1.9.0"
31
- spec.add_dependency "thin", "~> 1.6.0"
32
- spec.add_dependency "multi_json", "~> 1.8.2"
33
- spec.add_dependency "oj", "~> 2.5.0"
29
+ # spec.add_dependency "bson_ext", "~> 1.9.0"
30
+ # spec.add_dependency "thin", "~> 1.6.0"
34
31
  spec.add_dependency "rake", "~> 10.0.4"
35
32
  spec.add_dependency "listen", "~> 2.4.0"
36
33
  spec.add_dependency "uglifier", "~> 2.4.0"
37
34
  spec.add_dependency "yui-compressor", "~> 0.12.0"
35
+ # spec.add_dependency "promise.rb", "~> 0.6.1"
36
+
38
37
  # spec.add_dependency "rack-colorized_logger", "~> 1.0.4"
39
38
 
40
39
 
@@ -49,5 +48,5 @@ Gem::Specification.new do |spec|
49
48
  spec.add_development_dependency "poltergeist", "~> 1.5.0"
50
49
  spec.add_development_dependency "sauce", "~> 3.3.0"
51
50
  spec.add_development_dependency "sauce-connect", "~> 3.3.0"
52
-
51
+
53
52
  end