volt 0.9.1 → 0.9.2

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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Rakefile +0 -1
  5. data/app/volt/models/user.rb +1 -3
  6. data/app/volt/tasks/live_query/live_query.rb +1 -1
  7. data/app/volt/tasks/store_tasks.rb +4 -5
  8. data/app/volt/tasks/user_tasks.rb +1 -1
  9. data/lib/volt.rb +2 -6
  10. data/lib/volt/boot.rb +0 -2
  11. data/lib/volt/cli.rb +0 -1
  12. data/lib/volt/cli/asset_compile.rb +0 -2
  13. data/lib/volt/cli/console.rb +3 -4
  14. data/lib/volt/cli/generate.rb +3 -4
  15. data/lib/volt/cli/new_gem.rb +1 -3
  16. data/lib/volt/controllers/actions.rb +6 -6
  17. data/lib/volt/controllers/model_controller.rb +4 -8
  18. data/lib/volt/data_stores/base.rb +1 -2
  19. data/lib/volt/data_stores/data_store.rb +2 -2
  20. data/lib/volt/data_stores/mongo_driver.rb +3 -3
  21. data/lib/volt/extra_core/hash.rb +1 -1
  22. data/lib/volt/extra_core/inflector/inflections.rb +10 -2
  23. data/lib/volt/extra_core/logger.rb +1 -4
  24. data/lib/volt/extra_core/object.rb +1 -1
  25. data/lib/volt/models.rb +2 -4
  26. data/lib/volt/models/array_model.rb +3 -7
  27. data/lib/volt/models/associations.rb +5 -4
  28. data/lib/volt/models/buffer.rb +1 -2
  29. data/lib/volt/models/dirty.rb +2 -2
  30. data/lib/volt/models/errors.rb +1 -1
  31. data/lib/volt/models/listener_tracker.rb +1 -3
  32. data/lib/volt/models/model.rb +16 -20
  33. data/lib/volt/models/permissions.rb +15 -18
  34. data/lib/volt/models/persistors/array_store.rb +5 -10
  35. data/lib/volt/models/persistors/cookies.rb +2 -2
  36. data/lib/volt/models/persistors/model_store.rb +3 -9
  37. data/lib/volt/models/persistors/params.rb +1 -3
  38. data/lib/volt/models/persistors/query/normalizer.rb +3 -3
  39. data/lib/volt/models/persistors/query/query_listener.rb +1 -1
  40. data/lib/volt/models/persistors/store.rb +2 -2
  41. data/lib/volt/models/state_helpers.rb +1 -1
  42. data/lib/volt/models/state_manager.rb +4 -4
  43. data/lib/volt/models/url.rb +2 -6
  44. data/lib/volt/models/validations.rb +8 -13
  45. data/lib/volt/models/validators/numericality_validator.rb +2 -6
  46. data/lib/volt/models/validators/unique_validator.rb +1 -1
  47. data/lib/volt/models/validators/user_validation.rb +0 -1
  48. data/lib/volt/page/bindings/attribute_binding.rb +9 -19
  49. data/lib/volt/page/bindings/content_binding.rb +1 -1
  50. data/lib/volt/page/bindings/each_binding.rb +3 -4
  51. data/lib/volt/page/bindings/if_binding.rb +1 -1
  52. data/lib/volt/page/bindings/view_binding.rb +15 -22
  53. data/lib/volt/page/bindings/view_binding/controller_handler.rb +5 -7
  54. data/lib/volt/page/bindings/view_binding/view_lookup_for_path.rb +1 -2
  55. data/lib/volt/page/bindings/yield_binding.rb +1 -2
  56. data/lib/volt/page/channel.rb +3 -3
  57. data/lib/volt/page/document_events.rb +1 -1
  58. data/lib/volt/page/page.rb +3 -6
  59. data/lib/volt/page/path_string_renderer.rb +7 -8
  60. data/lib/volt/page/sub_context.rb +1 -3
  61. data/lib/volt/page/targets/binding_document/component_node.rb +1 -3
  62. data/lib/volt/page/tasks.rb +3 -5
  63. data/lib/volt/reactive/class_eventable.rb +2 -2
  64. data/lib/volt/reactive/computation.rb +7 -7
  65. data/lib/volt/reactive/dependency.rb +1 -1
  66. data/lib/volt/reactive/eventable.rb +3 -4
  67. data/lib/volt/reactive/reactive_accessors.rb +0 -1
  68. data/lib/volt/reactive/reactive_array.rb +4 -12
  69. data/lib/volt/router/routes.rb +1 -3
  70. data/lib/volt/server.rb +6 -6
  71. data/lib/volt/server/component_handler.rb +1 -1
  72. data/lib/volt/server/component_templates.rb +2 -2
  73. data/lib/volt/server/forking_server.rb +6 -9
  74. data/lib/volt/server/html_parser/component_view_scope.rb +2 -2
  75. data/lib/volt/server/html_parser/each_scope.rb +1 -1
  76. data/lib/volt/server/html_parser/sandlebars_parser.rb +2 -6
  77. data/lib/volt/server/html_parser/view_handler.rb +1 -1
  78. data/lib/volt/server/html_parser/view_parser.rb +1 -1
  79. data/lib/volt/server/html_parser/view_scope.rb +2 -4
  80. data/lib/volt/server/rack/asset_files.rb +1 -3
  81. data/lib/volt/server/rack/component_paths.rb +1 -3
  82. data/lib/volt/server/rack/http_request.rb +1 -3
  83. data/lib/volt/server/rack/http_resource.rb +1 -3
  84. data/lib/volt/server/rack/http_response_renderer.rb +2 -2
  85. data/lib/volt/server/rack/index_files.rb +1 -1
  86. data/lib/volt/server/rack/opal_files.rb +1 -3
  87. data/lib/volt/server/socket_connection_handler.rb +1 -3
  88. data/lib/volt/server/websocket/rack_server_adaptor.rb +1 -1
  89. data/lib/volt/server/websocket/websocket_handler.rb +1 -2
  90. data/lib/volt/spec/capybara.rb +1 -1
  91. data/lib/volt/spec/setup.rb +18 -12
  92. data/lib/volt/tasks/dispatcher.rb +1 -2
  93. data/lib/volt/tasks/task_handler.rb +1 -3
  94. data/lib/volt/utils/boolean_patch.rb +1 -1
  95. data/lib/volt/utils/event_counter.rb +2 -2
  96. data/lib/volt/utils/generic_pool.rb +5 -9
  97. data/lib/volt/utils/logging/task_argument_filterer.rb +4 -4
  98. data/lib/volt/utils/logging/task_logger.rb +2 -2
  99. data/lib/volt/utils/modes.rb +2 -2
  100. data/lib/volt/utils/promise_patch.rb +1 -2
  101. data/lib/volt/utils/read_write_lock.rb +21 -23
  102. data/lib/volt/utils/tilt_patch.rb +1 -1
  103. data/lib/volt/utils/timers.rb +3 -7
  104. data/lib/volt/utils/volt_user_error.rb +1 -1
  105. data/lib/volt/version.rb +2 -2
  106. data/lib/volt/volt/app.rb +4 -6
  107. data/lib/volt/volt/users.rb +4 -3
  108. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +1 -1
  109. data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
  110. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +5 -5
  111. data/spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb +1 -1
  112. data/spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb +1 -1
  113. data/spec/controllers/actions_spec.rb +9 -10
  114. data/spec/controllers/model_controller_spec.rb +1 -1
  115. data/spec/extra_core/blank_spec.rb +2 -2
  116. data/spec/extra_core/logger_spec.rb +6 -8
  117. data/spec/extra_core/string_transformations_spec.rb +3 -3
  118. data/spec/integration/bindings_spec.rb +3 -9
  119. data/spec/integration/first_last_spec.rb +1 -1
  120. data/spec/integration/missing_spec.rb +1 -2
  121. data/spec/integration/raw_html_binding.rb +2 -2
  122. data/spec/integration/todos_spec.rb +22 -0
  123. data/spec/integration/yield_spec.rb +2 -2
  124. data/spec/models/associations_spec.rb +4 -4
  125. data/spec/models/buffer_spec.rb +2 -2
  126. data/spec/models/dirty_spec.rb +10 -11
  127. data/spec/models/model_spec.rb +19 -13
  128. data/spec/models/model_state_spec.rb +1 -1
  129. data/spec/models/permissions_spec.rb +8 -12
  130. data/spec/models/url_spec.rb +1 -1
  131. data/spec/models/user_spec.rb +17 -10
  132. data/spec/models/user_validation_spec.rb +2 -3
  133. data/spec/models/validations_spec.rb +7 -10
  134. data/spec/models/validators/email_validator_spec.rb +5 -7
  135. data/spec/models/validators/format_validator_spec.rb +21 -3
  136. data/spec/models/validators/length_validator_spec.rb +12 -22
  137. data/spec/models/validators/shared_examples_for_validators.rb +1 -1
  138. data/spec/models/validators/unique_validator_spec.rb +1 -2
  139. data/spec/page/bindings/content_binding_spec.rb +1 -1
  140. data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +0 -1
  141. data/spec/page/path_string_renderer_spec.rb +2 -3
  142. data/spec/reactive/class_eventable_spec.rb +1 -1
  143. data/spec/reactive/computation_spec.rb +30 -31
  144. data/spec/reactive/reactive_hash_spec.rb +1 -1
  145. data/spec/router/routes_spec.rb +14 -16
  146. data/spec/server/html_parser/view_handler_spec.rb +1 -1
  147. data/spec/server/html_parser/view_parser_spec.rb +0 -1
  148. data/spec/server/rack/quite_common_logger_spec.rb +3 -3
  149. data/spec/tasks/dispatcher_spec.rb +1 -1
  150. data/spec/tasks/query_tracker_spec.rb +1 -3
  151. data/spec/utils/task_argument_filtererer_spec.rb +5 -5
  152. data/templates/project/app/main/controllers/main_controller.rb +1 -1
  153. data/templates/project/spec/app/main/models/sample_model_spec.rb +2 -2
  154. data/templates/project/spec/app/main/tasks/sample_task_spec.rb +2 -2
  155. data/volt.gemspec +3 -5
  156. metadata +19 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 089a3893d8b7611b25bad4b8fcbdedd84be6579b
