volt 0.8.14 → 0.8.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Readme.md +8 -2
  4. data/VERSION +1 -1
  5. data/app/volt/controllers/notices_controller.rb +1 -1
  6. data/app/volt/models/user.rb +2 -2
  7. data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
  8. data/app/volt/tasks/query_tasks.rb +1 -1
  9. data/app/volt/tasks/store_tasks.rb +1 -1
  10. data/app/volt/tasks/user_tasks.rb +2 -2
  11. data/lib/volt/boot.rb +2 -2
  12. data/lib/volt/cli/asset_compile.rb +31 -27
  13. data/lib/volt/cli.rb +64 -65
  14. data/lib/volt/config.rb +25 -23
  15. data/lib/volt/console.rb +17 -16
  16. data/lib/volt/controllers/model_controller.rb +82 -80
  17. data/lib/volt/data_stores/data_store.rb +2 -2
  18. data/lib/volt/data_stores/mongo_driver.rb +2 -2
  19. data/lib/volt/extra_core/inflections.rb +2 -2
  20. data/lib/volt/extra_core/inflector/inflections.rb +185 -183
  21. data/lib/volt/extra_core/inflector/methods.rb +50 -48
  22. data/lib/volt/extra_core/string.rb +2 -2
  23. data/lib/volt/models/array_model.rb +93 -92
  24. data/lib/volt/models/cursor.rb +3 -2
  25. data/lib/volt/models/model.rb +248 -251
  26. data/lib/volt/models/model_hash_behaviour.rb +44 -44
  27. data/lib/volt/models/model_helpers.rb +38 -36
  28. data/lib/volt/models/model_state.rb +16 -17
  29. data/lib/volt/models/model_wrapper.rb +25 -24
  30. data/lib/volt/models/persistors/array_store.rb +145 -143
  31. data/lib/volt/models/persistors/base.rb +18 -16
  32. data/lib/volt/models/persistors/flash.rb +24 -22
  33. data/lib/volt/models/persistors/local_store.rb +46 -44
  34. data/lib/volt/models/persistors/model_identity_map.rb +10 -8
  35. data/lib/volt/models/persistors/model_store.rb +76 -76
  36. data/lib/volt/models/persistors/params.rb +19 -17
  37. data/lib/volt/models/persistors/query/query_listener.rb +65 -63
  38. data/lib/volt/models/persistors/query/query_listener_pool.rb +12 -10
  39. data/lib/volt/models/persistors/store.rb +28 -28
  40. data/lib/volt/models/persistors/store_factory.rb +12 -10
  41. data/lib/volt/models/persistors/store_state.rb +33 -31
  42. data/lib/volt/models/url.rb +96 -104
  43. data/lib/volt/models/validations.rb +56 -54
  44. data/lib/volt/models/validators/length_validator.rb +24 -22
  45. data/lib/volt/models/validators/presence_validator.rb +14 -12
  46. data/lib/volt/page/bindings/attribute_binding.rb +106 -106
  47. data/lib/volt/page/bindings/base_binding.rb +23 -21
  48. data/lib/volt/page/bindings/component_binding.rb +3 -1
  49. data/lib/volt/page/bindings/content_binding.rb +34 -34
  50. data/lib/volt/page/bindings/each_binding.rb +113 -113
  51. data/lib/volt/page/bindings/event_binding.rb +38 -34
  52. data/lib/volt/page/bindings/if_binding.rb +56 -54
  53. data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +24 -22
  54. data/lib/volt/page/bindings/template_binding.rb +182 -185
  55. data/lib/volt/page/channel.rb +79 -77
  56. data/lib/volt/page/channel_stub.rb +29 -27
  57. data/lib/volt/page/document.rb +6 -5
  58. data/lib/volt/page/document_events.rb +54 -52
  59. data/lib/volt/page/page.rb +139 -138
  60. data/lib/volt/page/string_template_renderer.rb +36 -36
  61. data/lib/volt/page/sub_context.rb +26 -25
  62. data/lib/volt/page/targets/attribute_section.rb +27 -25
  63. data/lib/volt/page/targets/attribute_target.rb +7 -6
  64. data/lib/volt/page/targets/base_section.rb +27 -26
  65. data/lib/volt/page/targets/binding_document/base_node.rb +3 -1
  66. data/lib/volt/page/targets/binding_document/component_node.rb +85 -82
  67. data/lib/volt/page/targets/binding_document/html_node.rb +11 -9
  68. data/lib/volt/page/targets/dom_section.rb +78 -77
  69. data/lib/volt/page/targets/dom_target.rb +8 -6
  70. data/lib/volt/page/targets/dom_template.rb +90 -88
  71. data/lib/volt/page/targets/helpers/comment_searchers.rb +51 -49
  72. data/lib/volt/page/tasks.rb +59 -57
  73. data/lib/volt/page/template_renderer.rb +17 -14
  74. data/lib/volt/page/url_tracker.rb +26 -24
  75. data/lib/volt/reactive/computation.rb +87 -88
  76. data/lib/volt/reactive/dependency.rb +30 -28
  77. data/lib/volt/reactive/eventable.rb +64 -62
  78. data/lib/volt/reactive/hash_dependency.rb +25 -23
  79. data/lib/volt/reactive/reactive_accessors.rb +34 -32
  80. data/lib/volt/reactive/reactive_array.rb +162 -162
  81. data/lib/volt/reactive/reactive_hash.rb +37 -35
  82. data/lib/volt/router/routes.rb +99 -101
  83. data/lib/volt/server/component_handler.rb +20 -21
  84. data/lib/volt/server/component_templates.rb +72 -70
  85. data/lib/volt/server/html_parser/attribute_scope.rb +109 -99
  86. data/lib/volt/server/html_parser/each_scope.rb +17 -16
  87. data/lib/volt/server/html_parser/if_view_scope.rb +51 -49
  88. data/lib/volt/server/html_parser/sandlebars_parser.rb +184 -177
  89. data/lib/volt/server/html_parser/textarea_scope.rb +24 -22
  90. data/lib/volt/server/html_parser/view_handler.rb +66 -65
  91. data/lib/volt/server/html_parser/view_parser.rb +23 -21
  92. data/lib/volt/server/html_parser/view_scope.rb +142 -141
  93. data/lib/volt/server/rack/asset_files.rb +81 -79
  94. data/lib/volt/server/rack/component_code.rb +17 -15
  95. data/lib/volt/server/rack/component_html_renderer.rb +14 -12
  96. data/lib/volt/server/rack/component_paths.rb +72 -71
  97. data/lib/volt/server/rack/index_files.rb +36 -39
  98. data/lib/volt/server/rack/opal_files.rb +43 -41
  99. data/lib/volt/server/rack/source_map_server.rb +23 -21
  100. data/lib/volt/server/socket_connection_handler.rb +46 -45
  101. data/lib/volt/server/socket_connection_handler_stub.rb +21 -19
  102. data/lib/volt/server.rb +60 -58
  103. data/lib/volt/spec/setup.rb +3 -3
  104. data/lib/volt/tasks/dispatcher.rb +24 -23
  105. data/lib/volt/tasks/task_handler.rb +35 -33
  106. data/lib/volt/utils/ejson.rb +8 -6
  107. data/lib/volt/utils/generic_counting_pool.rb +33 -31
  108. data/lib/volt/utils/generic_pool.rb +73 -70
  109. data/lib/volt/utils/local_storage.rb +42 -38
  110. data/lib/volt/volt/environment.rb +1 -1
  111. data/lib/volt.rb +44 -42
  112. data/spec/apps/kitchen_sink/app/main/assets/css/todos.css +28 -0
  113. data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
  114. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +2 -2
  115. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +17 -0
  116. data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
  117. data/spec/apps/kitchen_sink/app/main/views/todos/index.html +24 -0
  118. data/spec/apps/kitchen_sink/config.ru +1 -1
  119. data/spec/controllers/reactive_accessors_spec.rb +5 -5
  120. data/spec/extra_core/inflector_spec.rb +2 -2
  121. data/spec/integration/list_spec.rb +68 -0
  122. data/spec/models/model_spec.rb +57 -57
  123. data/spec/models/persistors/params_spec.rb +6 -6
  124. data/spec/models/persistors/store_spec.rb +7 -7
  125. data/spec/models/validations_spec.rb +3 -3
  126. data/spec/page/bindings/content_binding_spec.rb +7 -7
  127. data/spec/page/bindings/template_binding_spec.rb +4 -5
  128. data/spec/page/sub_context_spec.rb +2 -2
  129. data/spec/reactive/computation_spec.rb +10 -10
  130. data/spec/reactive/dependency_spec.rb +2 -2
  131. data/spec/reactive/eventable_spec.rb +4 -4
  132. data/spec/reactive/reactive_array_spec.rb +13 -13
  133. data/spec/router/routes_spec.rb +5 -5
  134. data/spec/server/html_parser/sandlebars_parser_spec.rb +9 -9
  135. data/spec/server/html_parser/view_parser_spec.rb +27 -27
  136. data/spec/server/rack/asset_files_spec.rb +5 -5
  137. data/spec/server/rack/component_paths_spec.rb +2 -2
  138. data/spec/tasks/live_query_spec.rb +2 -2
  139. data/spec/tasks/query_tasks.rb +1 -1
  140. data/spec/tasks/query_tracker_spec.rb +1 -1
  141. data/spec/templates/targets/binding_document/component_node_spec.rb +2 -2
  142. data/spec/utils/generic_counting_pool_spec.rb +2 -2
  143. data/spec/utils/generic_pool_spec.rb +2 -2
  144. data/templates/component/controllers/main_controller.rb +1 -1
  145. data/templates/model/model.rb.tt +2 -2
  146. data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +2 -2
  147. data/templates/project/app/main/controllers/main_controller.rb +1 -1
  148. data/templates/project/config.ru +1 -1
  149. metadata +10 -3
  150. data/app/volt/assets/js/vertxbus.js +0 -216
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ef1ff0f6f37905ecc83687721e258cd17b7da32
4
- data.tar.gz: c6cf6a5c1df1ccf476185e6abd0df31271775bfc
3
+ metadata.gz: 6635ba6a1792a3170956c91f7125be7b5c0cd268
4
+ data.tar.gz: e63ae431f7bf79aa12be2ed75dc499e580979eb7
5
5
  SHA512:
