volt 0.8.15 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/Guardfile +2 -3
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/tasks/live_query/data_store.rb +7 -7
- data/app/volt/tasks/live_query/live_query.rb +7 -9
- data/app/volt/tasks/live_query/live_query_pool.rb +13 -12
- data/app/volt/tasks/live_query/query_tracker.rb +4 -5
- data/app/volt/tasks/query_tasks.rb +9 -11
- data/app/volt/tasks/store_tasks.rb +4 -4
- data/app/volt/tasks/user_tasks.rb +1 -1
- data/bin/volt +2 -2
- data/lib/volt.rb +3 -7
- data/lib/volt/assets/test.rb +1 -2
- data/lib/volt/benchmark/benchmark.rb +3 -3
- data/lib/volt/boot.rb +1 -1
- data/lib/volt/cli.rb +18 -18
- data/lib/volt/cli/asset_compile.rb +8 -10
- data/lib/volt/cli/generate.rb +9 -11
- data/lib/volt/cli/new_gem.rb +51 -51
- data/lib/volt/config.rb +2 -3
- data/lib/volt/console.rb +1 -1
- data/lib/volt/controllers/model_controller.rb +6 -6
- data/lib/volt/data_stores/data_store.rb +1 -1
- data/lib/volt/data_stores/mongo_driver.rb +1 -1
- data/lib/volt/extra_core/array.rb +2 -2
- data/lib/volt/extra_core/blank.rb +1 -2
- data/lib/volt/extra_core/extra_core.rb +1 -1
- data/lib/volt/extra_core/inflector/methods.rb +0 -1
- data/lib/volt/extra_core/logger.rb +13 -7
- data/lib/volt/extra_core/numeric.rb +1 -1
- data/lib/volt/extra_core/string.rb +7 -7
- data/lib/volt/extra_core/stringify_keys.rb +5 -5
- data/lib/volt/models.rb +2 -2
- data/lib/volt/models/array_model.rb +18 -19
- data/lib/volt/models/cursor.rb +0 -1
- data/lib/volt/models/model.rb +17 -35
- data/lib/volt/models/model_hash_behaviour.rb +0 -2
- data/lib/volt/models/model_state.rb +1 -1
- data/lib/volt/models/model_wrapper.rb +1 -1
- data/lib/volt/models/persistors/array_store.rb +26 -13
- data/lib/volt/models/persistors/base.rb +1 -1
- data/lib/volt/models/persistors/flash.rb +2 -2
- data/lib/volt/models/persistors/local_store.rb +2 -3
- data/lib/volt/models/persistors/model_store.rb +7 -6
- data/lib/volt/models/persistors/params.rb +2 -2
- data/lib/volt/models/persistors/query/query_listener.rb +2 -0
- data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
- data/lib/volt/models/persistors/store.rb +1 -2
- data/lib/volt/models/persistors/store_state.rb +2 -3
- data/lib/volt/models/url.rb +17 -16
- data/lib/volt/models/validations.rb +11 -14
- data/lib/volt/models/validators/length_validator.rb +3 -3
- data/lib/volt/models/validators/presence_validator.rb +2 -2
- data/lib/volt/page/bindings/attribute_binding.rb +2 -3
- data/lib/volt/page/bindings/base_binding.rb +1 -1
- data/lib/volt/page/bindings/each_binding.rb +8 -9
- data/lib/volt/page/bindings/event_binding.rb +2 -3
- data/lib/volt/page/bindings/template_binding.rb +8 -7
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +2 -1
- data/lib/volt/page/channel.rb +10 -10
- data/lib/volt/page/channel_stub.rb +1 -1
- data/lib/volt/page/document.rb +0 -1
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/page.rb +26 -19
- data/lib/volt/page/string_template_renderer.rb +2 -2
- data/lib/volt/page/sub_context.rb +10 -4
- data/lib/volt/page/targets/attribute_section.rb +1 -1
- data/lib/volt/page/targets/attribute_target.rb +1 -2
- data/lib/volt/page/targets/base_section.rb +4 -4
- data/lib/volt/page/targets/binding_document/base_node.rb +0 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +4 -5
- data/lib/volt/page/targets/dom_section.rb +21 -22
- data/lib/volt/page/targets/dom_target.rb +1 -1
- data/lib/volt/page/targets/dom_template.rb +11 -12
- data/lib/volt/page/targets/helpers/comment_searchers.rb +7 -8
- data/lib/volt/page/tasks.rb +0 -1
- data/lib/volt/page/template_renderer.rb +1 -1
- data/lib/volt/page/url_tracker.rb +3 -3
- data/lib/volt/reactive/computation.rb +5 -11
- data/lib/volt/reactive/dependency.rb +1 -3
- data/lib/volt/reactive/eventable.rb +17 -4
- data/lib/volt/reactive/hash_dependency.rb +1 -0
- data/lib/volt/reactive/reactive_accessors.rb +0 -1
- data/lib/volt/reactive/reactive_array.rb +20 -25
- data/lib/volt/reactive/reactive_hash.rb +3 -3
- data/lib/volt/router/routes.rb +11 -13
- data/lib/volt/server.rb +17 -17
- data/lib/volt/server/component_handler.rb +2 -2
- data/lib/volt/server/component_templates.rb +8 -8
- data/lib/volt/server/html_parser/attribute_scope.rb +9 -10
- data/lib/volt/server/html_parser/if_view_scope.rb +2 -2
- data/lib/volt/server/html_parser/sandlebars_parser.rb +14 -14
- data/lib/volt/server/html_parser/textarea_scope.rb +1 -2
- 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 +10 -10
- data/lib/volt/server/rack/asset_files.rb +15 -16
- data/lib/volt/server/rack/component_code.rb +2 -2
- data/lib/volt/server/rack/component_html_renderer.rb +0 -1
- data/lib/volt/server/rack/component_paths.rb +13 -10
- data/lib/volt/server/rack/index_files.rb +4 -4
- data/lib/volt/server/rack/opal_files.rb +4 -5
- data/lib/volt/server/rack/source_map_server.rb +3 -3
- data/lib/volt/server/socket_connection_handler.rb +3 -4
- data/lib/volt/server/socket_connection_handler_stub.rb +1 -1
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/store/mongo.rb +2 -2
- data/lib/volt/tasks/task_handler.rb +3 -3
- data/lib/volt/utils/generic_counting_pool.rb +2 -2
- data/lib/volt/utils/generic_pool.rb +7 -8
- data/lib/volt/utils/local_storage.rb +4 -4
- data/lib/volt/volt/environment.rb +1 -1
- data/spec/apps/file_loading/app/shared/config/dependencies.rb +1 -1
- data/spec/apps/kitchen_sink/Gemfile +0 -2
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +5 -5
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +7 -6
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +3 -4
- data/spec/controllers/reactive_accessors_spec.rb +4 -4
- data/spec/extra_core/inflector_spec.rb +1 -1
- data/spec/extra_core/string_transformation_test_cases.rb +23 -24
- data/spec/extra_core/string_transformations_spec.rb +11 -12
- data/spec/integration/bindings_spec.rb +15 -15
- data/spec/integration/list_spec.rb +12 -13
- data/spec/integration/templates_spec.rb +3 -3
- data/spec/models/model_spec.rb +74 -80
- data/spec/models/persistors/params_spec.rb +2 -2
- data/spec/models/persistors/store_spec.rb +4 -4
- data/spec/models/validations_spec.rb +14 -23
- data/spec/page/bindings/content_binding_spec.rb +7 -8
- data/spec/page/bindings/template_binding_spec.rb +22 -24
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +3 -3
- data/spec/reactive/reactive_array_spec.rb +12 -12
- data/spec/router/routes_spec.rb +45 -48
- data/spec/server/html_parser/sandlebars_parser_spec.rb +42 -42
- data/spec/server/html_parser/view_parser_spec.rb +132 -153
- data/spec/server/rack/asset_files_spec.rb +9 -8
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/server/rack/rack_requests_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/live_query_spec.rb +4 -5
- data/spec/tasks/query_tasks.rb +2 -4
- data/spec/tasks/query_tracker_spec.rb +29 -29
- data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
- data/spec/utils/generic_counting_pool_spec.rb +4 -4
- data/spec/utils/generic_pool_spec.rb +12 -12
- data/templates/component/config/routes.rb +2 -2
- data/templates/component/controllers/main_controller.rb +7 -6
- data/templates/newgem/app/newgem/config/dependencies.rb +1 -1
- data/templates/newgem/app/newgem/config/routes.rb +1 -1
- data/templates/project/app/main/config/routes.rb +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +7 -6
- data/templates/project/spec/sample_spec.rb +2 -2
- data/volt.gemspec +32 -33
- metadata +3 -4
- data/lib/volt/extra_core/log.rb +0 -56
- data/lib/volt/extra_core/try.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f2cebeff308d55c2552eba413e158fc6a128a5
|
4
|
+
data.tar.gz: b801ee31880a6926dcb402da887c9aaa957ba578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46369ca33511b29eee4fc83d5790155cfacceab89c16a69dafedc4c3fcd2b048c5ed7c72d704a98d1f5d9d533243920ccebb1807061c1f53512aee8fd3d1ca8
|
7
|
+
data.tar.gz: 17fee69bdedea9ea2f9349c9b13d999e5f07cb9689c4cd8fc6ecacb261bb7a3528236bab9d2a31adf5227f2fe956947e9d0dc0aeac9eca58abf4ef13547bdd44
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## Unreleased
|
2
|
+
### Added
|
3
|
+
- Change changelog format to match: http://keepachangelog.com/
|
4
|
+
- Added rubocop config and ran rubocop on repo, lots of changes.
|
5
|
+
- Added .limit and .skip to cursors
|
6
|
+
- Changed: ```attrs``` now return nil for attributes that weren't passed in.
|
7
|
+
|
8
|
+
# 0.8.15 - Oct 18, 2014
|
9
|
+
|
10
|
+
- MAJOR CHANGE: everything volt related now is under the Volt module. The only change apps need to think about is inheriting from ```Volt::ModelController``` and ```Volt::Model``` Also, config.ru needs to use ```Volt::Server``` instead of ```Server```.
|
11
|
+
|
1
12
|
# 0.8.10 - Oct 12, 2014
|
2
13
|
- url.query, url.fragment, url.path all update reactively now.
|
3
14
|
- MAJOR CHANGE: Previously all tables and fields were created with _'s as their name prefixes. The underscores have been removed from everywhere. The only place you use underscores is when you want to access fields without creating setters and getters. Now when you do: ```model._name = 'Something'```, your setting the ```name``` attribute on the model. When you do: ```model._name```, your fetching the ```name``` attribute. If you insert a hash into a collection, you no longer use underscores:
|
data/Gemfile
CHANGED
@@ -39,7 +39,7 @@ group :development do
|
|
39
39
|
# Simple theme for bootstrap, remove to theme yourself.
|
40
40
|
gem 'volt-bootstrap-jumbotron-theme'
|
41
41
|
|
42
|
-
|
42
|
+
gem 'rubocop', require: false
|
43
43
|
# gem 'guard', '2.0.1' # bug in current guard
|
44
44
|
# gem 'guard-rspec'
|
45
45
|
# gem 'opal-rspec', '0.3.0.beta2'#, git: 'https://github.com/adambeynon/opal-rspec.git'
|
data/Guardfile
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
guard :rspec, cmd: 'bundle exec rspec' do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
|
-
watch(%r{^lib/volt/(.+)\.rb$}) { |m| puts
|
7
|
-
watch('spec/spec_helper.rb') {
|
6
|
+
watch(%r{^lib/volt/(.+)\.rb$}) { |m| puts 'RUN AGAIN'; "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
8
8
|
end
|
9
|
-
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
4
|
Bundler.require(:development)
|
5
5
|
|
6
6
|
require 'opal'
|
@@ -10,7 +10,6 @@ Opal.append_path(File.expand_path('../lib', __FILE__))
|
|
10
10
|
|
11
11
|
require 'opal/rspec/rake_task'
|
12
12
|
|
13
|
-
|
14
13
|
task :docs do
|
15
14
|
`bundle exec yardoc 'lib/**/*.rb' - Readme.md docs/*`
|
16
15
|
# require 'yard'
|
@@ -22,8 +21,6 @@ task :docs do
|
|
22
21
|
# end
|
23
22
|
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
24
|
Opal::RSpec::RakeTask.new
|
28
25
|
|
29
26
|
task default: [:test]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.16
|
@@ -9,13 +9,13 @@ class DataStore
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def query(collection, query)
|
12
|
-
|
13
|
-
query
|
14
|
-
if key =~ /_id$/
|
15
|
-
# query[key] = BSON::ObjectId(query[key])
|
16
|
-
end
|
17
|
-
end
|
12
|
+
# Extract query parts
|
13
|
+
query, skip, limit = query
|
18
14
|
|
19
|
-
db[collection].find(query)
|
15
|
+
cursor = db[collection].find(query)
|
16
|
+
cursor = cursor.skip(skip) if skip
|
17
|
+
cursor = cursor.limit(limit) if limit
|
18
|
+
|
19
|
+
return cursor.to_a
|
20
20
|
end
|
21
21
|
end
|
@@ -18,39 +18,38 @@ class LiveQuery
|
|
18
18
|
run
|
19
19
|
end
|
20
20
|
|
21
|
-
def run(skip_channel=nil)
|
21
|
+
def run(skip_channel = nil)
|
22
22
|
@query_tracker.run(skip_channel)
|
23
23
|
end
|
24
24
|
|
25
25
|
def notify_removed(ids, skip_channel)
|
26
26
|
# puts "Removed: #{ids.inspect}"
|
27
27
|
notify! do |channel|
|
28
|
-
channel.send_message(
|
28
|
+
channel.send_message('removed', nil, @collection, @query, ids)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def notify_added(index, data, skip_channel)
|
33
33
|
# puts "Added: #{index} - #{data.inspect}"
|
34
34
|
notify! do |channel|
|
35
|
-
channel.send_message(
|
35
|
+
channel.send_message('added', nil, @collection, @query, index, data)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def notify_moved(id, new_position, skip_channel)
|
40
40
|
# puts "Moved: #{id}, #{new_position}"
|
41
41
|
notify! do |channel|
|
42
|
-
channel.send_message(
|
42
|
+
channel.send_message('moved', nil, @collection, @query, id, new_position)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def notify_changed(id, data, skip_channel)
|
47
47
|
# puts "Changed: #{id}, #{data}"
|
48
48
|
notify!(skip_channel) do |channel|
|
49
|
-
channel.send_message(
|
49
|
+
channel.send_message('changed', nil, @collection, @query, id, data)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
53
|
# return the query results the first time a channel connects
|
55
54
|
def initial_data
|
56
55
|
@query_tracker.results.map.with_index do |data, index|
|
@@ -73,18 +72,17 @@ class LiveQuery
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
def notify!(skip_channel=nil, only_channel=nil)
|
75
|
+
def notify!(skip_channel = nil, only_channel = nil)
|
77
76
|
if only_channel
|
78
77
|
channels = [only_channel]
|
79
78
|
else
|
80
79
|
channels = @channels
|
81
80
|
end
|
82
81
|
|
83
|
-
channels = channels.reject {|c| c == skip_channel }
|
82
|
+
channels = channels.reject { |c| c == skip_channel }
|
84
83
|
|
85
84
|
channels.each do |channel|
|
86
85
|
yield(channel)
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
90
88
|
end
|
@@ -10,7 +10,7 @@ class LiveQueryPool < Volt::GenericPool
|
|
10
10
|
def lookup(collection, query)
|
11
11
|
query = normalize_query(query)
|
12
12
|
|
13
|
-
|
13
|
+
super(collection, query)
|
14
14
|
end
|
15
15
|
|
16
16
|
def updated_collection(collection, skip_channel)
|
@@ -20,16 +20,17 @@ class LiveQueryPool < Volt::GenericPool
|
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
|
-
# Creates the live query if it doesn't exist, and stores it so it
|
24
|
-
# can be found later.
|
25
|
-
def create(collection, query={})
|
26
|
-
# If not already setup, create a new one for this collection/query
|
27
|
-
return LiveQuery.new(self, @data_store, collection, query)
|
28
|
-
end
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
# Creates the live query if it doesn't exist, and stores it so it
|
25
|
+
# can be found later.
|
26
|
+
def create(collection, query = {})
|
27
|
+
# If not already setup, create a new one for this collection/query
|
28
|
+
LiveQuery.new(self, @data_store, collection, query)
|
29
|
+
end
|
30
|
+
|
31
|
+
def normalize_query(query)
|
32
|
+
# TODO: add something to sort query properties so the queries are
|
33
|
+
# always compared the same.
|
34
|
+
query
|
35
|
+
end
|
35
36
|
end
|
@@ -13,7 +13,7 @@ class QueryTracker
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Runs the query, stores the results and updates the current_ids
|
16
|
-
def run(skip_channel=nil)
|
16
|
+
def run(skip_channel = nil)
|
17
17
|
@previous_results = @results
|
18
18
|
@previous_results_hash = @results_hash
|
19
19
|
@previous_ids = @current_ids
|
@@ -22,8 +22,8 @@ class QueryTracker
|
|
22
22
|
@results = @data_store.query(@live_query.collection, @live_query.query)
|
23
23
|
|
24
24
|
# Update the current_ids
|
25
|
-
@current_ids = @results.map {|r| r['_id'] }
|
26
|
-
@results_hash = Hash[@results.map {|r| [r['_id'], r] }]
|
25
|
+
@current_ids = @results.map { |r| r['_id'] }
|
26
|
+
@results_hash = Hash[@results.map { |r| [r['_id'], r] }]
|
27
27
|
|
28
28
|
process_changes(skip_channel)
|
29
29
|
end
|
@@ -55,7 +55,7 @@ class QueryTracker
|
|
55
55
|
# have been added or moved.
|
56
56
|
def detect_added_and_moved(skip_channel)
|
57
57
|
previous_index = 0
|
58
|
-
@current_ids.each_with_index do |id,index|
|
58
|
+
@current_ids.each_with_index do |id, index|
|
59
59
|
if (cur_previous = @previous_ids[previous_index]) && cur_previous == id
|
60
60
|
# Same in both previous and new
|
61
61
|
previous_index += 1
|
@@ -91,5 +91,4 @@ class QueryTracker
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
95
94
|
end
|
@@ -10,7 +10,7 @@ class QueryTasks < Volt::TaskHandler
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# The dispatcher passes its self in
|
13
|
-
def initialize(channel, dispatcher=nil)
|
13
|
+
def initialize(channel, dispatcher = nil)
|
14
14
|
@channel = channel
|
15
15
|
@dispatcher = dispatcher
|
16
16
|
end
|
@@ -29,17 +29,17 @@ class QueryTasks < Volt::TaskHandler
|
|
29
29
|
initial_data = live_query.initial_data
|
30
30
|
rescue => exception
|
31
31
|
# Capture and pass up any exceptions
|
32
|
-
error = {:
|
32
|
+
error = { error: exception.message }
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
[initial_data, error]
|
36
36
|
end
|
37
37
|
|
38
38
|
def initial_data
|
39
39
|
data = live_query.initial_data
|
40
40
|
data[:_id] = data[:_id].to_s
|
41
41
|
|
42
|
-
|
42
|
+
data
|
43
43
|
end
|
44
44
|
|
45
45
|
# Remove a listening channel, the LiveQuery will automatically remove
|
@@ -49,7 +49,6 @@ class QueryTasks < Volt::TaskHandler
|
|
49
49
|
live_query.remove_channel(@channel)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
52
|
# Removes a channel from all associated live queries
|
54
53
|
def close!
|
55
54
|
live_queries = @@channel_live_queries[@channel]
|
@@ -64,11 +63,10 @@ class QueryTasks < Volt::TaskHandler
|
|
64
63
|
end
|
65
64
|
|
66
65
|
private
|
67
|
-
# Tracks that this channel will be notified from the live query.
|
68
|
-
def track_channel_in_live_query(live_query)
|
69
|
-
@@channel_live_queries[@channel] ||= []
|
70
|
-
@@channel_live_queries[@channel] << live_query
|
71
|
-
end
|
72
|
-
|
73
66
|
|
67
|
+
# Tracks that this channel will be notified from the live query.
|
68
|
+
def track_channel_in_live_query(live_query)
|
69
|
+
@@channel_live_queries[@channel] ||= []
|
70
|
+
@@channel_live_queries[@channel] << live_query
|
71
|
+
end
|
74
72
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'mongo'
|
2
2
|
|
3
3
|
class StoreTasks < Volt::TaskHandler
|
4
|
-
def initialize(channel=nil, dispatcher=nil)
|
4
|
+
def initialize(channel = nil, dispatcher = nil)
|
5
5
|
@channel = channel
|
6
6
|
@dispatcher = dispatcher
|
7
7
|
end
|
@@ -26,7 +26,7 @@ class StoreTasks < Volt::TaskHandler
|
|
26
26
|
return model.to_h, model.errors
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
[data, {}]
|
30
30
|
end
|
31
31
|
|
32
32
|
def save(collection, data)
|
@@ -48,9 +48,9 @@ class StoreTasks < Volt::TaskHandler
|
|
48
48
|
# Update because the id already exists
|
49
49
|
update_values = values.dup
|
50
50
|
update_values.delete(:_id)
|
51
|
-
db[collection].update({:
|
51
|
+
db[collection].update({ _id: id }, update_values)
|
52
52
|
else
|
53
|
-
return {:
|
53
|
+
return { error: error.message }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
data/bin/volt
CHANGED
data/lib/volt.rb
CHANGED
@@ -21,9 +21,7 @@ module Volt
|
|
21
21
|
@root ||= File.expand_path(Dir.pwd)
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
@root = val
|
26
|
-
end
|
24
|
+
attr_writer :root
|
27
25
|
|
28
26
|
def server?
|
29
27
|
!!ENV['SERVER']
|
@@ -42,12 +40,10 @@ module Volt
|
|
42
40
|
end
|
43
41
|
|
44
42
|
def logger
|
45
|
-
@logger ||= Logger.new
|
43
|
+
@logger ||= Logger.new(STDOUT)
|
46
44
|
end
|
47
45
|
|
48
|
-
|
49
|
-
@logger = val
|
50
|
-
end
|
46
|
+
attr_writer :logger
|
51
47
|
|
52
48
|
def in_browser?
|
53
49
|
@in_browser
|
data/lib/volt/assets/test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'sass'
|
2
2
|
|
3
|
-
sass_engine = Sass::Engine.new(template,
|
3
|
+
sass_engine = Sass::Engine.new(template, syntax: :scss, filename: 'cool.css.scss', sourcemap: true); output =
|
4
4
|
sass_engine.render_with_sourcemap('/source_maps/')
|
5
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
if RUBY_PLATFORM == 'opal'
|
2
2
|
class Benchmark
|
3
|
-
def self.bm(iterations=1)
|
4
|
-
puts
|
3
|
+
def self.bm(iterations = 1)
|
4
|
+
puts 'BM'
|
5
5
|
|
6
6
|
times = []
|
7
7
|
total_time = nil
|
@@ -21,7 +21,7 @@ if RUBY_PLATFORM == 'opal'
|
|
21
21
|
puts "Times: #{times.inspect}"
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
result
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/volt/boot.rb
CHANGED
data/lib/volt/cli.rb
CHANGED
@@ -9,26 +9,26 @@ module Volt
|
|
9
9
|
|
10
10
|
register(Generate, 'generate', 'generate GENERATOR [args]', 'Run a generator.')
|
11
11
|
|
12
|
-
desc
|
12
|
+
desc 'new PROJECT_NAME', 'generates a new project.'
|
13
13
|
|
14
14
|
def new(name)
|
15
15
|
# Grab the current volt version
|
16
16
|
version = File.read(File.join(File.dirname(__FILE__), '../../VERSION'))
|
17
|
-
directory(
|
17
|
+
directory('project', name, version: version, name: name)
|
18
18
|
|
19
|
-
say
|
19
|
+
say 'Bundling Gems....'
|
20
20
|
`cd #{name} && bundle`
|
21
21
|
end
|
22
22
|
|
23
|
-
desc
|
23
|
+
desc 'console', 'run the console on the project in the current directory'
|
24
24
|
|
25
25
|
def console
|
26
26
|
require 'volt/console'
|
27
27
|
Console.start
|
28
28
|
end
|
29
29
|
|
30
|
-
desc
|
31
|
-
method_option :port, :
|
30
|
+
desc 'server', 'run the server on the project in the current directory'
|
31
|
+
method_option :port, type: :string, aliases: '-p', banner: 'specify which port the server should run on'
|
32
32
|
|
33
33
|
def server
|
34
34
|
if RUBY_PLATFORM == 'java'
|
@@ -42,10 +42,10 @@ module Volt
|
|
42
42
|
# If we're in a Volt project, clear the temp directory
|
43
43
|
# TODO: this is a work around for a bug when switching between
|
44
44
|
# source maps and non-source maps.
|
45
|
-
if File.
|
46
|
-
FileUtils.rm_rf(
|
45
|
+
if File.exist?('config.ru') && File.exist?('Gemfile')
|
46
|
+
FileUtils.rm_rf('tmp/.')
|
47
47
|
else
|
48
|
-
say(
|
48
|
+
say('Current folder is not a Volt project', :red)
|
49
49
|
return
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ module Volt
|
|
55
55
|
Thread.stop
|
56
56
|
else
|
57
57
|
ENV['SERVER'] = 'true'
|
58
|
-
args = ['start', '--threaded', '--max-persistent-conns', '300',
|
58
|
+
args = ['start', '--threaded', '--max-persistent-conns', '300', '--max-conns', '400']
|
59
59
|
|
60
60
|
if options[:port]
|
61
61
|
args += ['-p', options[:port].to_s]
|
@@ -65,13 +65,13 @@ module Volt
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
desc
|
69
|
-
method_option :bin, :
|
70
|
-
method_option :test, :
|
71
|
-
method_option :edit, :
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
68
|
+
desc 'gem GEM', 'Creates a component gem where you can share a component'
|
69
|
+
method_option :bin, type: :boolean, default: false, aliases: '-b', banner: 'Generate a binary for your library.'
|
70
|
+
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."
|
71
|
+
method_option :edit, type: :string, aliases: '-e',
|
72
|
+
lazy_default: [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find { |e| !e.nil? && !e.empty? },
|
73
|
+
required: false, banner: '/path/to/your/editor',
|
74
|
+
desc: 'Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)'
|
75
75
|
|
76
76
|
def gem(name)
|
77
77
|
require 'volt/cli/new_gem'
|
@@ -88,5 +88,5 @@ end
|
|
88
88
|
# Add in more features
|
89
89
|
require 'volt/cli/asset_compile'
|
90
90
|
|
91
|
-
puts "Volt #{File.read(File.join(File.dirname(__FILE__),
|
91
|
+
puts "Volt #{File.read(File.join(File.dirname(__FILE__), '../../VERSION'))}"
|
92
92
|
Volt::CLI.start(ARGV)
|