4
- data.tar.gz: 066dc262d293f911faafb6bafddedd065546484c
3
+ metadata.gz: c57d60611600de9f132243981453e12dd14d7d2b
4
+ data.tar.gz: e14a1bbead84d93c8cd03bcac1bdaf54d315d2ff
5
5
  SHA512:
6
- metadata.gz: 5c7a7190b94631d3cc27baf85d11881dbe242cedf01b180ee187d1253b92fa3ea5567e32d32302016935be383c360fbdd69380dbec88aa00ed82d4d362b65a21
7
- data.tar.gz: 0d099ac0fbf72d705c9c9e9be7cf3396c6737723da156cc5dc8f26d77b2bec36739c59b5f164fe537edf48a0a1823a760ae7028aa59e0a3af28721873deeb3c9
6
+ metadata.gz: 4fc5686a5121b45d4186acd8c59e0b46e45ad9796752a1bc0b915234fe864cb90bc8f6ad58954e4f757516a744e07cfe3da20d22e7283b49c12aab7bf59b12f6
7
+ data.tar.gz: 5b1b6ac243e17387a564b42be1341d378282883766a7e3002f21faa2396bd6c2006b53333ad39936194d5c84ba6ca29fb34c9dd63043f241251d5727481691b7
data/.rubocop.yml CHANGED
@@ -1,3 +1,54 @@
1
+ AllCops:
2
+ Include:
3
+ - "**/*.gemspec"
4
+ - "**/*.podspec"
5
+ - "**/*.jbuilder"
6
+ - "**/*.rake"
7
+ - "**/*.opal"
8
+ - "**/Gemfile"
9
+ - "**/Rakefile"
10
+ - "**/Capfile"
11
+ - "**/Guardfile"
12
+ - "**/Podfile"
13
+ - "**/Thorfile"
14
+ - "**/Vagrantfile"
15
+ - "**/Berksfile"
16
+ - "**/Cheffile"
17
+ - "**/Vagabondfile"
18
+ Exclude:
19
+ - "vendor/**/*"
20
+ - "db/schema.rb"
21
+ RunRailsCops: false
22
+ DisplayCopNames: false
23
+ StyleGuideCopsOnly: false
24
+
25
+
26
+ Style/AccessModifierIndentation:
27
+ Description: Check indentation of private/protected visibility modifiers.
28
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
29
+ Enabled: true
30
+ EnforcedStyle: indent
31
+ SupportedStyles:
32
+ - outdent
33
+ - indent
34
+
35
+ # Metrics/LineLength:
36
+ # Description: Limit lines to 80 characters.
37
+ # StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
38
+ # Enabled: false
39
+ # Max: 80
40
+ # AllowURI: true
41
+ # URISchemes:
42
+ # - http
43
+ # - https
44
+ # Style/GlobalVars:
45
+ # Description: Do not introduce global variables.
46
+ # StyleGuide: https://github.com/bbatsov/ruby-style-guide#instance-vars
47
+ # Enabled: false
48
+ # AllowedVariables: []
49
+
50
+ # ^ From hound
51
+
1
52
  Style/Documentation:
