volt 0.8.15 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +2 -3
  6. data/Rakefile +1 -4
  7. data/VERSION +1 -1
  8. data/app/volt/controllers/notices_controller.rb +1 -1
  9. data/app/volt/tasks/live_query/data_store.rb +7 -7
  10. data/app/volt/tasks/live_query/live_query.rb +7 -9
  11. data/app/volt/tasks/live_query/live_query_pool.rb +13 -12
  12. data/app/volt/tasks/live_query/query_tracker.rb +4 -5
  13. data/app/volt/tasks/query_tasks.rb +9 -11
  14. data/app/volt/tasks/store_tasks.rb +4 -4
  15. data/app/volt/tasks/user_tasks.rb +1 -1
  16. data/bin/volt +2 -2
  17. data/lib/volt.rb +3 -7
  18. data/lib/volt/assets/test.rb +1 -2
  19. data/lib/volt/benchmark/benchmark.rb +3 -3
  20. data/lib/volt/boot.rb +1 -1
  21. data/lib/volt/cli.rb +18 -18
  22. data/lib/volt/cli/asset_compile.rb +8 -10
  23. data/lib/volt/cli/generate.rb +9 -11
  24. data/lib/volt/cli/new_gem.rb +51 -51
  25. data/lib/volt/config.rb +2 -3
  26. data/lib/volt/console.rb +1 -1
  27. data/lib/volt/controllers/model_controller.rb +6 -6
  28. data/lib/volt/data_stores/data_store.rb +1 -1
  29. data/lib/volt/data_stores/mongo_driver.rb +1 -1
  30. data/lib/volt/extra_core/array.rb +2 -2
  31. data/lib/volt/extra_core/blank.rb +1 -2
  32. data/lib/volt/extra_core/extra_core.rb +1 -1
  33. data/lib/volt/extra_core/inflector/methods.rb +0 -1
  34. data/lib/volt/extra_core/logger.rb +13 -7
  35. data/lib/volt/extra_core/numeric.rb +1 -1
  36. data/lib/volt/extra_core/string.rb +7 -7
  37. data/lib/volt/extra_core/stringify_keys.rb +5 -5
  38. data/lib/volt/models.rb +2 -2
  39. data/lib/volt/models/array_model.rb +18 -19
  40. data/lib/volt/models/cursor.rb +0 -1
  41. data/lib/volt/models/model.rb +17 -35
  42. data/lib/volt/models/model_hash_behaviour.rb +0 -2
  43. data/lib/volt/models/model_state.rb +1 -1
  44. data/lib/volt/models/model_wrapper.rb +1 -1
  45. data/lib/volt/models/persistors/array_store.rb +26 -13
  46. data/lib/volt/models/persistors/base.rb +1 -1
  47. data/lib/volt/models/persistors/flash.rb +2 -2
  48. data/lib/volt/models/persistors/local_store.rb +2 -3
  49. data/lib/volt/models/persistors/model_store.rb +7 -6
  50. data/lib/volt/models/persistors/params.rb +2 -2
  51. data/lib/volt/models/persistors/query/query_listener.rb +2 -0
  52. data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
  53. data/lib/volt/models/persistors/store.rb +1 -2
  54. data/lib/volt/models/persistors/store_state.rb +2 -3
  55. data/lib/volt/models/url.rb +17 -16
  56. data/lib/volt/models/validations.rb +11 -14
  57. data/lib/volt/models/validators/length_validator.rb +3 -3
  58. data/lib/volt/models/validators/presence_validator.rb +2 -2
  59. data/lib/volt/page/bindings/attribute_binding.rb +2 -3
  60. data/lib/volt/page/bindings/base_binding.rb +1 -1
  61. data/lib/volt/page/bindings/each_binding.rb +8 -9
  62. data/lib/volt/page/bindings/event_binding.rb +2 -3
  63. data/lib/volt/page/bindings/template_binding.rb +8 -7
  64. data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +2 -1
  65. data/lib/volt/page/channel.rb +10 -10
  66. data/lib/volt/page/channel_stub.rb +1 -1
  67. data/lib/volt/page/document.rb +0 -1
  68. data/lib/volt/page/document_events.rb +4 -4
  69. data/lib/volt/page/page.rb +26 -19
  70. data/lib/volt/page/string_template_renderer.rb +2 -2
  71. data/lib/volt/page/sub_context.rb +10 -4
  72. data/lib/volt/page/targets/attribute_section.rb +1 -1
  73. data/lib/volt/page/targets/attribute_target.rb +1 -2
  74. data/lib/volt/page/targets/base_section.rb +4 -4
  75. data/lib/volt/page/targets/binding_document/base_node.rb +0 -1
  76. data/lib/volt/page/targets/binding_document/component_node.rb +4 -5
  77. data/lib/volt/page/targets/dom_section.rb +21 -22
  78. data/lib/volt/page/targets/dom_target.rb +1 -1
  79. data/lib/volt/page/targets/dom_template.rb +11 -12
  80. data/lib/volt/page/targets/helpers/comment_searchers.rb +7 -8
  81. data/lib/volt/page/tasks.rb +0 -1
  82. data/lib/volt/page/template_renderer.rb +1 -1
  83. data/lib/volt/page/url_tracker.rb +3 -3
  84. data/lib/volt/reactive/computation.rb +5 -11
  85. data/lib/volt/reactive/dependency.rb +1 -3
  86. data/lib/volt/reactive/eventable.rb +17 -4
  87. data/lib/volt/reactive/hash_dependency.rb +1 -0
  88. data/lib/volt/reactive/reactive_accessors.rb +0 -1
  89. data/lib/volt/reactive/reactive_array.rb +20 -25
  90. data/lib/volt/reactive/reactive_hash.rb +3 -3
  91. data/lib/volt/router/routes.rb +11 -13
  92. data/lib/volt/server.rb +17 -17
  93. data/lib/volt/server/component_handler.rb +2 -2
  94. data/lib/volt/server/component_templates.rb +8 -8
  95. data/lib/volt/server/html_parser/attribute_scope.rb +9 -10
  96. data/lib/volt/server/html_parser/if_view_scope.rb +2 -2
  97. data/lib/volt/server/html_parser/sandlebars_parser.rb +14 -14
  98. data/lib/volt/server/html_parser/textarea_scope.rb +1 -2
  99. data/lib/volt/server/html_parser/view_handler.rb +1 -1
  100. data/lib/volt/server/html_parser/view_parser.rb +1 -1
  101. data/lib/volt/server/html_parser/view_scope.rb +10 -10
  102. data/lib/volt/server/rack/asset_files.rb +15 -16
  103. data/lib/volt/server/rack/component_code.rb +2 -2
  104. data/lib/volt/server/rack/component_html_renderer.rb +0 -1
  105. data/lib/volt/server/rack/component_paths.rb +13 -10
  106. data/lib/volt/server/rack/index_files.rb +4 -4
  107. data/lib/volt/server/rack/opal_files.rb +4 -5
  108. data/lib/volt/server/rack/source_map_server.rb +3 -3
  109. data/lib/volt/server/socket_connection_handler.rb +3 -4
  110. data/lib/volt/server/socket_connection_handler_stub.rb +1 -1
  111. data/lib/volt/spec/setup.rb +3 -3
  112. data/lib/volt/store/mongo.rb +2 -2
  113. data/lib/volt/tasks/task_handler.rb +3 -3
  114. data/lib/volt/utils/generic_counting_pool.rb +2 -2
  115. data/lib/volt/utils/generic_pool.rb +7 -8
  116. data/lib/volt/utils/local_storage.rb +4 -4
  117. data/lib/volt/volt/environment.rb +1 -1
  118. data/spec/apps/file_loading/app/shared/config/dependencies.rb +1 -1
  119. data/spec/apps/kitchen_sink/Gemfile +0 -2
  120. data/spec/apps/kitchen_sink/app/main/config/routes.rb +5 -5
  121. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +7 -6
  122. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +3 -4
  123. data/spec/controllers/reactive_accessors_spec.rb +4 -4
  124. data/spec/extra_core/inflector_spec.rb +1 -1
  125. data/spec/extra_core/string_transformation_test_cases.rb +23 -24
  126. data/spec/extra_core/string_transformations_spec.rb +11 -12
  127. data/spec/integration/bindings_spec.rb +15 -15
  128. data/spec/integration/list_spec.rb +12 -13
  129. data/spec/integration/templates_spec.rb +3 -3
  130. data/spec/models/model_spec.rb +74 -80
  131. data/spec/models/persistors/params_spec.rb +2 -2
  132. data/spec/models/persistors/store_spec.rb +4 -4
  133. data/spec/models/validations_spec.rb +14 -23
  134. data/spec/page/bindings/content_binding_spec.rb +7 -8
  135. data/spec/page/bindings/template_binding_spec.rb +22 -24
  136. data/spec/page/sub_context_spec.rb +2 -2
  137. data/spec/reactive/computation_spec.rb +3 -3
  138. data/spec/reactive/reactive_array_spec.rb +12 -12
  139. data/spec/router/routes_spec.rb +45 -48
  140. data/spec/server/html_parser/sandlebars_parser_spec.rb +42 -42
  141. data/spec/server/html_parser/view_parser_spec.rb +132 -153
  142. data/spec/server/rack/asset_files_spec.rb +9 -8
  143. data/spec/server/rack/component_paths_spec.rb +5 -5
  144. data/spec/server/rack/rack_requests_spec.rb +3 -3
  145. data/spec/spec_helper.rb +1 -1
  146. data/spec/tasks/live_query_spec.rb +4 -5
  147. data/spec/tasks/query_tasks.rb +2 -4
  148. data/spec/tasks/query_tracker_spec.rb +29 -29
  149. data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
  150. data/spec/utils/generic_counting_pool_spec.rb +4 -4
  151. data/spec/utils/generic_pool_spec.rb +12 -12
  152. data/templates/component/config/routes.rb +2 -2
  153. data/templates/component/controllers/main_controller.rb +7 -6
  154. data/templates/newgem/app/newgem/config/dependencies.rb +1 -1
  155. data/templates/newgem/app/newgem/config/routes.rb +1 -1
  156. data/templates/project/app/main/config/routes.rb +2 -2
  157. data/templates/project/app/main/controllers/main_controller.rb +7 -6
  158. data/templates/project/spec/sample_spec.rb +2 -2
  159. data/volt.gemspec +32 -33
  160. metadata +3 -4
  161. data/lib/volt/extra_core/log.rb +0 -56
  162. data/lib/volt/extra_core/try.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6635ba6a1792a3170956c91f7125be7b5c0cd268
