volt 0.6.5 → 0.7.0
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/Readme.md +47 -40
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +3 -3
- data/app/volt/tasks/live_query/data_store.rb +2 -2
- data/app/volt/tasks/live_query/live_query.rb +20 -20
- data/app/volt/tasks/live_query/live_query_pool.rb +6 -6
- data/app/volt/tasks/live_query/query_tracker.rb +15 -15
- data/app/volt/tasks/query_tasks.rb +13 -13
- data/app/volt/tasks/store_tasks.rb +7 -7
- data/app/volt/views/notices/index.html +17 -18
- data/lib/volt/assets/test.rb +2 -2
- data/lib/volt/benchmark/benchmark.rb +25 -23
- data/lib/volt/cli/asset_compile.rb +11 -0
- data/lib/volt/cli/new_gem.rb +16 -16
- data/lib/volt/cli.rb +14 -12
- data/lib/volt/console.rb +5 -6
- data/lib/volt/controllers/model_controller.rb +18 -18
- data/lib/volt/extra_core/array.rb +4 -4
- data/lib/volt/extra_core/hash.rb +3 -3
- data/lib/volt/extra_core/object.rb +6 -6
- data/lib/volt/extra_core/string.rb +6 -6
- data/lib/volt/extra_core/symbol.rb +5 -5
- data/lib/volt/extra_core/time.rb +4 -4
- data/lib/volt/extra_core/true_false.rb +6 -6
- data/lib/volt/extra_core/try.rb +9 -9
- data/lib/volt/models/array_model.rb +26 -26
- data/lib/volt/models/model.rb +35 -35
- data/lib/volt/models/model_hash_behaviour.rb +15 -15
- data/lib/volt/models/model_helpers.rb +8 -8
- data/lib/volt/models/model_wrapper.rb +6 -6
- data/lib/volt/models/persistors/array_store.rb +36 -36
- data/lib/volt/models/persistors/base.rb +6 -6
- data/lib/volt/models/persistors/flash.rb +5 -5
- data/lib/volt/models/persistors/model_identity_map.rb +2 -2
- data/lib/volt/models/persistors/model_store.rb +22 -22
- data/lib/volt/models/persistors/params.rb +3 -3
- data/lib/volt/models/persistors/query/query_listener.rb +14 -14
- data/lib/volt/models/persistors/query/query_listener_pool.rb +2 -2
- data/lib/volt/models/persistors/store.rb +8 -8
- data/lib/volt/models/persistors/store_factory.rb +2 -2
- data/lib/volt/models/url.rb +37 -37
- data/lib/volt/page/bindings/attribute_binding.rb +14 -14
- data/lib/volt/page/bindings/base_binding.rb +9 -9
- data/lib/volt/page/bindings/component_binding.rb +7 -7
- data/lib/volt/page/bindings/content_binding.rb +3 -3
- data/lib/volt/page/bindings/each_binding.rb +13 -13
- data/lib/volt/page/bindings/event_binding.rb +4 -4
- data/lib/volt/page/bindings/if_binding.rb +12 -12
- data/lib/volt/page/bindings/template_binding.rb +30 -30
- data/lib/volt/page/channel.rb +19 -19
- data/lib/volt/page/channel_stub.rb +6 -6
- data/lib/volt/page/document.rb +2 -2
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/draw_cycle.rb +3 -3
- data/lib/volt/page/memory_test.rb +6 -6
- data/lib/volt/page/page.rb +19 -19
- data/lib/volt/page/reactive_template.rb +9 -9
- data/lib/volt/page/sub_context.rb +5 -5
- data/lib/volt/page/targets/attribute_section.rb +9 -9
- data/lib/volt/page/targets/attribute_target.rb +3 -3
- data/lib/volt/page/targets/base_section.rb +2 -2
- data/lib/volt/page/targets/binding_document/component_node.rb +23 -23
- data/lib/volt/page/targets/binding_document/html_node.rb +2 -2
- data/lib/volt/page/targets/dom_section.rb +40 -38
- data/lib/volt/page/targets/dom_target.rb +2 -2
- data/lib/volt/page/tasks.rb +12 -12
- data/lib/volt/page/template_renderer.rb +4 -4
- data/lib/volt/page/url_tracker.rb +6 -6
- data/lib/volt/reactive/array_extensions.rb +2 -2
- data/lib/volt/reactive/destructive_methods.rb +5 -5
- data/lib/volt/reactive/event_chain.rb +25 -25
- data/lib/volt/reactive/events.rb +33 -33
- data/lib/volt/reactive/object_tracker.rb +21 -21
- data/lib/volt/reactive/object_tracking.rb +2 -2
- data/lib/volt/reactive/reactive_array.rb +57 -57
- data/lib/volt/reactive/reactive_tags.rb +16 -16
- data/lib/volt/reactive/reactive_value.rb +72 -72
- data/lib/volt/reactive/string_extensions.rb +3 -3
- data/lib/volt/router/routes.rb +22 -23
- data/lib/volt/server/component_handler.rb +5 -5
- data/lib/volt/server/component_templates.rb +14 -11
- data/lib/volt/server/html_parser/attribute_scope.rb +116 -0
- data/lib/volt/server/html_parser/each_scope.rb +18 -0
- data/lib/volt/server/html_parser/if_view_scope.rb +71 -0
- data/lib/volt/server/html_parser/sandlebars_parser.rb +219 -0
- data/lib/volt/server/html_parser/textarea_scope.rb +31 -0
- data/lib/volt/server/html_parser/view_handler.rb +82 -0
- data/lib/volt/server/html_parser/view_parser.rb +23 -0
- data/lib/volt/server/html_parser/view_scope.rb +145 -0
- data/lib/volt/server/rack/asset_files.rb +17 -17
- data/lib/volt/server/rack/component_paths.rb +18 -18
- data/lib/volt/server/rack/index_files.rb +8 -8
- data/lib/volt/server/rack/opal_files.rb +11 -11
- data/lib/volt/server/socket_connection_handler.rb +13 -13
- data/lib/volt/server/socket_connection_handler_stub.rb +2 -2
- data/lib/volt/server.rb +18 -18
- data/lib/volt/tasks/dispatcher.rb +5 -5
- data/lib/volt/utils/ejson.rb +2 -2
- data/lib/volt/utils/generic_counting_pool.rb +8 -8
- data/lib/volt/utils/generic_pool.rb +16 -16
- data/lib/volt/volt/environment.rb +4 -4
- data/lib/volt.rb +6 -6
- data/spec/integration/test_integration_spec.rb +2 -2
- data/spec/models/event_chain_spec.rb +38 -38
- data/spec/models/model_spec.rb +128 -128
- data/spec/models/old_model_spec.rb +17 -17
- data/spec/models/persistors/params_spec.rb +3 -3
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/reactive_array_spec.rb +82 -82
- data/spec/models/reactive_generator_spec.rb +11 -11
- data/spec/models/reactive_tags_spec.rb +6 -6
- data/spec/models/reactive_value_spec.rb +70 -70
- data/spec/models/store_spec.rb +4 -4
- data/spec/models/string_extensions_spec.rb +13 -13
- data/spec/page/bindings/content_binding_spec.rb +6 -6
- data/spec/page/sub_context_spec.rb +1 -1
- data/spec/router/routes_spec.rb +3 -3
- data/spec/server/html_parser/sample_page.html +595 -0
- data/spec/server/html_parser/sandlebars_parser_spec.rb +192 -0
- data/spec/server/html_parser/view_parser_spec.rb +286 -0
- data/spec/server/rack/asset_files_spec.rb +6 -6
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/spec_helper.rb +4 -5
- data/spec/store/mongo_spec.rb +3 -3
- data/spec/tasks/live_query_spec.rb +6 -6
- data/spec/tasks/query_tasks.rb +4 -4
- data/spec/tasks/query_tracker_spec.rb +20 -20
- data/spec/templates/targets/binding_document/component_node_spec.rb +4 -4
- data/spec/templates/template_binding_spec.rb +28 -28
- data/spec/utils/generic_counting_pool_spec.rb +5 -5
- data/spec/utils/generic_pool_spec.rb +14 -14
- data/templates/newgem/app/newgem/views/index/index.html +1 -2
- data/templates/project/app/home/config/dependencies.rb +1 -1
- data/templates/project/app/home/controllers/index_controller.rb +1 -1
- data/templates/project/app/home/views/index/about.html +4 -6
- data/templates/project/app/home/views/index/home.html +4 -5
- data/templates/project/app/home/views/index/index.html +8 -9
- data/templates/project/spec/spec_helper.rb +1 -1
- metadata +17 -8
- data/lib/volt/server/binding_setup.rb +0 -2
- data/lib/volt/server/if_binding_setup.rb +0 -31
- data/lib/volt/server/scope.rb +0 -43
- data/lib/volt/server/template_parser.rb +0 -453
- data/spec/server/template_parser_spec.rb +0 -50
|
@@ -4,18 +4,18 @@ class StoreTasks
|
|
|
4
4
|
def initialize(channel=nil, dispatcher=nil)
|
|
5
5
|
@@mongo_db ||= Mongo::MongoClient.new("localhost", 27017)
|
|
6
6
|
@@db ||= @@mongo_db.db("development")
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
@channel = channel
|
|
9
9
|
@dispatcher = dispatcher
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
def db
|
|
13
13
|
@@db
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def save(collection, data)
|
|
17
17
|
# puts "Insert: #{data.inspect} on #{collection.inspect}"
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
data = data.symbolize_keys
|
|
20
20
|
id = data[:_id]
|
|
21
21
|
|
|
@@ -34,14 +34,14 @@ class StoreTasks
|
|
|
34
34
|
raise
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
QueryTasks.live_query_pool.updated_collection(collection, @channel)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def delete(collection, id)
|
|
42
42
|
puts "DELETE: #{collection.inspect} - #{id.inspect}"
|
|
43
43
|
@@db[collection].remove('_id' => id)
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
QueryTasks.live_query_pool.updated_collection(collection, @channel)
|
|
46
46
|
end
|
|
47
|
-
end
|
|
47
|
+
end
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
<:
|
|
2
|
-
{#if page._reloading}
|
|
3
|
-
|
|
4
|
-
{/}
|
|
5
|
-
{#if channel.status == :reconnecting}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{/}
|
|
11
|
-
{#if !flash.empty?}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{/}
|
|
18
|
-
</:body>
|
|
1
|
+
<:Body>
|
|
2
|
+
{#if page._reloading}
|
|
3
|
+
<div class="notices alert alert-info">Reloading...</div>
|
|
4
|
+
{/}
|
|
5
|
+
{#if channel.status == :reconnecting}
|
|
6
|
+
<div class="notices alert alert-info">
|
|
7
|
+
Connection Lost... {channel.error}...
|
|
8
|
+
{#if channel.reconnect_interval} Reconnecting in {(channel.reconnect_interval / 1000.0).round} sec{/}
|
|
9
|
+
</div>
|
|
10
|
+
{/}
|
|
11
|
+
{#if !flash.empty?}
|
|
12
|
+
<div class="notices alert alert-info" e-click="flash.clear">
|
|
13
|
+
{#each flash._notices as notice}
|
|
14
|
+
<p>{notice}</p>
|
|
15
|
+
{/}
|
|
16
|
+
</div>
|
|
17
|
+
{/}
|
data/lib/volt/assets/test.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
|
|
6
|
-
puts a[1].to_json(:css_path => '/cool.css', :sourcemap_path => '/source_maps/cool.css.map')
|
|
6
|
+
puts a[1].to_json(:css_path => '/cool.css', :sourcemap_path => '/source_maps/cool.css.map')
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
if RUBY_PLATFORM == 'opal'
|
|
2
|
+
class Benchmark
|
|
3
|
+
def self.bm(iterations=1)
|
|
4
|
+
puts "BM"
|
|
5
|
+
|
|
6
|
+
times = []
|
|
7
|
+
total_time = nil
|
|
8
|
+
result = nil
|
|
9
|
+
|
|
10
|
+
iterations.times do
|
|
11
|
+
start_time = `Date.now()`
|
|
12
|
+
result = yield
|
|
13
|
+
end_time = `Date.now()`
|
|
14
|
+
total_time = `end_time - start_time`
|
|
15
|
+
times << total_time
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if iterations == 1
|
|
19
|
+
puts "TOTAL TIME: #{total_time}ms"
|
|
20
|
+
else
|
|
21
|
+
puts "Times: #{times.inspect}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
return result
|
|
15
25
|
end
|
|
16
|
-
|
|
17
|
-
if iterations == 1
|
|
18
|
-
puts "TOTAL TIME: #{total_time}ms"
|
|
19
|
-
else
|
|
20
|
-
puts "Times: #{times.inspect}"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
return result
|
|
24
26
|
end
|
|
25
|
-
end
|
|
27
|
+
end
|
data/lib/volt/cli/new_gem.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
|
4
4
|
|
|
5
5
|
# Creates a new "volt" gem, which can be used to easily repackage
|
|
6
6
|
# components.
|
|
7
|
-
class NewGem
|
|
7
|
+
class NewGem
|
|
8
8
|
def initialize(thor, name, options)
|
|
9
9
|
@thor = thor
|
|
10
10
|
@component_name = name.chomp("/")
|
|
@@ -16,16 +16,16 @@ class NewGem
|
|
|
16
16
|
@thor.say("There is already a gem named #{@name}. Please choose a different name.", :red)
|
|
17
17
|
return
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
@options = options
|
|
21
21
|
@namespaced_path = @name.tr('-', '/')
|
|
22
22
|
@opts = gem_options
|
|
23
23
|
@target = File.join(Dir.pwd, @name)
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
copy_files
|
|
26
26
|
copy_options
|
|
27
27
|
end
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
# Check with the rubygems api to see if this gem name is available.
|
|
30
30
|
def gem_is_available?
|
|
31
31
|
@thor.say("Check if #{@name} is available as a gem name.", :yellow)
|
|
@@ -33,7 +33,7 @@ class NewGem
|
|
|
33
33
|
|
|
34
34
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
35
35
|
http.use_ssl = true
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
request = Net::HTTP::Get.new(uri.request_uri)
|
|
38
38
|
response = http.request(request)
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ class NewGem
|
|
|
42
42
|
# rubygems is down, skip check
|
|
43
43
|
return true
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
def copy_files
|
|
47
47
|
@thor.directory("newgem/app/newgem", File.join("#{@target}", "app/#{@component_name}"), @opts)
|
|
48
48
|
copy("newgem/Gemfile.tt", "Gemfile")
|
|
@@ -54,7 +54,7 @@ class NewGem
|
|
|
54
54
|
copy("newgem/VERSION", "VERSION")
|
|
55
55
|
FileUtils.mkdir_p(File.join(@target, "lib/#{@namespaced_path}"))
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
def copy_options
|
|
59
59
|
if @options[:bin]
|
|
60
60
|
copy("newgem/bin/newgem.tt", "bin/#{@name}")
|
|
@@ -75,18 +75,18 @@ class NewGem
|
|
|
75
75
|
run("#{@options["edit"]} \"#{gemspec_dest}\"") # Open gemspec in editor
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
private
|
|
80
80
|
def copy(from, to)
|
|
81
81
|
@thor.template(File.join(from), File.join(@target, to), @opts)
|
|
82
82
|
end
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
def gem_options
|
|
85
85
|
constant_name = get_constant_name
|
|
86
86
|
constant_array = constant_name.split('::')
|
|
87
87
|
git_user_name = `git config user.name`.chomp
|
|
88
88
|
git_user_email = `git config user.email`.chomp
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
opts = {
|
|
91
91
|
:name => @name,
|
|
92
92
|
:namespaced_path => @namespaced_path,
|
|
@@ -97,20 +97,20 @@ class NewGem
|
|
|
97
97
|
:test => @options[:test],
|
|
98
98
|
:volt_version_base => volt_version_base
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
return opts
|
|
102
102
|
end
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
def volt_version_base
|
|
105
105
|
version_path = File.join(File.dirname(__FILE__), '../../../VERSION')
|
|
106
106
|
File.read(version_path).split('.').tap {|v| v[v.size-1] = 0 }.join('.')
|
|
107
107
|
end
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
def get_constant_name
|
|
110
110
|
constant_name = @name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
|
|
111
111
|
constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
return constant_name
|
|
114
114
|
end
|
|
115
|
-
|
|
116
|
-
end
|
|
115
|
+
|
|
116
|
+
end
|
data/lib/volt/cli.rb
CHANGED
|
@@ -3,17 +3,17 @@ require 'thor'
|
|
|
3
3
|
|
|
4
4
|
class CLI < Thor
|
|
5
5
|
include Thor::Actions
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
desc "new PROJECT_NAME", "generates a new project."
|
|
8
8
|
def new(name)
|
|
9
9
|
# Grab the current volt version
|
|
10
10
|
version = File.read(File.join(File.dirname(__FILE__), '../../VERSION'))
|
|
11
11
|
directory("project", name, {version: version, name: name})
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
say "Bundling Gems...."
|
|
14
14
|
`cd #{name} ; bundle -j 4`
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
desc "console", "run the console on the project in the current directory"
|
|
18
18
|
def console
|
|
19
19
|
require 'volt/console'
|
|
@@ -38,21 +38,21 @@ class CLI < Thor
|
|
|
38
38
|
|
|
39
39
|
ENV['SERVER'] = 'true'
|
|
40
40
|
args = ['start', '--threaded', '--max-persistent-conns', '300', "--max-conns", "400"]
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
if options[:port]
|
|
43
43
|
args += ['-p', options[:port].to_s]
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
Thin::Runner.new(args).run!
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
# require 'volt/server'
|
|
49
|
-
#
|
|
49
|
+
#
|
|
50
50
|
# EM.run do
|
|
51
51
|
# thin = Rack::Handler.get("thin")
|
|
52
52
|
# thin.run(Server.new.app, Port: 3000)
|
|
53
53
|
# end
|
|
54
54
|
end
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
desc "gem GEM", "Creates a component gem where you can share a component"
|
|
57
57
|
method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
|
|
58
58
|
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."
|
|
@@ -62,15 +62,17 @@ class CLI < Thor
|
|
|
62
62
|
:desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
|
|
63
63
|
def gem(name)
|
|
64
64
|
require 'volt/cli/new_gem'
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
NewGem.new(self, name, options)
|
|
67
|
-
end
|
|
68
|
-
|
|
67
|
+
end
|
|
68
|
+
|
|
69
69
|
def self.source_root
|
|
70
70
|
File.expand_path(File.join(File.dirname(__FILE__), '../../templates'))
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
# Add in more features
|
|
75
|
+
require 'volt/cli/asset_compile'
|
|
74
76
|
|
|
75
77
|
puts "Volt #{File.read(File.join(File.dirname(__FILE__), "../../VERSION"))}"
|
|
76
|
-
CLI.start(ARGV)
|
|
78
|
+
CLI.start(ARGV)
|
data/lib/volt/console.rb
CHANGED
|
@@ -7,15 +7,14 @@ class Console
|
|
|
7
7
|
|
|
8
8
|
require 'volt'
|
|
9
9
|
require 'volt/models'
|
|
10
|
-
require 'volt/server/template_parser'
|
|
11
10
|
require 'volt'
|
|
12
11
|
require 'volt/page/page'
|
|
13
12
|
require 'volt/server/rack/component_paths'
|
|
14
13
|
require 'volt/server/socket_connection_handler_stub'
|
|
15
|
-
|
|
14
|
+
|
|
16
15
|
SocketConnectionHandlerStub.dispatcher = Dispatcher.new
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
|
|
17
|
+
|
|
19
18
|
app_path = File.expand_path(File.join(Dir.pwd, "app"))
|
|
20
19
|
component_paths = ComponentPaths.new
|
|
21
20
|
component_paths.require_in_components
|
|
@@ -24,7 +23,7 @@ class Console
|
|
|
24
23
|
|
|
25
24
|
# start a REPL session
|
|
26
25
|
# Pry.start
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
Page.new.pry
|
|
29
28
|
end
|
|
30
|
-
end
|
|
29
|
+
end
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
class ModelController
|
|
1
|
+
class ModelController
|
|
2
2
|
def self.model(val)
|
|
3
3
|
@@default_model = val
|
|
4
4
|
end
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
# Sets the current model on this controller
|
|
7
7
|
def model(val)
|
|
8
|
-
if
|
|
8
|
+
if Symbol === val || String === val
|
|
9
9
|
collections = [:page, :store, :params]
|
|
10
10
|
if collections.include?(val.to_sym)
|
|
11
11
|
@model = self.send(val)
|
|
12
12
|
else
|
|
13
13
|
raise "#{val} is not the name of a valid model, choose from: #{collections.join(', ')}"
|
|
14
14
|
end
|
|
15
|
-
elsif
|
|
16
|
-
@model =
|
|
15
|
+
elsif val
|
|
16
|
+
@model = val
|
|
17
17
|
else
|
|
18
|
-
raise "model can not be #{
|
|
18
|
+
raise "model can not be #{val.inspect}"
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
def self.new(*args, &block)
|
|
23
23
|
inst = self.allocate
|
|
24
24
|
if @@default_model
|
|
25
25
|
inst.model(@@default_model || :page)
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
inst.initialize(*args, &block)
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
return inst
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def page
|
|
34
34
|
$page.page
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
def paged
|
|
38
38
|
$page.page
|
|
39
39
|
end
|
|
@@ -47,26 +47,26 @@ class ModelController
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def params
|
|
50
|
-
$page.params
|
|
50
|
+
$page.params
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def url
|
|
54
|
-
$page.url
|
|
54
|
+
$page.url
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
def channel
|
|
58
58
|
$page.channel
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
def tasks
|
|
62
62
|
$page.tasks
|
|
63
63
|
end
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
def controller
|
|
66
66
|
@controller ||= ReactiveValue.new(Model.new)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def method_missing(method_name, *args, &block)
|
|
70
|
-
return @model.send(method_name, *args, &block)
|
|
70
|
+
return @model.send(method_name, *args, &block)
|
|
71
71
|
end
|
|
72
|
-
end
|
|
72
|
+
end
|
data/lib/volt/extra_core/hash.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
class Object
|
|
2
2
|
# Setup a default pretty_inspect
|
|
3
3
|
# alias_method :pretty_inspect, :inspect
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
def instance_values
|
|
6
6
|
Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }]
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
# Provides the same functionality as ||, but since ReactiveValue's only
|
|
10
10
|
# work with method calls, we provide .or as a convience.
|
|
11
11
|
def or(other)
|
|
@@ -15,7 +15,7 @@ class Object
|
|
|
15
15
|
return other
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
# Provides the same functionality as &&, but since ReactiveValue's only
|
|
20
20
|
# work with method calls, we provide .and as a convience
|
|
21
21
|
def and(other)
|
|
@@ -25,7 +25,7 @@ class Object
|
|
|
25
25
|
return self
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
def try(*a, &b)
|
|
30
30
|
if a.empty? && block_given?
|
|
31
31
|
yield self
|
|
@@ -33,8 +33,8 @@ class Object
|
|
|
33
33
|
__send__(*a, &b)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
def deep_cur
|
|
38
38
|
self.cur
|
|
39
39
|
end
|
|
40
|
-
end
|
|
40
|
+
end
|
|
@@ -4,11 +4,11 @@ class String
|
|
|
4
4
|
def camelize
|
|
5
5
|
self.split("_").map {|s| s.capitalize }.join("")
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def underscore
|
|
9
9
|
self.scan(/[A-Z][a-z]*/).join("_").downcase
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
def pluralize
|
|
13
13
|
# TODO: Temp implementation
|
|
14
14
|
if self[-1] != 's'
|
|
@@ -17,7 +17,7 @@ class String
|
|
|
17
17
|
return self
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
def singularize
|
|
22
22
|
# TODO: Temp implementation
|
|
23
23
|
if self[-1] == 's'
|
|
@@ -26,14 +26,14 @@ class String
|
|
|
26
26
|
return self
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def plural?
|
|
31
31
|
# TODO: Temp implementation
|
|
32
32
|
self[-1] == 's'
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
def singular?
|
|
36
36
|
# TODO: Temp implementation
|
|
37
37
|
self[-1] != 's'
|
|
38
38
|
end
|
|
39
|
-
end
|
|
39
|
+
end
|
|
@@ -2,19 +2,19 @@ class Symbol
|
|
|
2
2
|
def camelize
|
|
3
3
|
to_s.camelize.to_sym
|
|
4
4
|
end
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
def underscore
|
|
7
7
|
to_s.underscore.to_sym
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
def pluralize
|
|
11
11
|
to_s.pluralize.to_sym
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def singularize
|
|
15
15
|
to_s.singularize.to_sym
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def plural?
|
|
19
19
|
to_s.plural?
|
|
20
20
|
end
|
|
@@ -22,4 +22,4 @@ class Symbol
|
|
|
22
22
|
def singular?
|
|
23
23
|
to_s.singular?
|
|
24
24
|
end
|
|
25
|
-
end
|
|
25
|
+
end
|
data/lib/volt/extra_core/time.rb
CHANGED
|
@@ -6,7 +6,7 @@ class Object
|
|
|
6
6
|
def true?
|
|
7
7
|
true
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
def false?
|
|
11
11
|
false
|
|
12
12
|
end
|
|
@@ -16,7 +16,7 @@ class FalseClass
|
|
|
16
16
|
def true?
|
|
17
17
|
false
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def false?
|
|
21
21
|
true
|
|
22
22
|
end
|
|
@@ -26,7 +26,7 @@ class NilClass
|
|
|
26
26
|
def true?
|
|
27
27
|
false
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def false?
|
|
31
31
|
true
|
|
32
32
|
end
|
|
@@ -37,8 +37,8 @@ class Boolean
|
|
|
37
37
|
def true?
|
|
38
38
|
self
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
def false?
|
|
42
42
|
self
|
|
43
|
-
end
|
|
44
|
-
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/volt/extra_core/try.rb
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
class Object
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
class TryProxy
|
|
4
4
|
def initialize(original)
|
|
5
5
|
@original = original
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def method_missing(method_name, *args, &block)
|
|
9
9
|
if @original.respond_to?(method_name)
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
else
|
|
12
12
|
NilProxy.new
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
class NilProxy
|
|
18
18
|
def method_missing(method_name, *args, &block)
|
|
19
19
|
if @original.respond_to?(method_name)
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
else
|
|
22
22
|
NilProxy.new
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def try
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
end
|
|
30
|
-
|
|
31
|
-
end
|
|
30
|
+
|
|
31
|
+
end
|