2
53
  Enabled: false
3
54
 
@@ -12,3 +63,8 @@ UnderscorePrefixedVariableName:
12
63
 
13
64
  UnusedBlockArgument:
14
65
  Enabled: false
66
+
67
+ Lint/UselessAssignment:
68
+ Description: Checks for useless assignment to a local variable.
69
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
70
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.2
4
+ ### Changed
5
+ - We released 0.9.1 with a bug for destroy (doh!). Specs added and bug fixed.
6
+
3
7
  ## 0.9.1
4
8
  ### Added
5
9
  - Mailer! - volt now includes the volt-mailer gem out of the box. (you can remove it if you don't need/want it). See https://github.com/voltrb/volt-mailer for more info.
data/Rakefile CHANGED
@@ -19,7 +19,6 @@ Opal::RSpec::RakeTask.new('opal:rspec') do |s|
19
19
  s.append_path('app')
20
20
  end
21
21
 
22
-
23
22
  task default: [:test]
24
23
 
25
24
  require 'rspec/core/rake_task'
@@ -1,6 +1,4 @@
1
- unless RUBY_PLATFORM == 'opal'
2
- require 'bcrypt'
3
- end
1
+ require 'bcrypt' unless RUBY_PLATFORM == 'opal'
4
2
 
5
3
  module Volt
6
4
  class User < Model
@@ -129,6 +129,6 @@ class LiveQuery
129
129
  end
130
130
 
131
131
  def inspect
132
- "<#{self.class.to_s} #{@collection}: #{@query.inspect}>"
132
+ "<#{self.class} #{@collection}: #{@query.inspect}>"
133
133
  end
134
134
  end
@@ -50,10 +50,9 @@ class StoreTasks < Volt::Task
50
50
  # who sent the update.
51
51
  #
52
52
  # return another promise
53
- return promise.then do |model|
53
+ promise.then do |model|
54
54
  Thread.current['in_channel'] = @channel
55
55
  save_promise = model.save!.then do |result|
56
-
57
56
  next nil
58
57
  end.fail do |err|
59
58
  # An error object, convert to hash
@@ -77,14 +76,14 @@ class StoreTasks < Volt::Task
77
76
  query.fetch_first do |model|
78
77
  if model
79
78
  if model.can_delete?
80
- db.delete('_id' => id)
79
+ db.delete(collection, '_id' => id)
81
80
  else
82
- raise "Permissions did not allow #{collection} #{id} to be deleted."
81
+ fail "Permissions did not allow #{collection} #{id} to be deleted."
83
82
  end
84
83
 
85
84
  QueryTasks.live_query_pool.updated_collection(collection, @channel)
86
85
  else
87
- raise "Could not find #{id} in #{collection}"
86
+ fail "Could not find #{id} in #{collection}"
88
87
  end
89
88
  end
90
89
  end
@@ -34,4 +34,4 @@ class UserTasks < Volt::Task
34
34
  def salty_user_id(user_id)
35
35
  "#{Volt.config.app_secret}::#{user_id}"
36
36
  end
37
- end
37
+ end
data/lib/volt.rb CHANGED
@@ -7,9 +7,7 @@ require 'volt/utils/volt_user_error'
7
7
  require 'volt/utils/boolean_patch'
8
8
 
9
9
  require 'volt/config'
10
- unless RUBY_PLATFORM == 'opal'
11
- require 'volt/data_stores/data_store'
12
- end
10
+ require 'volt/data_stores/data_store' unless RUBY_PLATFORM == 'opal'
13
11
  require 'volt/volt/users'
14
12
 
15
13
  module Volt
@@ -23,9 +21,7 @@ module Volt
23
21
 
24
22
  class << self
25
23
  def root
26
- if self.client?
27
- raise "Volt.root can not be called from the client."
28
- end
24
+ fail 'Volt.root can not be called from the client.' if self.client?
29
25
  @root ||= File.expand_path(Dir.pwd)
30
26
  end
31
27
 
data/lib/volt/boot.rb CHANGED
@@ -21,6 +21,4 @@ module Volt
21
21
  # Boot the app
22
22
  App.new(app_path)
23
23
  end
24
-
25
-
26
24
  end
data/lib/volt/cli.rb CHANGED
@@ -72,7 +72,6 @@ module Volt
72
72
  server.timeout = 0
73
73
  end
74
74
  end
75
-
76
75
  end
77
76
 
78
77
  desc 'runner FILEPATH', 'Runs a ruby file at FILEPATH in the volt app'
@@ -19,7 +19,6 @@ module Volt
19
19
  require 'volt/volt/core'
20
20
  require 'volt/boot'
21
21
 
22
-
23
22
  @root_path ||= Dir.pwd
24
23
  Volt.root = @root_path
25
24
 
@@ -31,7 +30,6 @@ module Volt
31
30
  require 'volt/server/rack/index_files'
32
31
  require 'volt/server/component_handler'
33
32
 
34
-
35
33
  @app_path = File.expand_path(File.join(@root_path, 'app'))
36
34
 
37
35
  @component_paths = ComponentPaths.new(@root_path)
@@ -9,13 +9,13 @@ class Pry
9
9
  loop do
10
10
  case val = read
11
11
  when :control_c
12
- output.puts ""
12
+ output.puts ''
13
13
  pry.reset_eval_string
14
14
  when :no_more_input
15
- output.puts "" if output.tty?
15
+ output.puts '' if output.tty?
16
16
  break
17
17
  else
18
- output.puts "" if val.nil? && output.tty?
18
+ output.puts '' if val.nil? && output.tty?
19
19
  return pry.exit_value unless pry.eval(val)
20
20
  end
21
21
 
@@ -39,7 +39,6 @@ module Volt
39
39
  end
40
40
  end
41
41
 
42
-
43
42
  def self.start
44
43
  require 'pry'
45
44
 
@@ -22,7 +22,6 @@ class Generate < Thor
22
22
  directory('component_specs', component_spec_folder)
23
23
  end
24
24
 
25
-
26
25
  desc 'gem GEM', 'Creates a component gem where you can share a component'
27
26
  method_option :bin, type: :boolean, default: false, aliases: '-b', banner: 'Generate a binary for your library.'
28
27
  method_option :test, type: :string, lazy_default: 'rspec', aliases: '-t', banner: "Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported."
@@ -35,7 +34,7 @@ class Generate < Thor
35
34
  require 'volt/cli/new_gem'
36
35
 
37
36
  if name =~ /[-]/
38
- Volt.logger.error("Gem names should use underscores for their names. Currently volt only supports a single namespace for a component.")
37
+ Volt.logger.error('Gem names should use underscores for their names. Currently volt only supports a single namespace for a component.')
39
38
  return
40
39
  end
41
40
 
@@ -68,7 +67,7 @@ class Generate < Thor
68
67
  spec_file = Dir.pwd + "/spec/app/#{component.underscore}/integration/#{name.underscore.pluralize}_spec.rb"
69
68
 
70
69
  template('controller/model_controller.rb.tt', output_file, component_module: component.camelize, model_controller_name: controller_name.camelize)
71
- template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore.pluralize )
70
+ template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore.pluralize)
72
71
  end
