volt 0.8.27.beta7 → 0.8.27.beta8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile +2 -2
  4. data/VERSION +1 -1
  5. data/app/volt/tasks/user_tasks.rb +2 -2
  6. data/lib/volt/cli/generate.rb +17 -0
  7. data/lib/volt/extra_core/extra_core.rb +0 -1
  8. data/lib/volt/extra_core/object.rb +0 -18
  9. data/lib/volt/models/array_model.rb +4 -3
  10. data/lib/volt/models/buffer.rb +3 -0
  11. data/lib/volt/models/errors.rb +11 -0
  12. data/lib/volt/models/model_hash_behaviour.rb +0 -8
  13. data/lib/volt/models/persistors/array_store.rb +1 -1
  14. data/lib/volt/page/bindings/content_binding.rb +1 -1
  15. data/lib/volt/page/bindings/template_binding.rb +0 -5
  16. data/lib/volt/page/page.rb +1 -1
  17. data/lib/volt/reactive/reactive_array.rb +4 -4
  18. data/lib/volt/server/rack/http_resource.rb +5 -1
  19. data/lib/volt/tasks/dispatcher.rb +1 -1
  20. data/lib/volt/volt/users.rb +1 -1
  21. data/spec/apps/kitchen_sink/Gemfile +2 -2
  22. data/spec/apps/kitchen_sink/app/main/config/dependencies.rb +2 -2
  23. data/spec/apps/kitchen_sink/app/main/config/routes.rb +2 -2
  24. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +42 -40
  25. data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +14 -12
  26. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +14 -12
  27. data/spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb +21 -19
  28. data/spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb +5 -3
  29. data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -1
  30. data/spec/extra_core/object_spec.rb +4 -4
  31. data/spec/integration/user_spec.rb +0 -2
  32. data/spec/models/buffer_spec.rb +28 -0
  33. data/spec/models/model_spec.rb +0 -8
  34. data/templates/component/controllers/main_controller.rb.tt +1 -1
  35. data/templates/controller/http_controller.rb.tt +5 -0
  36. data/templates/controller/model_controller.rb.tt +5 -0
  37. data/templates/model/model.rb.tt +1 -1
  38. data/templates/project/Gemfile.tt +2 -2
  39. data/templates/project/app/main/config/dependencies.rb +2 -2
  40. data/templates/project/app/main/config/routes.rb +3 -3
  41. data/templates/project/app/main/controllers/main_controller.rb +21 -19
  42. data/templates/project/app/main/views/main/main.html.tt +1 -1
  43. metadata +3 -2
  44. data/lib/volt/extra_core/true_false.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8f7ccdc9801cf342901b77cf83b2091af34975f
4
- data.tar.gz: a4f0dd2b28f09f2423fa602eb45c9935d422840c
3
+ metadata.gz: 12a30dfcdd14af504ac6f848776b93e18074123e
4
+ data.tar.gz: 9729fd4c76c577c9bc8ace4fba5c816060b5b70a
5
5
  SHA512:
6
- metadata.gz: 94607eb5080e4809be8a505e2a6e0c2602a887346de86c335e7177b1230ed75048091a9d1751d1b3d30e1960bb242b385966c58eb1b13bd52f03a05b253f3069
7
- data.tar.gz: bb4d64bc6781e697e646f53054c305499fcd4434e10c8bfde661c46fb0fef31a3a0bda791818c783bc5631aacfadd156486baddb0537a4868dd597056f91708c
6
+ metadata.gz: 7d9bc05ab9bdce64f2a38e900cc362c81ae026b8038c11160a6a15e1134a50d4bcbda4aec36cc157aef8f4eaf1d08188d5f710604dce51414779dfd35697ec18
7
+ data.tar.gz: 84da2e64eab8a4b8b7bf5db5a5a4bd1e95892b41bd59da5a3e3ae52d6106742f2a318f0c0c4c13824b4248e5c82e1941ae8f924692ab4cd3f4297378da6baf37
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
  ### Added
5
5
  - added has_many and belongs_to on models. See docs.
6
6
  - you can now serve http/rest from Volt. Thanks to @jfahrer for his great work. Docs coming soon.