4
- data.tar.gz: e63ae431f7bf79aa12be2ed75dc499e580979eb7
3
+ metadata.gz: e6f2cebeff308d55c2552eba413e158fc6a128a5
4
+ data.tar.gz: b801ee31880a6926dcb402da887c9aaa957ba578
5
5
  SHA512:
6
- metadata.gz: 3ccaaf9013222c95f10537b9712e8b8d5a8ecb3d705c20e533c54985c4420ffd09ec71a6cc51bc49e19ce55e525b788745d6be13b2e1cb1ce05a00f87499836f
7
- data.tar.gz: 19ecd0ca6771454732889f8336c34cb24803caa5ea8ebc5cdc058557e6ffdaa618cbb4cca56c69069f89b35ce0c7de6468338f0ccc338d69cb75448400a31785
6
+ metadata.gz: c46369ca33511b29eee4fc83d5790155cfacceab89c16a69dafedc4c3fcd2b048c5ed7c72d704a98d1f5d9d533243920ccebb1807061c1f53512aee8fd3d1ca8
7
+ data.tar.gz: 17fee69bdedea9ea2f9349c9b13d999e5f07cb9689c4cd8fc6ecacb261bb7a3528236bab9d2a31adf5227f2fe956947e9d0dc0aeac9eca58abf4ef13547bdd44
@@ -0,0 +1,11 @@
1
+ UselessAssignment:
2
+ Enabled: false
3
+
4
+ UnusedMethodArgument:
5
+ Enabled: false
6
+
7
+ UnderscorePrefixedVariableName:
8
+ Enabled: false
9
+
10
+ UnusedBlockArgument:
11
+ Enabled: false
@@ -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 "RUN AGAIN" ; "spec/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
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 "bundler/gem_tasks"
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.15
1
+ 0.8.16
@@ -3,7 +3,7 @@ module Volt
3
3
  model :page