73
72
 
74
73
  desc 'task NAME COMPONENT', 'Creates a task named NAME in the app folder of the component named COMPONENT.'
@@ -96,6 +95,6 @@ class Generate < Thor
96
95
 
97
96
  def controller_exists?(name, component = 'main')
98
97
  dir = Dir.pwd + "/app/#{component}/controllers/"
99
- File.exists?(dir + name.downcase.underscore.singularize + '.rb')
98
+ File.exist?(dir + name.downcase.underscore.singularize + '.rb')
100
99
  end
101
100
  end
@@ -56,9 +56,7 @@ class NewGem
56
56
  end
57
57
 
58
58
  def copy_options
59
- if @options[:bin]
60
- copy('newgem/bin/newgem.tt', "bin/#{@name}")
61
- end
59
+ copy('newgem/bin/newgem.tt', "bin/#{@name}") if @options[:bin]
62
60
  case @options[:test]
63
61
  when 'rspec'
64
62
  copy('newgem/rspec.tt', '.rspec')
@@ -12,7 +12,7 @@ module Volt
12
12
  module Actions
13
13
  # StopChainException inherits from Exception directly so it will not be handled by a
14
14
  # default rescue.
15
- class StopChainException < Exception ; end
15
+ class StopChainException < Exception; end
16
16
 