6
- metadata.gz: 19ef4e5c647e1897197d327cc27106b533b474cc5d668c41823f3833d0a8bb59f4884fa9399d740b0872725d09c0b67a88935275867f996dfdf47d4ca64c1eea
7
- data.tar.gz: cfe27008bccf191c05ae9e7dd2ab6a1d39dc52d724d09f2707ccd5c4271eb54887d5f3b4761dc0d7914b270ff8b91314385f6ee670ed5e23e00b892d4cd6bb35
6
+ metadata.gz: 3ccaaf9013222c95f10537b9712e8b8d5a8ecb3d705c20e533c54985c4420ffd09ec71a6cc51bc49e19ce55e525b788745d6be13b2e1cb1ce05a00f87499836f
7
+ data.tar.gz: 19ecd0ca6771454732889f8336c34cb24803caa5ea8ebc5cdc058557e6ffdaa618cbb4cca56c69069f89b35ce0c7de6468338f0ccc338d69cb75448400a31785
data/.gitignore CHANGED
@@ -19,4 +19,4 @@ tmp
19
19
  .yardoc
20
20
  .sass-cache
21
21
  .DS_Store
22
- sauce_connect.log
22
+ sauce_connect.log
data/Readme.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/volt.svg)](http://badge.fury.io/rb/volt)
2
- [![Code Climate](http://img.shields.io/codeclimate/github/voltrb/volt.svg)](https://codeclimate.com/github/voltrb/volt)
2
+ [![Code Climate](https://codeclimate.com/github/voltrb/volt/badges/gpa.svg)](https://codeclimate.com/github/voltrb/volt)
3
3
  [![Build Status](http://img.shields.io/travis/voltrb/volt/master.svg)](https://travis-ci.org/voltrb/volt)
4
4
  [![Inline docs](http://inch-ci.org/github/voltrb/volt.svg?branch=master)](http://inch-ci.org/github/voltrb/volt)
5
5
  [![Volt Chat](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/voltrb/volt)
@@ -26,4 +26,10 @@ Check out demo apps:
26
26
 
27
27
  # Docs
28
28
 
29
- Read the [full docs on Volt here](http://voltframework.com/docs)
29
+ Read the [full docs on Volt here](http://voltframework.com/docs)
30
+
31
+ # Contributing
32
+
33
+ You want to contribute? Great! Thanks for being awesome! At the moment, we have a big internal todo list, hop on https://gitter.im/voltrb/volt so we don't duplicate work. Pull requests are always welcome, but asking about helping on gitter should save some duplication.
34
+
35
+ [![Pledgie](https://pledgie.com/campaigns/26731.png?skin_name=chrome)](https://pledgie.com/campaigns/26731)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.14
1
+ 0.8.15
@@ -1,4 +1,4 @@
1
- class Volt
1
+ module Volt
2
2
  class NoticesController < ModelController
3
3
  model :page
4
4
 
@@ -1,5 +1,5 @@
1
- class User < Model
1
+ class User < Volt::Model
2
2
  def password=(val)
3
3
  self._password = '--encoded: ' + val
4
4
  end
5
- end
5
+ end
@@ -1,7 +1,7 @@
1
1
  require_relative 'live_query'
2
2
  require 'volt/utils/generic_pool'
3
3
 
4
- class LiveQueryPool < GenericPool
4
+ class LiveQueryPool < Volt::GenericPool
5
5
  def initialize(data_store)
6
6
  super()
7
7
  @data_store = data_store
@@ -1,7 +1,7 @@
1
1
  require_relative 'live_query/data_store'
2
2
  require_relative 'live_query/live_query_pool'
3
3
 
4
- class QueryTasks < TaskHandler
4
+ class QueryTasks < Volt::TaskHandler
5
5
  @@live_query_pool = LiveQueryPool.new(DataStore.new)
6
6
  @@channel_live_queries = {}
7
7
 
@@ -1,6 +1,6 @@
1
1
  require 'mongo'
2
2
 
3
- class StoreTasks < TaskHandler
3
+ class StoreTasks < Volt::TaskHandler
4
4
  def initialize(channel=nil, dispatcher=nil)
5
5
  @channel = channel
6
6
  @dispatcher = dispatcher
@@ -1,6 +1,6 @@
1
- class UserTasks < TaskHandler
1
+ class UserTasks < Volt::TaskHandler
2
2
  # Login a user, takes a username and password
3
3
  def create_user(username, password)
4
4
  $page.store._users << {email: username, password: password}
5
5
  end
6
- end
6
+ end
data/lib/volt/boot.rb CHANGED
@@ -6,7 +6,7 @@ else
6
6
  require 'volt/page/page'
7
7
  end
8
8
 
9
- class Volt
9
+ module Volt
10
10
  def self.boot(app_path)
11
11
  # Run the app config to load all users config files
12
12
  Volt.run_files_in_config_folder
@@ -20,4 +20,4 @@ class Volt
20
20
 
21
21
  return component_paths
22
22
  end
23
- end
23
+ end
@@ -1,34 +1,37 @@
1
- class CLI
1
+ module Volt
2
+ class CLI
2
3
 
3
- desc "precompile", "precompile all application assets"
4
- def precompile
5
- compile
6
- end
7
-
8
- desc "watch", "compiles the project to /compiled when a file changes"
9
- def watch
10
- require 'listen'
4
+ desc "precompile", "precompile all application assets"
11
5
 
12
- listener = Listen.to('app') do |modified, added, removed|
6
+ def precompile
13
7
  compile
14
8
  end
15
9
 
16
- listener.start # non-blocking
10
+ desc "watch", "compiles the project to /compiled when a file changes"
17
11
 
18
- Signal.trap("SIGINT") do
19
- listener.stop
20
- end
12
+ def watch
13
+ require 'listen'
21
14
 
22
- compile
15
+ listener = Listen.to('app') do |modified, added, removed|
16
+ compile
17
+ end
18
+
19
+ listener.start # non-blocking
20
+
21
+ Signal.trap("SIGINT") do
22
+ listener.stop
23
+ end
23
24
 
24
- begin
25
- sleep
26
- rescue ThreadError => e
27
- # ignore, breaks out on sigint
25
+ compile
26
+
27
+ begin
28
+ sleep
29
+ rescue ThreadError => e
30
+ # ignore, breaks out on sigint
31
+ end
28
32
  end
29
- end
30
33
 
31
- private
34
+ private
32
35
  def compile
33
36
  print "compiling project..."
34
37
  require 'fileutils'
@@ -41,14 +44,14 @@ class CLI
41
44
  require 'volt/server/component_handler'
42
45
 
43
46
  @root_path ||= Dir.pwd
44
- Volt.root = @root_path
47
+ Volt.root = @root_path
45
48
 
46
49
  @app_path = File.expand_path(File.join(@root_path, "app"))
47
50
 
48
- @component_paths = ComponentPaths.new(@root_path)
49
- @app = Rack::Builder.new
50
- @opal_files = OpalFiles.new(@app, @app_path, @component_paths)
51
- @index_files = IndexFiles.new(@app, @component_paths, @opal_files)
51
+ @component_paths = ComponentPaths.new(@root_path)
52
+ @app = Rack::Builder.new
53
+ @opal_files = OpalFiles.new(@app, @app_path, @component_paths)
54
+ @index_files = IndexFiles.new(@app, @component_paths, @opal_files)
52
55
  @component_handler = ComponentHandler.new(@component_paths)
53
56
 
54
57
  write_component_js
@@ -112,4 +115,5 @@ class CLI
112
115
  file.write(@index_files.html)
113
116
  end
114
117
  end
115
- end
118
+ end
119
+ end
data/lib/volt/cli.rb CHANGED
@@ -3,86 +3,85 @@ require 'thor'
3
3
  require 'volt/extra_core/extra_core'
4
4
  require 'volt/cli/generate'
5
5
 
6
- class CLI < Thor
7
- include Thor::Actions
6
+ module Volt
7
+ class CLI < Thor
8
+ include Thor::Actions
8
9
 
9
- register(Generate, 'generate', 'generate GENERATOR [args]', 'Run a generator.')
10
+ register(Generate, 'generate', 'generate GENERATOR [args]', 'Run a generator.')
10
11
 
11
- desc "new PROJECT_NAME", "generates a new project."
12
- def new(name)
13
- # Grab the current volt version
14
- version = File.read(File.join(File.dirname(__FILE__), '../../VERSION'))
15
- directory("project", name, {version: version, name: name})
12
+ desc "new PROJECT_NAME", "generates a new project."
16
13
 
17
- say "Bundling Gems...."
18
- `cd #{name} && bundle`
19
- end
20
-
21
- desc "console", "run the console on the project in the current directory"
22
- def console
23
- require 'volt/console'
24
- Console.start
25
- end
14
+ def new(name)
15
+ # Grab the current volt version
16
+ version = File.read(File.join(File.dirname(__FILE__), '../../VERSION'))
17
+ directory("project", name, {version: version, name: name})
26
18
 
27
- desc "server", "run the server on the project in the current directory"
28
- method_option :port, :type => :string, :aliases => '-p', :banner => 'specify which port the server should run on'
29
- def server
30
- if RUBY_PLATFORM == 'java'
31
- require 'volt/server'
32
- else
33
- require 'thin'
19
+ say "Bundling Gems...."
20
+ `cd #{name} && bundle`
34
21
  end
35
22
 
36
- require 'fileutils'
23
+ desc "console", "run the console on the project in the current directory"
37
24
 
38
- # If we're in a Volt project, clear the temp directory
39
- # TODO: this is a work around for a bug when switching between
40
- # source maps and non-source maps.
41
- if File.exists?("config.ru") && File.exists?("Gemfile")
42
- FileUtils.rm_rf("tmp/.")
43
- else
44
- say("Current folder is not a Volt project", :red)
45
- return
25
+ def console
26
+ require 'volt/console'
27
+ Console.start
46
28
  end
47
29
 
48
- if RUBY_PLATFORM == 'java'
49
- server = Server.new.app
50
- Rack::Handler::Jubilee.run(server)
51
- Thread.stop
52
- else
53
- ENV['SERVER'] = 'true'
54
- args = ['start', '--threaded', '--max-persistent-conns', '300', "--max-conns", "400"]
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'
55
32
 
56
- if options[:port]
57
- args += ['-p', options[:port].to_s]
33
+ def server
34
+ if RUBY_PLATFORM == 'java'
35
+ require 'volt/server'
36
+ else
37
+ require 'thin'
58
38
  end
59
39
 
60
- Thin::Runner.new(args).run!
40
+ require 'fileutils'
41
+
42
+ # If we're in a Volt project, clear the temp directory
43
+ # TODO: this is a work around for a bug when switching between
44
+ # source maps and non-source maps.
45
+ if File.exists?("config.ru") && File.exists?("Gemfile")
46
+ FileUtils.rm_rf("tmp/.")
47
+ else
48
+ say("Current folder is not a Volt project", :red)
49
+ return
50
+ end
51
+
52
+ if RUBY_PLATFORM == 'java'
53
+ server = Server.new.app
54
+ Rack::Handler::Jubilee.run(server)
55
+ Thread.stop
56
+ else
57
+ ENV['SERVER'] = 'true'
58
+ args = ['start', '--threaded', '--max-persistent-conns', '300', "--max-conns", "400"]
59
+
60
+ if options[:port]
61
+ args += ['-p', options[:port].to_s]
62
+ end
63
+
64
+ Thin::Runner.new(args).run!
65
+ end
61
66
  end
62
67
 
63
- # require 'volt/server'
64
- #
65
- # EM.run do
66
- # thin = Rack::Handler.get("thin")
67
- # thin.run(Server.new.app, Port: 3000)
68
- # end
69
- end
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)"
70
75
 
71
- desc "gem GEM", "Creates a component gem where you can share a component"
72
- method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
73
- 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."
74
- method_option :edit, :type => :string, :aliases => "-e",
75
- :lazy_default => [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? },
76
- :required => false, :banner => "/path/to/your/editor",
77
- :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
78
- def gem(name)
79
- require 'volt/cli/new_gem'
80
-
81
- NewGem.new(self, name, options)
82
- end
76
+ def gem(name)
77
+ require 'volt/cli/new_gem'
83
78
 
84
- def self.source_root
85
- File.expand_path(File.join(File.dirname(__FILE__), '../../templates'))
79
+ NewGem.new(self, name, options)
80
+ end
81
+
82
+ def self.source_root
83
+ File.expand_path(File.join(File.dirname(__FILE__), '../../templates'))
84
+ end
86
85
  end
87
86
  end
88
87
 
@@ -90,4 +89,4 @@ end
90
89
  require 'volt/cli/asset_compile'
91
90
 
92
91
  puts "Volt #{File.read(File.join(File.dirname(__FILE__), "../../VERSION"))}"
93
- CLI.start(ARGV)
92
+ Volt::CLI.start(ARGV)
data/lib/volt/config.rb CHANGED
@@ -1,31 +1,33 @@
1
1
  # Config lets a user set global config options for Volt.
2
- class Volt
2
+ module Volt
3
+ module Config
3
4
 
4
- def self.setup
5
- yield self.config
6
- end
5
+ def setup
6
+ yield self.config
7
+ end
7
8
 
8
- def self.config
9
- @config || self.reset_config!
10
- end
9
+ def config
10
+ @config || self.reset_config!
11
+ end
11
12
 
12
- # Resets the configuration to the default (empty hash)
13
- def self.reset_config!
14
- app_name = File.basename(Dir.pwd)
13
+ # Resets the configuration to the default (empty hash)
14
+ def reset_config!
15
+ app_name = File.basename(Dir.pwd)
15
16
 
16
- @config = OpenStruct.new({
17
- app_name: app_name,
18
- db_name: ENV['DB_NAME'] || (app_name + '_' + Volt.env.to_s),
19
- db_host: ENV['DB_HOST'] || 'localhost',
20
- db_port: (ENV['DB_PORT'] || 27017).to_i,
21
- db_driver: ENV['DB_DRIVER'] || 'mongo'
22
- })
23
- end
17
+ @config = OpenStruct.new(
18
+ app_name: app_name,
19
+ db_name: ENV['DB_NAME'] || (app_name + '_' + Volt.env.to_s),
20
+ db_host: ENV['DB_HOST'] || 'localhost',
21
+ db_port: (ENV['DB_PORT'] || 27017).to_i,
22
+ db_driver: ENV['DB_DRIVER'] || 'mongo'
23
+ )
24
+ end
24
25
 
25
- # Load in all .rb files in the config folder
26
- def self.run_files_in_config_folder
27
- Dir[Dir.pwd + '/config/*.rb'].each do |config_file|
28
- require(config_file)
26
+ # Load in all .rb files in the config folder
27
+ def run_files_in_config_folder
28
+ Dir[Dir.pwd + '/config/*.rb'].each do |config_file|
29
+ require(config_file)
30
+ end
29
31
  end
30
32
  end
31
- end
33
+ end
data/lib/volt/console.rb CHANGED
@@ -13,31 +13,32 @@ class Pry
13
13
  end
14
14
 
15
15
  # Automatically flush after each line
16
- Computation.flush!
16
+ Volt::Computation.flush!
17
17
  end
18
18
  end
19
19
 
20
+ module Volt
21
+ class Console
22
+ def self.start
23
+ require 'pry'
20
24
 
21
- class Console
22
- def self.start
23
- require 'pry'
25
+ $LOAD_PATH << 'lib'
26
+ ENV['SERVER'] = 'true'
24
27
 
25
- $LOAD_PATH << 'lib'
26
- ENV['SERVER'] = 'true'
28
+ require 'volt'
29
+ require 'volt/boot'
30
+ require 'volt/server/socket_connection_handler_stub'
27
31
 
28
- require 'volt'
29
- require 'volt/boot'
30
- require 'volt/server/socket_connection_handler_stub'
32
+ SocketConnectionHandlerStub.dispatcher = Dispatcher.new
31
33
 
32
- SocketConnectionHandlerStub.dispatcher = Dispatcher.new
34
+ Volt.boot(Dir.pwd)
33
35
 
34
- Volt.boot(Dir.pwd)
36
+ Pry.config.prompt_name = 'volt'
35
37
 
36
- Pry.config.prompt_name = 'volt'
38
+ # start a REPL session
39
+ # Pry.start
37
40
 
38
- # start a REPL session
39
- # Pry.start
40
-
41
- $page.pry
41
+ $page.pry
42
+ end
42
43
  end
43
44
  end
@@ -1,114 +1,116 @@
1
1
  require 'volt/reactive/reactive_accessors'
2
2
 
3
- class ModelController
4
- include ReactiveAccessors
3
+ module Volt
4
+ class ModelController
5
+ include ReactiveAccessors
5
6
 
6
- reactive_accessor :current_model
7
+ reactive_accessor :current_model
7
8
 
8
- def self.model(val)
9
- @default_model = val
10
- end
11
-
12
- # Sets the current model on this controller
13
- def model=(val)
14
- # Start with a nil reactive value.
15
- self.current_model ||= Model.new
9
+ def self.model(val)
10
+ @default_model = val
11
+ end
16
12
 
17
- if Symbol === val || String === val
18
- collections = [:page, :store, :params, :controller]
19
- if collections.include?(val.to_sym)
20
- self.current_model = self.send(val)
13
+ # Sets the current model on this controller
14
+ def model=(val)
15
+ # Start with a nil reactive value.
16
+ self.current_model ||= Model.new
17
+
18
+ if Symbol === val || String === val
19
+ collections = [:page, :store, :params, :controller]
20
+ if collections.include?(val.to_sym)
21
+ self.current_model = self.send(val)
22
+ else
23
+ raise "#{val} is not the name of a valid model, choose from: #{collections.join(', ')}"
24
+ end
25
+ elsif val
26
+ self.current_model = val
21
27
  else
22
- raise "#{val} is not the name of a valid model, choose from: #{collections.join(', ')}"
28
+ raise "model can not be #{val.inspect}"
23
29
  end
24
- elsif val
25
- self.current_model = val
26
- else
27
- raise "model can not be #{val.inspect}"
28
30
  end
29
- end
30
31
 
31
- def model
32
- model = self.current_model
32
+ def model
33
+ model = self.current_model
33
34
 
34
- # If the model is a proc, call it now
35
- if model.is_a?(Proc)
36
- model = model.call
37
- end
35
+ # If the model is a proc, call it now
36
+ if model.is_a?(Proc)
37
+ model = model.call
38
+ end
38
39
 
39
- return model
40
- end
40
+ return model
41
+ end
41
42
 
42
- def self.new(*args, &block)
43
- inst = self.allocate
43
+ def self.new(*args, &block)
44
+ inst = self.allocate
44
45
 
45
- inst.model = (@default_model || :controller)
46
+ inst.model = (@default_model || :controller)
46
47
 
47
- inst.initialize(*args, &block)
48
+ inst.initialize(*args, &block)
48
49
 
49
- return inst
50
- end
50
+ return inst
51
+ end
51
52
 
52
- attr_accessor :attrs
53
+ attr_accessor :attrs
53
54
 
54
- def initialize(*args)
55
- if args[0]
56
- # Assign the first passed in argument to attrs
57
- self.attrs = args[0]
55
+ def initialize(*args)
56
+ if args[0]
57
+ # Assign the first passed in argument to attrs
58
+ self.attrs = args[0]
58
59
 
59
- # If a model attribute is passed in, we assign it directly
60
- if attrs.respond_to?(:model)
61
- self.model = attrs.locals[:model]
60
+ # If a model attribute is passed in, we assign it directly
61
+ if attrs.respond_to?(:model)
62
+ self.model = attrs.locals[:model]
63
+ end
62
64
  end
63
65
  end
64
- end
65
66
 
66
- # Change the url params, similar to redirecting to a new url
67
- def go(url)
68
- self.url.parse(url)
69
- end
67
+ # Change the url params, similar to redirecting to a new url
68
+ def go(url)
69
+ self.url.parse(url)
70
+ end
70
71
 
71
- def page
72
- $page.page
73
- end
72
+ def page
73
+ $page.page
74
+ end
74
75
 
75
- def paged
76
- $page.page
77
- end
76
+ def paged
77
+ $page.page
78
+ end
78
79
 
79
- def store
80
- $page.store
81
- end
80
+ def store
81
+ $page.store
82
+ end
82
83
 
83
- def flash
84
- $page.flash
85
- end
84
+ def flash
85
+ $page.flash
86
+ end
86
87
 
87
- def params
88
- $page.params
89
- end
88
+ def params
89
+ $page.params
90
+ end
90
91
 
91
- def local_store
92
- $page.local_store
93
- end
92
+ def local_store
93
+ $page.local_store
94
+ end
94
95
 
95
- def url
96
- $page.url
97
- end
96
+ def url
97
+ $page.url
98
+ end
98
99
 
99
- def channel
100
- $page.channel
101
- end
100
+ def channel
101
+ $page.channel
102
+ end
102
103
 
103
- def tasks
104
- $page.tasks
105
- end
104
+ def tasks
105
+ $page.tasks
106
+ end
106
107
 
107
- def controller
108
- @controller ||= Model.new
109
- end
108
+ def controller
109
+ @controller ||= Model.new
110
+ end
110
111
 
111
- def method_missing(method_name, *args, &block)
112
- return model.send(method_name, *args, &block)
112
+ def method_missing(method_name, *args, &block)
113
+ model.send(method_name, *args, &block)
114
+ end
113
115
  end
114
116
  end