4
4
 
5
5
  def hey
6
- "yep"
6
+ 'yep'
7
7
  end
8
8
 
9
9
  def page
@@ -9,13 +9,13 @@ class DataStore
9
9
  end
10
10
 
11
11
  def query(collection, query)
12
- query = query.dup
13
- query.keys.each do |key|
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).to_a
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("removed", nil, @collection, @query, ids)
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("added", nil, @collection, @query, index, data)
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("moved", nil, @collection, @query, id, new_position)
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("changed", nil, @collection, @query, id, data)
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
- return super(collection, query)
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
- def normalize_query(query)
31
- # TODO: add something to sort query properties so the queries are
32
- # always compared the same.
33
- return query
34
- end
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 = {:error => exception.message}
32
+ error = { error: exception.message }
33
33
  end
34
34
 
35
- return [initial_data, error]
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
- return data
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
- return data, {}
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({:_id => id}, update_values)
51
+ db[collection].update({ _id: id }, update_values)
52
52
  else
53
- return {:error => error.message}
53
+ return { error: error.message }
54
54
  end
55
55
  end
56
56
 
@@ -1,6 +1,6 @@
1
1
  class UserTasks < Volt::TaskHandler
2
2
  # Login a user, takes a username and password
3
3
  def create_user(username, password)