17
17
  module ClassMethods
18
18
  # Takes a list of action groups (as symbols). An action group is typically used for before/after, but
@@ -29,7 +29,7 @@ module Volt
29
29
  # Add the block in place of the symbol
30
30
  args.unshift(block) if block
31
31
 
32
- raise "No callback symbol or block provided" unless args[0]
32
+ fail 'No callback symbol or block provided' unless args[0]
33
33
 
34
34
  callbacks = send(callbacks_var_name)
35
35
 
@@ -75,7 +75,7 @@ module Volt
75
75
  # raise an exception under the hood which will stop the chain and evaluation
76
76
  # from where stop_chain is called.
77
77
  def stop_chain
78
- raise StopChainException
78
+ fail StopChainException
79
79
  end
80
80
 
81
81
  def self.included(base)
@@ -83,6 +83,7 @@ module Volt
83
83
  end
84
84
 
85
85
  private
86
+
86
87
  # TODO: currently we filter during the call, we could maybe improve performance
87
88
  # here by storing by action and having an all category as well.
88
89
  def filter_actions_by_only_exclude(callbacks, action)
@@ -94,8 +95,7 @@ module Volt
94
95
  # If no only, include it
95
96
  true
96
97
  end
97
- end.map {|v| v[0] }
98
+ end.map { |v| v[0] }
98
99
  end
