volt 0.8.14 → 0.8.15
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/.gitignore +1 -1
- data/Readme.md +8 -2
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/models/user.rb +2 -2
- data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
- data/app/volt/tasks/query_tasks.rb +1 -1
- data/app/volt/tasks/store_tasks.rb +1 -1
- data/app/volt/tasks/user_tasks.rb +2 -2
- data/lib/volt/boot.rb +2 -2
- data/lib/volt/cli/asset_compile.rb +31 -27
- data/lib/volt/cli.rb +64 -65
- data/lib/volt/config.rb +25 -23
- data/lib/volt/console.rb +17 -16
- data/lib/volt/controllers/model_controller.rb +82 -80
- data/lib/volt/data_stores/data_store.rb +2 -2
- data/lib/volt/data_stores/mongo_driver.rb +2 -2
- data/lib/volt/extra_core/inflections.rb +2 -2
- data/lib/volt/extra_core/inflector/inflections.rb +185 -183
- data/lib/volt/extra_core/inflector/methods.rb +50 -48
- data/lib/volt/extra_core/string.rb +2 -2
- data/lib/volt/models/array_model.rb +93 -92
- data/lib/volt/models/cursor.rb +3 -2
- data/lib/volt/models/model.rb +248 -251
- data/lib/volt/models/model_hash_behaviour.rb +44 -44
- data/lib/volt/models/model_helpers.rb +38 -36
- data/lib/volt/models/model_state.rb +16 -17
- data/lib/volt/models/model_wrapper.rb +25 -24
- data/lib/volt/models/persistors/array_store.rb +145 -143
- data/lib/volt/models/persistors/base.rb +18 -16
- data/lib/volt/models/persistors/flash.rb +24 -22
- data/lib/volt/models/persistors/local_store.rb +46 -44
- data/lib/volt/models/persistors/model_identity_map.rb +10 -8
- data/lib/volt/models/persistors/model_store.rb +76 -76
- data/lib/volt/models/persistors/params.rb +19 -17
- data/lib/volt/models/persistors/query/query_listener.rb +65 -63
- data/lib/volt/models/persistors/query/query_listener_pool.rb +12 -10
- data/lib/volt/models/persistors/store.rb +28 -28
- data/lib/volt/models/persistors/store_factory.rb +12 -10
- data/lib/volt/models/persistors/store_state.rb +33 -31
- data/lib/volt/models/url.rb +96 -104
- data/lib/volt/models/validations.rb +56 -54
- data/lib/volt/models/validators/length_validator.rb +24 -22
- data/lib/volt/models/validators/presence_validator.rb +14 -12
- data/lib/volt/page/bindings/attribute_binding.rb +106 -106
- data/lib/volt/page/bindings/base_binding.rb +23 -21
- data/lib/volt/page/bindings/component_binding.rb +3 -1
- data/lib/volt/page/bindings/content_binding.rb +34 -34
- data/lib/volt/page/bindings/each_binding.rb +113 -113
- data/lib/volt/page/bindings/event_binding.rb +38 -34
- data/lib/volt/page/bindings/if_binding.rb +56 -54
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +24 -22
- data/lib/volt/page/bindings/template_binding.rb +182 -185
- data/lib/volt/page/channel.rb +79 -77
- data/lib/volt/page/channel_stub.rb +29 -27
- data/lib/volt/page/document.rb +6 -5
- data/lib/volt/page/document_events.rb +54 -52
- data/lib/volt/page/page.rb +139 -138
- data/lib/volt/page/string_template_renderer.rb +36 -36
- data/lib/volt/page/sub_context.rb +26 -25
- data/lib/volt/page/targets/attribute_section.rb +27 -25
- data/lib/volt/page/targets/attribute_target.rb +7 -6
- data/lib/volt/page/targets/base_section.rb +27 -26
- data/lib/volt/page/targets/binding_document/base_node.rb +3 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +85 -82
- data/lib/volt/page/targets/binding_document/html_node.rb +11 -9
- data/lib/volt/page/targets/dom_section.rb +78 -77
- data/lib/volt/page/targets/dom_target.rb +8 -6
- data/lib/volt/page/targets/dom_template.rb +90 -88
- data/lib/volt/page/targets/helpers/comment_searchers.rb +51 -49
- data/lib/volt/page/tasks.rb +59 -57
- data/lib/volt/page/template_renderer.rb +17 -14
- data/lib/volt/page/url_tracker.rb +26 -24
- data/lib/volt/reactive/computation.rb +87 -88
- data/lib/volt/reactive/dependency.rb +30 -28
- data/lib/volt/reactive/eventable.rb +64 -62
- data/lib/volt/reactive/hash_dependency.rb +25 -23
- data/lib/volt/reactive/reactive_accessors.rb +34 -32
- data/lib/volt/reactive/reactive_array.rb +162 -162
- data/lib/volt/reactive/reactive_hash.rb +37 -35
- data/lib/volt/router/routes.rb +99 -101
- data/lib/volt/server/component_handler.rb +20 -21
- data/lib/volt/server/component_templates.rb +72 -70
- data/lib/volt/server/html_parser/attribute_scope.rb +109 -99
- data/lib/volt/server/html_parser/each_scope.rb +17 -16
- data/lib/volt/server/html_parser/if_view_scope.rb +51 -49
- data/lib/volt/server/html_parser/sandlebars_parser.rb +184 -177
- data/lib/volt/server/html_parser/textarea_scope.rb +24 -22
- data/lib/volt/server/html_parser/view_handler.rb +66 -65
- data/lib/volt/server/html_parser/view_parser.rb +23 -21
- data/lib/volt/server/html_parser/view_scope.rb +142 -141
- data/lib/volt/server/rack/asset_files.rb +81 -79
- data/lib/volt/server/rack/component_code.rb +17 -15
- data/lib/volt/server/rack/component_html_renderer.rb +14 -12
- data/lib/volt/server/rack/component_paths.rb +72 -71
- data/lib/volt/server/rack/index_files.rb +36 -39
- data/lib/volt/server/rack/opal_files.rb +43 -41
- data/lib/volt/server/rack/source_map_server.rb +23 -21
- data/lib/volt/server/socket_connection_handler.rb +46 -45
- data/lib/volt/server/socket_connection_handler_stub.rb +21 -19
- data/lib/volt/server.rb +60 -58
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/tasks/dispatcher.rb +24 -23
- data/lib/volt/tasks/task_handler.rb +35 -33
- data/lib/volt/utils/ejson.rb +8 -6
- data/lib/volt/utils/generic_counting_pool.rb +33 -31
- data/lib/volt/utils/generic_pool.rb +73 -70
- data/lib/volt/utils/local_storage.rb +42 -38
- data/lib/volt/volt/environment.rb +1 -1
- data/lib/volt.rb +44 -42
- data/spec/apps/kitchen_sink/app/main/assets/css/todos.css +28 -0
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +2 -2
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +17 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
- data/spec/apps/kitchen_sink/app/main/views/todos/index.html +24 -0
- data/spec/apps/kitchen_sink/config.ru +1 -1
- data/spec/controllers/reactive_accessors_spec.rb +5 -5
- data/spec/extra_core/inflector_spec.rb +2 -2
- data/spec/integration/list_spec.rb +68 -0
- data/spec/models/model_spec.rb +57 -57
- data/spec/models/persistors/params_spec.rb +6 -6
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/validations_spec.rb +3 -3
- data/spec/page/bindings/content_binding_spec.rb +7 -7
- data/spec/page/bindings/template_binding_spec.rb +4 -5
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +10 -10
- data/spec/reactive/dependency_spec.rb +2 -2
- data/spec/reactive/eventable_spec.rb +4 -4
- data/spec/reactive/reactive_array_spec.rb +13 -13
- data/spec/router/routes_spec.rb +5 -5
- data/spec/server/html_parser/sandlebars_parser_spec.rb +9 -9
- data/spec/server/html_parser/view_parser_spec.rb +27 -27
- data/spec/server/rack/asset_files_spec.rb +5 -5
- data/spec/server/rack/component_paths_spec.rb +2 -2
- data/spec/tasks/live_query_spec.rb +2 -2
- data/spec/tasks/query_tasks.rb +1 -1
- data/spec/tasks/query_tracker_spec.rb +1 -1
- data/spec/templates/targets/binding_document/component_node_spec.rb +2 -2
- data/spec/utils/generic_counting_pool_spec.rb +2 -2
- data/spec/utils/generic_pool_spec.rb +2 -2
- data/templates/component/controllers/main_controller.rb +1 -1
- data/templates/model/model.rb.tt +2 -2
- data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +1 -1
- data/templates/project/config.ru +1 -1
- metadata +10 -3
- data/app/volt/assets/js/vertxbus.js +0 -216
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6635ba6a1792a3170956c91f7125be7b5c0cd268
|
|
4
|
+
data.tar.gz: e63ae431f7bf79aa12be2ed75dc499e580979eb7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ccaaf9013222c95f10537b9712e8b8d5a8ecb3d705c20e533c54985c4420ffd09ec71a6cc51bc49e19ce55e525b788745d6be13b2e1cb1ce05a00f87499836f
|
|
7
|
+
data.tar.gz: 19ecd0ca6771454732889f8336c34cb24803caa5ea8ebc5cdc058557e6ffdaa618cbb4cca56c69069f89b35ce0c7de6468338f0ccc338d69cb75448400a31785
|
data/.gitignore
CHANGED
data/Readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](http://badge.fury.io/rb/volt)
|
|
2
|
-
[](https://codeclimate.com/github/voltrb/volt)
|
|
3
3
|
[](https://travis-ci.org/voltrb/volt)
|
|
4
4
|
[](http://inch-ci.org/github/voltrb/volt)
|
|
5
5
|
[](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
|
+
[](https://pledgie.com/campaigns/26731)
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.15
|
data/app/volt/models/user.rb
CHANGED
data/lib/volt/boot.rb
CHANGED
|
@@ -6,7 +6,7 @@ else
|
|
|
6
6
|
require 'volt/page/page'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
|
|
1
|
+
module Volt
|
|
2
|
+
class CLI
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
|
|
6
|
+
def precompile
|
|
13
7
|
compile
|
|
14
8
|
end
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
desc "watch", "compiles the project to /compiled when a file changes"
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
12
|
+
def watch
|
|
13
|
+
require 'listen'
|
|
21
14
|
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
|
47
|
+
Volt.root = @root_path
|
|
45
48
|
|
|
46
49
|
@app_path = File.expand_path(File.join(@root_path, "app"))
|
|
47
50
|
|
|
48
|
-
@component_paths
|
|
49
|
-
@app
|
|
50
|
-
@opal_files
|
|
51
|
-
@index_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
|
-
|
|
7
|
-
|
|
6
|
+
module Volt
|
|
7
|
+
class CLI < Thor
|
|
8
|
+
include Thor::Actions
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
register(Generate, 'generate', 'generate GENERATOR [args]', 'Run a generator.')
|
|
10
11
|
|
|
11
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
23
|
+
desc "console", "run the console on the project in the current directory"
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
57
|
-
|
|
33
|
+
def server
|
|
34
|
+
if RUBY_PLATFORM == 'java'
|
|
35
|
+
require 'volt/server'
|
|
36
|
+
else
|
|
37
|
+
require 'thin'
|
|
58
38
|
end
|
|
59
39
|
|
|
60
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
2
|
+
module Volt
|
|
3
|
+
module Config
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
def setup
|
|
6
|
+
yield self.config
|
|
7
|
+
end
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
def config
|
|
10
|
+
@config || self.reset_config!
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
# Resets the configuration to the default (empty hash)
|
|
14
|
+
def reset_config!
|
|
15
|
+
app_name = File.basename(Dir.pwd)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
require 'pry'
|
|
25
|
+
$LOAD_PATH << 'lib'
|
|
26
|
+
ENV['SERVER'] = 'true'
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
require 'volt'
|
|
29
|
+
require 'volt/boot'
|
|
30
|
+
require 'volt/server/socket_connection_handler_stub'
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
require 'volt/boot'
|
|
30
|
-
require 'volt/server/socket_connection_handler_stub'
|
|
32
|
+
SocketConnectionHandlerStub.dispatcher = Dispatcher.new
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
Volt.boot(Dir.pwd)
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Pry.config.prompt_name = 'volt'
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
# start a REPL session
|
|
39
|
+
# Pry.start
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
4
|
-
|
|
3
|
+
module Volt
|
|
4
|
+
class ModelController
|
|
5
|
+
include ReactiveAccessors
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
reactive_accessor :current_model
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 "
|
|
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
|
-
|
|
32
|
-
|
|
32
|
+
def model
|
|
33
|
+
model = self.current_model
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
40
|
+
return model
|
|
41
|
+
end
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
def self.new(*args, &block)
|
|
44
|
+
inst = self.allocate
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
inst.model = (@default_model || :controller)
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
inst.initialize(*args, &block)
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
return inst
|
|
51
|
+
end
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
attr_accessor :attrs
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
def page
|
|
73
|
+
$page.page
|
|
74
|
+
end
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
def paged
|
|
77
|
+
$page.page
|
|
78
|
+
end
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
def store
|
|
81
|
+
$page.store
|
|
82
|
+
end
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
def flash
|
|
85
|
+
$page.flash
|
|
86
|
+
end
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
def params
|
|
89
|
+
$page.params
|
|
90
|
+
end
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
def local_store
|
|
93
|
+
$page.local_store
|
|
94
|
+
end
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
def url
|
|
97
|
+
$page.url
|
|
98
|
+
end
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
def channel
|
|
101
|
+
$page.channel
|
|
102
|
+
end
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
def tasks
|
|
105
|
+
$page.tasks
|
|
106
|
+
end
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
def controller
|
|
109
|
+
@controller ||= Model.new
|
|
110
|
+
end
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
def method_missing(method_name, *args, &block)
|
|
113
|
+
model.send(method_name, *args, &block)
|
|
114
|
+
end
|
|
113
115
|
end
|
|
114
116
|
end
|