4
- $page.store._users << {email: username, password: password}
4
+ $page.store._users << { email: username, password: password }
5
5
  end
6
6
  end
data/bin/volt CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
4
- require 'volt/cli'
3
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
4
+ require 'volt/cli'
@@ -21,9 +21,7 @@ module Volt
21
21
  @root ||= File.expand_path(Dir.pwd)
22
22
  end
23
23
 
24
- def root=(val)
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
- def logger=(val)
49
- @logger = val
50
- end
46
+ attr_writer :logger
51
47
 
52
48
  def in_browser?
53
49
  @in_browser
@@ -1,5 +1,4 @@
1
1
  require 'sass'
2
2
 
3
- sass_engine = Sass::Engine.new(template, {syntax: :scss, filename: 'cool.css.scss', sourcemap: true}) ; output =
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 "BM"
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
- return result
24
+ result
25
25
  end
26
26
  end
27
27
  end
@@ -18,6 +18,6 @@ module Volt
18
18
  component_paths = ComponentPaths.new(app_path)
19
19
  component_paths.require_in_components
20
20
 
21
- return component_paths
21
+ component_paths
22
22
  end
23
23
  end
@@ -9,26 +9,26 @@ module Volt
9
9
 
10
10
  register(Generate, 'generate', 'generate GENERATOR [args]', 'Run a generator.')
11
11
 
12
- desc "new PROJECT_NAME", "generates a new project."
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("project", name, {version: version, name: name})
17
+ directory('project', name, version: version, name: name)
18
18
 
19
- say "Bundling Gems...."
19
+ say 'Bundling Gems....'
20
20
  `cd #{name} && bundle`
21
21
  end
22
22
 
23
- desc "console", "run the console on the project in the current directory"
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 "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'
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.exists?("config.ru") && File.exists?("Gemfile")
46
- FileUtils.rm_rf("tmp/.")
45
+ if File.exist?('config.ru') && File.exist?('Gemfile')
46
+ FileUtils.rm_rf('tmp/.')
47
47
  else
48
- say("Current folder is not a Volt project", :red)
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', "--max-conns", "400"]
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 "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)"
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__), "../../VERSION"))}"
91
+ puts "Volt #{File.read(File.join(File.dirname(__FILE__), '../../VERSION'))}"
92
92
  Volt::CLI.start(ARGV)