99
-
100
100
  end
101
- end
101
+ end
@@ -50,7 +50,7 @@ module Volt
50
50
 
51
51
  val.then do |result|
52
52
  # Only assign if nothing else has been assigned since we started the resolve
53
- self.model = result if self.last_promise == val
53
+ self.model = result if last_promise == val
54
54
  end.fail do |err|
55
55
  Volt.logger.error("Unable to resolve promise assigned to model on #{inspect}")
56
56
  end
@@ -80,9 +80,7 @@ module Volt
80
80
  model = self.current_model
81
81
 
82
82
  # If the model is a proc, call it now
83
- if model && model.is_a?(Proc)
84
- model = model.call
85
- end
83
+ model = model.call if model && model.is_a?(Proc)
86
84
 
87
85
  model
88
86
  end
@@ -106,9 +104,7 @@ module Volt
106
104
  self.attrs = args[0]
107
105
 
108
106
  # If a model attribute is passed in, we assign it directly
109
- if attrs.respond_to?(:model)
110
- self.model = attrs.locals[:model]
111
- end
107
+ self.model = attrs.locals[:model] if attrs.respond_to?(:model)
112
108
  end
113
109
  end
114
110
 
@@ -191,7 +187,7 @@ module Volt
191
187
  end
192
188
  end
