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.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +0 -1
- data/app/volt/models/user.rb +1 -3
- data/app/volt/tasks/live_query/live_query.rb +1 -1
- data/app/volt/tasks/store_tasks.rb +4 -5
- data/app/volt/tasks/user_tasks.rb +1 -1
- data/lib/volt.rb +2 -6
- data/lib/volt/boot.rb +0 -2
- data/lib/volt/cli.rb +0 -1
- data/lib/volt/cli/asset_compile.rb +0 -2
- data/lib/volt/cli/console.rb +3 -4
- data/lib/volt/cli/generate.rb +3 -4
- data/lib/volt/cli/new_gem.rb +1 -3
- data/lib/volt/controllers/actions.rb +6 -6
- data/lib/volt/controllers/model_controller.rb +4 -8
- data/lib/volt/data_stores/base.rb +1 -2
- data/lib/volt/data_stores/data_store.rb +2 -2
- data/lib/volt/data_stores/mongo_driver.rb +3 -3
- data/lib/volt/extra_core/hash.rb +1 -1
- data/lib/volt/extra_core/inflector/inflections.rb +10 -2
- data/lib/volt/extra_core/logger.rb +1 -4
- data/lib/volt/extra_core/object.rb +1 -1
- data/lib/volt/models.rb +2 -4
- data/lib/volt/models/array_model.rb +3 -7
- data/lib/volt/models/associations.rb +5 -4
- data/lib/volt/models/buffer.rb +1 -2
- data/lib/volt/models/dirty.rb +2 -2
- data/lib/volt/models/errors.rb +1 -1
- data/lib/volt/models/listener_tracker.rb +1 -3
- data/lib/volt/models/model.rb +16 -20
- data/lib/volt/models/permissions.rb +15 -18
- data/lib/volt/models/persistors/array_store.rb +5 -10
- data/lib/volt/models/persistors/cookies.rb +2 -2
- data/lib/volt/models/persistors/model_store.rb +3 -9
- data/lib/volt/models/persistors/params.rb +1 -3
- data/lib/volt/models/persistors/query/normalizer.rb +3 -3
- data/lib/volt/models/persistors/query/query_listener.rb +1 -1
- data/lib/volt/models/persistors/store.rb +2 -2
- data/lib/volt/models/state_helpers.rb +1 -1
- data/lib/volt/models/state_manager.rb +4 -4
- data/lib/volt/models/url.rb +2 -6
- data/lib/volt/models/validations.rb +8 -13
- data/lib/volt/models/validators/numericality_validator.rb +2 -6
- data/lib/volt/models/validators/unique_validator.rb +1 -1
- data/lib/volt/models/validators/user_validation.rb +0 -1
- data/lib/volt/page/bindings/attribute_binding.rb +9 -19
- data/lib/volt/page/bindings/content_binding.rb +1 -1
- data/lib/volt/page/bindings/each_binding.rb +3 -4
- data/lib/volt/page/bindings/if_binding.rb +1 -1
- data/lib/volt/page/bindings/view_binding.rb +15 -22
- data/lib/volt/page/bindings/view_binding/controller_handler.rb +5 -7
- data/lib/volt/page/bindings/view_binding/view_lookup_for_path.rb +1 -2
- data/lib/volt/page/bindings/yield_binding.rb +1 -2
- data/lib/volt/page/channel.rb +3 -3
- data/lib/volt/page/document_events.rb +1 -1
- data/lib/volt/page/page.rb +3 -6
- data/lib/volt/page/path_string_renderer.rb +7 -8
- data/lib/volt/page/sub_context.rb +1 -3
- data/lib/volt/page/targets/binding_document/component_node.rb +1 -3
- data/lib/volt/page/tasks.rb +3 -5
- data/lib/volt/reactive/class_eventable.rb +2 -2
- data/lib/volt/reactive/computation.rb +7 -7
- data/lib/volt/reactive/dependency.rb +1 -1
- data/lib/volt/reactive/eventable.rb +3 -4
- data/lib/volt/reactive/reactive_accessors.rb +0 -1
- data/lib/volt/reactive/reactive_array.rb +4 -12
- data/lib/volt/router/routes.rb +1 -3
- data/lib/volt/server.rb +6 -6
- data/lib/volt/server/component_handler.rb +1 -1
- data/lib/volt/server/component_templates.rb +2 -2
- data/lib/volt/server/forking_server.rb +6 -9
- data/lib/volt/server/html_parser/component_view_scope.rb +2 -2
- data/lib/volt/server/html_parser/each_scope.rb +1 -1
- data/lib/volt/server/html_parser/sandlebars_parser.rb +2 -6
- data/lib/volt/server/html_parser/view_handler.rb +1 -1
- data/lib/volt/server/html_parser/view_parser.rb +1 -1
- data/lib/volt/server/html_parser/view_scope.rb +2 -4
- data/lib/volt/server/rack/asset_files.rb +1 -3
- data/lib/volt/server/rack/component_paths.rb +1 -3
- data/lib/volt/server/rack/http_request.rb +1 -3
- data/lib/volt/server/rack/http_resource.rb +1 -3
- data/lib/volt/server/rack/http_response_renderer.rb +2 -2
- data/lib/volt/server/rack/index_files.rb +1 -1
- data/lib/volt/server/rack/opal_files.rb +1 -3
- data/lib/volt/server/socket_connection_handler.rb +1 -3
- data/lib/volt/server/websocket/rack_server_adaptor.rb +1 -1
- data/lib/volt/server/websocket/websocket_handler.rb +1 -2
- data/lib/volt/spec/capybara.rb +1 -1
- data/lib/volt/spec/setup.rb +18 -12
- data/lib/volt/tasks/dispatcher.rb +1 -2
- data/lib/volt/tasks/task_handler.rb +1 -3
- data/lib/volt/utils/boolean_patch.rb +1 -1
- data/lib/volt/utils/event_counter.rb +2 -2
- data/lib/volt/utils/generic_pool.rb +5 -9
- data/lib/volt/utils/logging/task_argument_filterer.rb +4 -4
- data/lib/volt/utils/logging/task_logger.rb +2 -2
- data/lib/volt/utils/modes.rb +2 -2
- data/lib/volt/utils/promise_patch.rb +1 -2
- data/lib/volt/utils/read_write_lock.rb +21 -23
- data/lib/volt/utils/tilt_patch.rb +1 -1
- data/lib/volt/utils/timers.rb +3 -7
- data/lib/volt/utils/volt_user_error.rb +1 -1
- data/lib/volt/version.rb +2 -2
- data/lib/volt/volt/app.rb +4 -6
- data/lib/volt/volt/users.rb +4 -3
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +5 -5
- data/spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb +1 -1
- data/spec/controllers/actions_spec.rb +9 -10
- data/spec/controllers/model_controller_spec.rb +1 -1
- data/spec/extra_core/blank_spec.rb +2 -2
- data/spec/extra_core/logger_spec.rb +6 -8
- data/spec/extra_core/string_transformations_spec.rb +3 -3
- data/spec/integration/bindings_spec.rb +3 -9
- data/spec/integration/first_last_spec.rb +1 -1
- data/spec/integration/missing_spec.rb +1 -2
- data/spec/integration/raw_html_binding.rb +2 -2
- data/spec/integration/todos_spec.rb +22 -0
- data/spec/integration/yield_spec.rb +2 -2
- data/spec/models/associations_spec.rb +4 -4
- data/spec/models/buffer_spec.rb +2 -2
- data/spec/models/dirty_spec.rb +10 -11
- data/spec/models/model_spec.rb +19 -13
- data/spec/models/model_state_spec.rb +1 -1
- data/spec/models/permissions_spec.rb +8 -12
- data/spec/models/url_spec.rb +1 -1
- data/spec/models/user_spec.rb +17 -10
- data/spec/models/user_validation_spec.rb +2 -3
- data/spec/models/validations_spec.rb +7 -10
- data/spec/models/validators/email_validator_spec.rb +5 -7
- data/spec/models/validators/format_validator_spec.rb +21 -3
- data/spec/models/validators/length_validator_spec.rb +12 -22
- data/spec/models/validators/shared_examples_for_validators.rb +1 -1
- data/spec/models/validators/unique_validator_spec.rb +1 -2
- data/spec/page/bindings/content_binding_spec.rb +1 -1
- data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +0 -1
- data/spec/page/path_string_renderer_spec.rb +2 -3
- data/spec/reactive/class_eventable_spec.rb +1 -1
- data/spec/reactive/computation_spec.rb +30 -31
- data/spec/reactive/reactive_hash_spec.rb +1 -1
- data/spec/router/routes_spec.rb +14 -16
- data/spec/server/html_parser/view_handler_spec.rb +1 -1
- data/spec/server/html_parser/view_parser_spec.rb +0 -1
- data/spec/server/rack/quite_common_logger_spec.rb +3 -3
- data/spec/tasks/dispatcher_spec.rb +1 -1
- data/spec/tasks/query_tracker_spec.rb +1 -3
- data/spec/utils/task_argument_filtererer_spec.rb +5 -5
- data/templates/project/app/main/controllers/main_controller.rb +1 -1
- data/templates/project/spec/app/main/models/sample_model_spec.rb +2 -2
- data/templates/project/spec/app/main/tasks/sample_task_spec.rb +2 -2
- data/volt.gemspec +3 -5
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c57d60611600de9f132243981453e12dd14d7d2b
|
4
|
+
data.tar.gz: e14a1bbead84d93c8cd03bcac1bdaf54d315d2ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/app/volt/models/user.rb
CHANGED
@@ -50,10 +50,9 @@ class StoreTasks < Volt::Task
|
|
50
50
|
# who sent the update.
|
51
51
|
#
|
52
52
|
# return another promise
|
53
|
-
|
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
|
-
|
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
|
-
|
86
|
+
fail "Could not find #{id} in #{collection}"
|
88
87
|
end
|
89
88
|
end
|
90
89
|
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
data/lib/volt/cli.rb
CHANGED
@@ -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)
|
data/lib/volt/cli/console.rb
CHANGED
@@ -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
|
15
|
+
output.puts '' if output.tty?
|
16
16
|
break
|
17
17
|
else
|
18
|
-
output.puts
|
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
|
|
data/lib/volt/cli/generate.rb
CHANGED
@@ -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(
|
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.
|
98
|
+
File.exist?(dir + name.downcase.underscore.singularize + '.rb')
|
100
99
|
end
|
101
100
|
end
|
data/lib/volt/cli/new_gem.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
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
|
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=
|
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'
|
@@ -10,10 +10,10 @@ module Volt
|
|
10
10
|
driver_name = database_name.camelize + 'Driver'
|
11
11
|
|
12
12
|
begin
|
13
|
-
driver =
|
13
|
+
driver = const_get(driver_name)
|
14
14
|
@driver = MongoDriver.new
|
15
15
|
rescue NameError => e
|
16
|
-
|
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
|
-
|
39
|
+
nil
|
40
40
|
end
|
41
41
|
|
42
42
|
def query(collection, query)
|
43
|
-
allowed_methods =
|
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
|
-
|
51
|
+
fail "`#{method_name}` is not part of a valid query"
|
52
52
|
end
|
53
53
|
|
54
54
|
cursor = cursor.send(method_name, *args)
|
data/lib/volt/extra_core/hash.rb
CHANGED
@@ -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
|
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
|
187
|
+
@plurals = []
|
188
|
+
@singulars = []
|
189
|
+
@uncountables = []
|
190
|
+
@humans = []
|
183
191
|
else
|
184
192
|
instance_variable_set "@#{scope}", []
|
185
193
|
end
|