7
+ - there is now a generator for controllers and HttpControllers.
8
+ - the following were renamed to follow gem naming conventions:
9
+ - volt-user-templates (now volt-user_templates)
10
+ - volt-bootstrap-jumbotron-theme (now volt-bootstrap_jumbotron_theme)
7
11
  - fixed generated component code
8
12
  - added .order for sorting on the data store (since .sort is a ruby Enum method)
9
13
  - calling .then on ArrayModels has been changed to calling .fetch and .fetch_first. These both return a promise, and take an optional block
@@ -22,6 +26,8 @@
22
26
  - ```the_page``` is a shortcut to the page collection inside of specs. (Unfortunately, ```page``` is used by capybara, so for now we're using ```the_page```, we'll find a better solution in the future.)
23
27
 
24
28
  ### Changed
29
+ - main_path in generated projects now includes the a component param that can be used to easily point at controllers/views in other components.
30
+ - previously the main component's controllers were not namespaced. We changed it so all controllers (including those in main) are namespaced. This is makes things more consistent and keeps expectations when working with components.
25
31
  - model attributes no longer return NilModels. Instead they just return nil. You can however add an ! to the end to "expand" the model to an empty model.
26
32
 
27
33
  ```page._new_todo # => now returns nil```
@@ -35,6 +41,9 @@ So if you wanted to use a property on ```_new_todo``` without initializing ```_n
35
41
  - changed .find to .where to not conflict with ruby Enum's .find
36
42
  - Volt::TaskHandler is now Volt::Task
37
43
 
44
+ ### Removed
45
+ - .false?, .true?, .or, and .and were removed since NilModels were removed. This means you get back a real nil value when accessing an undefined model attribute.
46
+
38
47
  ## 0.8.24 - 2014-12-05
39
48
  ### Added
40
49
  - Fix bug with validation inheritance
data/Gemfile CHANGED
@@ -8,13 +8,13 @@ group :development do
8
8
  gem 'volt-bootstrap'
9
9
 
10
10
  # Simple theme for bootstrap, remove to theme yourself.
11
- gem 'volt-bootstrap-jumbotron-theme'
11
+ gem 'volt-bootstrap_jumbotron_theme'
12
12
 
13
13
  # For testing
14
14
  gem 'volt-fields'
15
15
 
16
16
  # For testing
17
- gem 'volt-user-templates'
17
+ gem 'volt-user_templates'
18
18
 
19
19
  # For running rubocop
20
20
  gem 'rubocop', require: false
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.27.beta7
1
+ 0.8.27.beta8
@@ -6,7 +6,7 @@ class UserTasks < Volt::Task
6
6
 
7
7
  # During login we need access to the user's info even though we aren't the user
8
8
  Volt.skip_permissions do
9
- store._users.find(query).fetch_first do |user|
9
+ store._users.where(query).fetch_first do |user|
10
10
  fail 'User could not be found' unless user
11
11
 
12
12
  match_pass = BCrypt::Password.new(user._hashed_password)
@@ -29,4 +29,4 @@ class UserTasks < Volt::Task
29
29
  def salty_user_id(user_id)
30
30
  "#{Volt.config.app_secret}::#{user_id}"
31
31
  end
32
- end
32
+ end
@@ -36,4 +36,21 @@ class Generate < Thor
36
36
  def self.source_root
37
37
  File.expand_path(File.join(File.dirname(__FILE__), '../../../templates'))
38
38
  end
39
+
40
+ desc 'http_controller NAME COMPONENT', 'Creates an HTTP Controller named NAME in the .'
41
+ method_option :name, type: :string, banner: 'The name of the HTTP Controller.'
42
+ method_option :component, type: :string, default: 'main', banner: 'The component the http_controller should be created in.', required: false
43
+ def http_controller(name, component = 'main')
44
+ output_file = Dir.pwd + "/app/#{component}/controllers/#{name.underscore.singularize}.rb"
45
+ template('controller/http_controller.rb.tt', output_file, component_module: component.camelize, http_controller_name: name.camelize.singularize)
46
+ end
47
+
48
+ desc 'controller NAME COMPONENT', 'Creates a model controller named NAME in the app folder of the component named COMPONENT.'
49
+ method_option :name, type: :string, banner: 'The name of the model controller.'
50
+ method_option :component, type: :string, default: 'main', banner: 'The component the controller should be created in.', required: false
51
+ def controller(name, component = 'main')
52
+ output_file = Dir.pwd + "/app/#{component}/controllers/#{name.underscore.singularize}.rb"
53
+ template('controller/model_controller.rb.tt', output_file, component_module: component.camelize, model_controller_name: name.camelize.singularize)
54
+ end
55
+
39
56
  end
@@ -4,7 +4,6 @@ require 'volt/extra_core/object'
4
4
  require 'volt/extra_core/blank'
5
5
  require 'volt/extra_core/stringify_keys'
6
6
  require 'volt/extra_core/string'
7
- require 'volt/extra_core/true_false'
8
7
  require 'volt/extra_core/hash'
9
8
  require 'volt/extra_core/class'
10
9
  if RUBY_PLATFORM == 'opal'
@@ -6,24 +6,6 @@ class Object
6
6
  Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }]
7
7
  end
8
8
 
9
- # Provides the same functionality as ||, but treats a nil model as falsy
10
- def or(other)
11
- if self && !self.nil?
12
- self
13
- else
14
- other
15
- end
16
- end
17
-
18
- # Provides the same functionality as &&, treats a nil model as falsy
19
- def and(other)
20
- if self && !self.nil?
21
- other
22
- else
23
- self
24
- end
25
- end
26
-
27
9
  def html_inspect
28
10
  inspect.gsub('<', '&lt;').gsub('>', '&gt;')
29
11
  end
@@ -94,13 +94,14 @@ module Volt
94
94
  trigger_size_change!
95
95
  #
96
96
  # re-raise, err might not be an Error object, so we use a rejected promise to re-raise
97
+
97
98
  Promise.new.reject(err)
98
99
  end
99
100
  end
100
- else
101
- # Return this model
102
- model
103
101
  end
102
+
103
+ # Return this model
104
+ Promise.new.resolve(model)
104
105
  end
105
106
 
106
107
  # Works like << except it always returns a promise
@@ -61,6 +61,9 @@ module Volt
61
61
  def promise_for_errors(errors)
62
62
  mark_all_fields!
63
63
 
64
+ # Wrap in an Errors class unless it already is one
65
+ errors = errors.is_a?(Errors) ? errors : Errors.new(errors)
66
+
64
67
  Promise.new.reject(errors)
65
68
  end
66
69
 
@@ -17,5 +17,16 @@ module Volt
17
17
  end
18
18
  end
19
19
  end
20
+
21
+ # Generate a string version of all of the errors
22
+ def to_s
23
+ str = []
24
+
25
+ each_pair do |field, error|
26
+ str << "#{field} #{error}"
27
+ end
28
+
29
+ str.join
30
+ end
20
31
  end
21
32
  end
@@ -45,14 +45,6 @@ module Volt
45
45
  !@attributes || @attributes.size == 0
46
46
  end
47
47
 
48
- def false?
49
- @attributes.false?
50
- end
51
-
52
- def true?
53
- @attributes.true?
54
- end
55
-
56
48
  def clear
57
49
  @attributes.each_pair do |key, _|
58
50
  delete(key)
@@ -140,7 +140,7 @@ module Volt
140
140
 
141
141
  parent.persistor.ensure_setup if parent.persistor
142
142
 
143
- if parent && (attrs = parent.attributes) && attrs[:_id].true?
143
+ if parent && (attrs = parent.attributes) && attrs[:_id]
144
144
  query = query.dup
145
145
 
146
146
  query << [:find, {:"#{@model.path[-3].singularize}_id" => attrs[:_id]}]
@@ -20,7 +20,7 @@ module Volt
20
20
  end
21
21
 
22
22
  def update(value)
23
- value = value.or('')
23
+ value = value || ''
24
24
 
25
25
  # Exception values display the exception as a string
26
26
  value = value.to_s
@@ -195,11 +195,6 @@ module Volt
195
195
  # Get the constant parts
196
196
  parts = controller_path[0..-2].map { |v| v.tr('-', '_').camelize }
197
197
 
198
- # Home doesn't get namespaced
199
- if parts.first == 'Main'
200
- parts.shift
201
- end
202
-
203
198
  # Do const lookups starting at object and working our way down.
204
199
  # So Volt::ProgressBar would lookup Volt, then ProgressBar on Volt.
205
200
  obj = Object
@@ -167,7 +167,7 @@ module Volt
167
167
  # Do the initial url params parse
168
168
  @url_tracker.url_updated(true)
169
169
 
170
- main_controller = MainController.new
170
+ main_controller = Main::MainController.new
171
171
 
172
172
  # Setup main page template
173
173
  TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', 'main/main/main/body')
@@ -35,7 +35,7 @@ module Volt
35
35
  count = 0
36
36
 
37
37
  size.times do |index|
38
- if block.call(self[index]).true?
38
+ if block.call(self[index])
39
39
  count += 1
40
40
  end
41
41
  end
@@ -50,7 +50,7 @@ module Volt
50
50
  result = []
51
51
  size.times do |index|
52
52
  val = self[index]
53
- if yield(val).true?
53
+ if yield(val)
54
54
  result << val
55
55
  end
56
56
  end
@@ -63,7 +63,7 @@ module Volt
63
63
  size.times do |index|
64
64
  val = self[index]
65
65
 
66
- if yield(val).true?
66
+ if yield(val)
67
67
  return true
68
68
  end
69
69
  end
@@ -79,7 +79,7 @@ module Volt
79
79
  size.times do |index|
80
80
  val = self[index]
81
81
 
82
- unless yield(val).true?
82
+ unless yield(val)
83
83
  return false
84
84
  end
85
85
  end
@@ -31,9 +31,13 @@ module Volt
31
31
  # The controller name and actions need to be set as params for the
32
32
  # matching route
33
33
  def dispatch_to_controller(params, request)
34
+ namespace = params[:component] || 'main'
35
+
34
36
  controller_name = params[:controller] + '_controller'
35
37
  action = params[:action]
36
- klass = Object.const_get(controller_name.camelize.to_sym)
38
+
39
+ namespace_module = Object.const_get(namespace.camelize.to_sym)
40
+ klass = namespace_module.const_get(controller_name.camelize.to_sym)
37
41
  controller = klass.new(params, request)
38
42
  controller.perform(action)
39
43
  end
@@ -19,7 +19,7 @@ module Volt
19
19
  start_time = Time.now.to_f
20
20
 
21
21
  # Check that we are calling on a Task class and a method provide at
22
- # Task or above in the ancestor chain.
22
+ # Task or above in the ancestor chain. (so no :send or anything)
23
23
  if safe_method?(klass, method_name)
24
24
  promise.resolve(nil)
25
25
 
@@ -64,7 +64,7 @@ module Volt
64
64
 
65
65
  # Put in a deprecation placeholder
66
66
  def user
67
- Volt.logger.warning("deprication: Volt.user has been renamed to Volt.current_user (to be more clear about what it returns). Volt.user will be deprecated in the future.")
67
+ Volt.logger.warn("deprication: Volt.user has been renamed to Volt.current_user (to be more clear about what it returns). Volt.user will be deprecated in the future.")
68
68
  current_user
69
69
  end
70
70
 
@@ -8,10 +8,10 @@ gem 'volt', path: '../../../'
8
8
  gem 'volt-bootstrap'
9
9
 
10
10
  # Simple theme for bootstrap, remove to theme yourself.
11
- gem 'volt-bootstrap-jumbotron-theme'
11
+ gem 'volt-bootstrap_jumbotron_theme'
12
12
 
13
13
  gem 'volt-fields'
14
- gem 'volt-user-templates', path: '/Users/ryanstout/Sites/volt/apps/volt-user-templates'
14
+ gem 'volt-user_templates'
15
15
 
16
16
  gem 'opal'
17
17
 
@@ -5,10 +5,10 @@
5
5
  component 'bootstrap'
6
6
 
7
7
  # a default theme for the bootstrap framework
8
- component 'bootstrap-jumbotron-theme'
8
+ component 'bootstrap_jumbotron_theme'
9
9
 
10
10
  # For testing user
11
11
  component 'fields'
12
12
 
13
13
  # For testing
14
- component 'user-templates'
14
+ component 'user_templates'
@@ -9,8 +9,8 @@ client '/yield', action: 'yield'
9
9
  client '/todos', controller: 'todos'
10
10
 
11
11
  # Signup/login routes
12
- client '/signup', controller: 'user-templates', action: 'signup'
13
- client '/login', controller: 'user-templates', action: 'login'
12
+ client '/signup', component: 'user_templates', controller: 'signup'
13
+ client '/login', component: 'user_templates', controller: 'login'
14
14
 
15
15
  # HTTP endpoints
16
16
  get '/simple_http', controller: 'simple_http', action: 'index'
@@ -1,53 +1,55 @@
1
- class MainController < Volt::ModelController
2
- model :page
1
+ module Main
2
+ class MainController < Volt::ModelController
3
+ model :page
3
4
 
4
- def index
5
- a = {}
6
- a[{}] = 5
7
- end
5
+ def index
6
+ a = {}
7
+ a[{}] = 5
8
+ end
8
9
 
9
- def flash_notice
10
- flash._notices << 'A notice message'
11
- end
10
+ def flash_notice
11
+ flash._notices << 'A notice message'
12
+ end
12
13
 
13
- def flash_success
14
- flash._successes << 'A success message'
15
- end
14
+ def flash_success
15
+ flash._successes << 'A success message'
16
+ end
16
17
 
17
- def flash_warning
18
- flash._warnings << 'A warning message'
19
- end
18
+ def flash_warning
19
+ flash._warnings << 'A warning message'
20
+ end
20
21
 
21
- def flash_error
22
- flash._errors << 'An error message'
23
- end
22
+ def flash_error
23
+ flash._errors << 'An error message'
24
+ end
24
25
 
25
- def cookie_test
26
- self.model = page._new_cookie!.buffer
27
- end
26
+ def cookie_test
27
+ self.model = page._new_cookie!.buffer
28
+ end
28
29
 
29
- def add_cookie
30
- cookies.send(:"_#{_name.to_s}=", _value)
30
+ def add_cookie
31
+ cookies.send(:"_#{_name.to_s}=", _value)
31
32
 
32
- self.model = page._new_cookie!.buffer
33
- end
33
+ self.model = page._new_cookie!.buffer
34
+ end
34
35
 
35
- def content_string
36
- 'content'
37
- end
36
+ def content_string
37
+ 'content'
38
+ end
38
39
 
39
- private
40
+ private
40
41
 
41
- # the main template contains a #template binding that shows another
42
- # template. This is the path to that template. It may change based
43
- # on the params._controller and params._action values.
44
- def main_path
45
- params._controller.or('main') + '/' + params._action.or('index')
46
- end
42
+ # the main template contains a #template binding that shows another
43
+ # template. This is the path to that template. It may change based
44
+ # on the params._controller and params._action values.
45
+ def main_path
46
+ "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
47
+ end
47
48
 
48
- # Determine if the current nav component is the active one by looking
49
- # at the first part of the url against the href attribute.
50
- def active_tab?
51
- url.path.split('/')[1] == attrs.href.split('/')[1]
49
+ # Determine if the current nav component is the active one by looking
50
+ # at the first part of the url against the href attribute.
51
+ def active_tab?
52
+ url.path.split('/')[1] == attrs.href.split('/')[1]
53
+ end
52
54
  end
53
- end
55
+ end
@@ -1,15 +1,17 @@
1
- class SimpleHttpController < Volt::HttpController
2
- def index
3
- render text: 'this is just some text'
4
- end
1
+ module Main
2
+ class SimpleHttpController < Volt::HttpController
3
+ def index
4
+ render text: 'this is just some text'
5
+ end
5
6
 
6
- def show
7
- render text: "You had me at #{store._simple_http_tests.first._name}"
8
- end
7
+ def show
8
+ render text: "You had me at #{store._simple_http_tests.first._name}"
9
+ end
9
10
 
10
- def upload
11
- uploaded = params[:file][:tempfile]
12
- File.open('tmp/uploaded_file', 'wb') { |f| f.write(uploaded.read) }
13
- render text: 'Thanks for uploading'
11
+ def upload
12
+ uploaded = params[:file][:tempfile]
13
+ File.open('tmp/uploaded_file', 'wb') { |f| f.write(uploaded.read) }
14
+ render text: 'Thanks for uploading'
15
+ end
14
16
  end
15
- end
17
+ end
@@ -1,16 +1,18 @@
1
- class TodosController < Volt::ModelController
2
- model :page
1
+ module Main
2
+ class TodosController < Volt::ModelController
3
+ model :page
3
4
 
4
- def add_todo
5
- _todos << { name: _new_todo }
6
- self._new_todo = ''
7
- end
5
+ def add_todo
6
+ _todos << { name: _new_todo }
7
+ self._new_todo = ''
8
+ end
8
9
 
9
- def remove_todo(todo)
10
- _todos.delete(todo)
11
- end
10
+ def remove_todo(todo)
11
+ _todos.delete(todo)
12
+ end
12
13
 
13
- def completed
14
- _todos.count(&:_completed)
14
+ def completed
15
+ _todos.count(&:_completed)
16
+ end
15
17
  end
16
- end
18
+ end
@@ -1,22 +1,24 @@
1
- class UploadController < Volt::ModelController
2
- model :page
1
+ module Main
2
+ class UploadController < Volt::ModelController
3
+ model :page
3
4
 
4
- def index
5
- # Nothing to setup here
6
- end
5
+ def index
6
+ # Nothing to setup here
7
+ end
7
8
 
8
- def upload
9
- `form_data = new FormData();
10
- form_data.append("file", $('#file')[0].files[0]);
11
- $.ajax({
12
- url: '/simple_http/upload',
13
- data: form_data,
14
- processData: false,
15
- contentType: false,
16
- type: 'POST',
17
- success: function(data){
18
- $('#status').html("successfully uploaded");
19
- }
20
- });`
9
+ def upload
10
+ `form_data = new FormData();
11
+ form_data.append("file", $('#file')[0].files[0]);
12
+ $.ajax({
13
+ url: '/simple_http/upload',
14
+ data: form_data,
15
+ processData: false,
16
+ contentType: false,
17
+ type: 'POST',
18
+ success: function(data){
19
+ $('#status').html("successfully uploaded");
20
+ }
21
+ });`
22
+ end
21
23
  end
22
- end
24
+ end
@@ -1,5 +1,7 @@
1
- class YieldComponentController < Volt::ModelController
2
- def content_string
3
- 'wrong'
1
+ module Main
2
+ class YieldComponentController < Volt::ModelController
3
+ def content_string
4
+ 'wrong'
5
+ end
4
6
  end
5
7
  end
@@ -12,7 +12,7 @@
12
12
  <:nav href="/cookie_test" text="Cookies" />
13
13
  <:nav href="/store" text="Store" />
14
14
  <:nav href="/yield" text="Yield" />
15
- <:user-templates:menu />
15
+ <:user_templates:menu />
16
16
  </ul>
17
17
  <h3 class="text-muted">Project name</h3>
18
18
  </div>
@@ -3,12 +3,12 @@ require 'volt/extra_core/blank'
3
3
 
4
4
  describe Object do
5
5
  it 'should add blank? to all objects' do
6
- expect(Object.new.blank?).to be_false
7
- expect(nil.blank?).to be_true
6
+ expect(Object.new.blank?).to eq(false)
7
+ expect(nil.blank?).to eq(true)
8
8
  end
9
9
 
10
10
  it 'should add present? to all objects' do
11
- expect(Object.new.present?).to be_true
12
- expect(nil.present?).to be_false
11
+ expect(Object.new.present?).to eq(true)
12
+ expect(nil.present?).to eq(false)
13
13
  end
14
14
  end
@@ -5,13 +5,11 @@ if ENV['BROWSER']
5
5
  before(:each) do
6
6
  # Clear out db
7
7
  DataStore.new.drop_database
8
- # Volt::Persistors::ArrayStore.query_pool.clear
9
8
  end
10
9
 
11
10
  after(:each) do
12
11
  # Clear out db
13
12
  DataStore.new.drop_database
14
- # Volt::Persistors::ArrayStore.query_pool.clear
15
13
  end
16
14
 
17
15
  it 'should create an account' do
@@ -1,5 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class ::TestSaveFailure < Volt::Model
4
+ validate :name, length: 5
5
+ end
6
+
3
7
  describe Volt::Buffer do
4
8
  it 'should let you pass a block that evaluates to the then of the promise' do
5
9
  buffer = the_page._items!.buffer
@@ -12,4 +16,28 @@ describe Volt::Buffer do
12
16
  expect(count).to eq(1)
13
17
  expect(result.class).to eq(Promise)
14
18
  end
19
+
20
+ if RUBY_PLATFORM != 'opal'
21
+ it 'should reject a failed save! with the errors object' do
22
+ buffer = the_page._test_save_failures.buffer
23
+
24
+ buffer._name = 'Ryan'
25
+
26
+ then_count = 0
27
+ fail_count = 0
28
+ error = nil
29
+
30
+ buffer.save!.then do
31
+ then_count += 1
32
+ end.fail do |err|
33
+ fail_count += 1
34
+ error = err
35
+ end
36
+
37
+ expect(then_count).to eq(0)
38
+ expect(fail_count).to eq(1)
39
+ expect(error.class).to eq(Volt::Errors)
40
+ expect(error).to eq({:name=>["must be at least 5 characters"]})
41
+ end
42
+ end
15
43
  end
@@ -518,10 +518,6 @@ describe Volt::Model do
518
518
  a.attributes = {first: 'Jimmy', last: 'Dean'}
519
519
  expect(a.new?).to eq(false)
520
520
  end
521
-
522
- it 'should load store models ' do
523
-
524
- end
525
521
  end
526
522
 
527
523
 
@@ -544,9 +540,5 @@ describe Volt::Model do
544
540
 
545
541
  expect(count).to eq(1)
546
542
  end
547
-
548
- it 'should skip read permissions when checking create/update' do
549
-
550
- end
551
543
  end
552
544
  end
@@ -14,7 +14,7 @@ module <%= config[:component_name].camelize %>
14
14
  # template. This is the path to that template. It may change based
15
15
  # on the params._controller and params._action values.
16
16
  def main_path
17
- params._controller.or('main') + '/' + params._action.or('index')
17
+ "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,5 @@
1
+ module <%= config[:component_module] %>
2
+ class <%= config[:http_controller_name] %> < Volt::HttpController
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module <%= config[:component_module] %>
2
+ class <%= config[:model_controller_name] %> < Volt::ModelController
3
+
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  class <%= config[:model_name] %> < Volt::Model
2
2
 
3
- end
3
+ end
@@ -7,10 +7,10 @@ gem 'volt', '<%= config[:version] %>'
7
7
  gem 'volt-bootstrap', '~> 0.0.10'
8
8
 
9
9
  # Simple theme for bootstrap, remove to theme yourself.
10
- gem 'volt-bootstrap-jumbotron-theme', '~> 0.0.5'
10
+ gem 'volt-bootstrap_jumbotron_theme', '~> 0.0.5'
11
11
 
12
12
  # User templates for login, signup, and logout menu.
13
- gem 'volt-user-templates', '~> 0.1.0'
13
+ gem 'volt-user_templates', '~> 0.1.0'
14
14
 
15
15
  # Server for MRI
16
16
  platform :mri do
@@ -5,7 +5,7 @@
5
5
  component 'bootstrap'
6
6
 
7
7
  # a default theme for the bootstrap framework
8
- component 'bootstrap-jumbotron-theme'
8
+ component 'bootstrap_jumbotron_theme'
9
9
 
10
10
  # provides templates for login, signup, and logout
11
- component 'user-templates'
11
+ component 'user_templates'
@@ -2,9 +2,9 @@
2
2
 
3
3
  client '/about', action: 'about'
4
4
 
5
- # Routes for login and signup, provided by user-templates component gem
6
- client '/signup', controller: 'user-templates', action: 'signup'
7
- client '/login', controller: 'user-templates', action: 'login'
5
+ # Routes for login and signup, provided by user_templates component gem
6
+ client '/signup', component: 'user_templates', controller: 'signup'
7
+ client '/login', component: 'user_templates', controller: 'login'
8
8
 
9
9
  # The main route, this should be last. It will match any params not
10
10
  # previously matched.
@@ -1,25 +1,27 @@
1
1
  # By default Volt generates this controller for your Main component
2
- class MainController < Volt::ModelController
3
- def index
4
- # Add code for when the index view is loaded
5
- end
2
+ module Main
3
+ class MainController < Volt::ModelController
4
+ def index
5
+ # Add code for when the index view is loaded
6
+ end
6
7
 
7
- def about
8
- # Add code for when the about view is loaded
9
- end
8
+ def about
9
+ # Add code for when the about view is loaded
10
+ end
10
11
 
11
- private
12
+ private
12
13
 
13
- # The main template contains a #template binding that shows another
14
- # template. This is the path to that template. It may change based
15
- # on the params._controller and params._action values.
16
- def main_path
17
- params._controller.or('main') + '/' + params._action.or('index')
18
- end
14
+ # The main template contains a #template binding that shows another
15
+ # template. This is the path to that template. It may change based
16
+ # on the params._component, params._controller, and params._action values.
17
+ def main_path
18
+ "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
19
+ end
19
20
 
20
- # Determine if the current nav component is the active one by looking
21
- # at the first part of the url against the href attribute.
22
- def active_tab?
23
- url.path.split('/')[1] == attrs.href.split('/')[1]
21
+ # Determine if the current nav component is the active one by looking
22
+ # at the first part of the url against the href attribute.
23
+ def active_tab?
24
+ url.path.split('/')[1] == attrs.href.split('/')[1]
25
+ end
24
26
  end
25
- end
27
+ end
@@ -7,7 +7,7 @@
7
7
  <ul class="nav nav-pills pull-right">
8
8
  <:nav href="/">Home</:nav>
9
9
  <:nav href="/about">About</:nav>
10
- <:user-templates:menu />
10
+ <:user_templates:menu />
11
11
  </ul>
12
12
  <h3 class="text-muted"><%= config[:name] %></h3>
13
13
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.27.beta7
4
+ version: 0.8.27.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
@@ -498,7 +498,6 @@ files:
498
498
  - lib/volt/extra_core/string.rb
499
499
  - lib/volt/extra_core/stringify_keys.rb
500
500
  - lib/volt/extra_core/symbol.rb
501
- - lib/volt/extra_core/true_false.rb
502
501
  - lib/volt/models.rb
503
502
  - lib/volt/models/array_model.rb
504
503
  - lib/volt/models/associations.rb
@@ -731,6 +730,8 @@ files:
731
730
  - templates/component/models/.empty_directory
732
731
  - templates/component/tasks/.empty_directory
733
732
  - templates/component/views/main/index.html.tt
733
+ - templates/controller/http_controller.rb.tt
734
+ - templates/controller/model_controller.rb.tt
734
735
  - templates/model/model.rb.tt
735
736
  - templates/newgem/Gemfile.tt
736
737
  - templates/newgem/LICENSE.txt.tt
@@ -1,44 +0,0 @@
1
- # The true?/false? predicates are convience methods since if ..reactive_value.. does
2
- # not correctly evaluate. The reason for this is that ruby currently does not allow
3
- # anything besides nil and false to be falsy.
4
-
5
- class Object
6
- def true?
7
- true
8
- end
9
-
10
- def false?
11
- false
12
- end
13
- end
14
-
15
- class FalseClass
16
- def true?
17
- false
18
- end
19
-
20
- def false?
21
- true
22
- end
23
- end
24
-
25
- class NilClass
26
- def true?
27
- false
28
- end
29
-
30
- def false?
31
- true
32
- end
33
- end
34
-
35
- # Opal only has a single class for true/false
36
- class Boolean
37
- def true?
38
- self
39
- end
40
-
41
- def false?
42
- self
43
- end
44
- end