193
189
 
194
- def require_login(message="You must login to access this area.")
190
+ def require_login(message = 'You must login to access this area.')
195
191
  unless Volt.current_user_id
196
192
  flash._notices << message
197
193
  go '/login'
@@ -1,7 +1,6 @@
1
1
  module Volt
2
2
  class DataStore
3
3
  class Base
4
-
5
4
  end
6
5
  end
7
- end
6
+ end
@@ -10,10 +10,10 @@ module Volt
10
10
  driver_name = database_name.camelize + 'Driver'
11
11
 
12
12
  begin
13
- driver = self.const_get(driver_name)
13
+ driver = const_get(driver_name)
14
14
  @driver = MongoDriver.new
15
15
  rescue NameError => e
16
- fail "#{database_name} is not a supported database"
16
+ raise "#{database_name} is not a supported database"
17
17
  end
18
18
  end
19
19
  end
@@ -36,11 +36,11 @@ module Volt
36
36
  end
37
37
  end
38
38
 
39
- return nil
39
+ nil
40
40
  end
41
41
 
42
42
  def query(collection, query)
43
- allowed_methods = ['find', 'skip', 'limit']
43
+ allowed_methods = %w(find skip limit)
44
44
 
45
45
  cursor = @db[collection]
46
46
 
@@ -48,7 +48,7 @@ module Volt
48
48
  method_name, *args = query_part
49
49
 
50
50
  unless allowed_methods.include?(method_name.to_s)
51
- raise "`#{method_name}` is not part of a valid query"
51
+ fail "`#{method_name}` is not part of a valid query"
52
52
  end
53
53
 
54
54
  cursor = cursor.send(method_name, *args)
@@ -23,4 +23,4 @@
23
23
  # key.is_a?(String) ? key : key.to_sym
24
24
  # end
25
25
  # end
26
- # end
26
+ # end
@@ -28,7 +28,12 @@ module Volt
28
28
  attr_reader :plurals, :singulars, :uncountables, :humans, :acronyms, :acronym_regex
29
29
 
30
30
  def initialize
31
- @plurals, @singulars, @uncountables, @humans, @acronyms, @acronym_regex = [], [], [], [], {}, /(?=a)b/
31
+ @plurals = []
32
+ @singulars = []
33
+ @uncountables = []
34
+ @humans = []
35
+ @acronyms = {}
36
+ @acronym_regex = /(?=a)b/
32
37
  end
33
38
 
34
39
  # Private, for the test suite.
@@ -179,7 +184,10 @@ module Volt
179
184
  def clear(scope = :all)
180
185
  case scope
181
186
  when :all
182
- @plurals, @singulars, @uncountables, @humans = [], [], [], []
187
+ @plurals = []
188
+ @singulars = []
189
+ @uncountables = []
190
+ @humans = []
183
191
  else
184
192
  instance_variable_set "@#{scope}", []
185
193
  end