volt 0.9.2 → 0.9.3.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +4 -0
- data/Gemfile +3 -0
- data/app/volt/assets/js/volt_js_polyfills.js +0 -1
- data/app/volt/assets/js/volt_watch.js +217 -0
- data/app/volt/models/user.rb +7 -2
- data/app/volt/tasks/query_tasks.rb +6 -0
- data/lib/volt/boot.rb +1 -1
- data/lib/volt/cli/generate.rb +1 -1
- data/lib/volt/config.rb +12 -2
- data/lib/volt/controllers/model_controller.rb +1 -1
- data/lib/volt/data_stores/base_adaptor_client.rb +34 -0
- data/lib/volt/data_stores/{base.rb → base_adaptor_server.rb} +1 -1
- data/lib/volt/data_stores/data_store.rb +23 -7
- data/lib/volt/models/array_model.rb +3 -2
- data/lib/volt/models/model.rb +29 -91
- data/lib/volt/models/{dirty.rb → model_helpers/dirty.rb} +0 -0
- data/lib/volt/models/{listener_tracker.rb → model_helpers/listener_tracker.rb} +0 -0
- data/lib/volt/models/model_helpers/model_change_helpers.rb +76 -0
- data/lib/volt/models/{model_helpers.rb → model_helpers/model_helpers.rb} +0 -0
- data/lib/volt/models/persistors/array_store.rb +2 -23
- data/lib/volt/models/persistors/query/normalizer.rb +0 -44
- data/{templates/project/lib/.empty_directory → lib/volt/models/validations/errors.rb} +0 -0
- data/lib/volt/models/{validations.rb → validations/validations.rb} +80 -26
- data/lib/volt/page/bindings/attribute_binding.rb +17 -3
- data/lib/volt/page/page.rb +1 -0
- data/lib/volt/reactive/eventable.rb +1 -0
- data/lib/volt/server.rb +2 -1
- data/lib/volt/server/component_templates.rb +66 -16
- data/lib/volt/server/forking_server.rb +16 -14
- data/lib/volt/server/html_parser/sandlebars_parser.rb +2 -0
- data/lib/volt/server/html_parser/view_scope.rb +2 -0
- data/lib/volt/server/rack/component_paths.rb +4 -2
- data/lib/volt/server/rack/opal_files.rb +4 -2
- data/lib/volt/server/socket_connection_handler.rb +5 -1
- data/lib/volt/server/template_handlers/handlers.rb +0 -0
- data/lib/volt/spec/setup.rb +23 -8
- data/lib/volt/tasks/dispatcher.rb +4 -0
- data/lib/volt/utils/promise_patch.rb +3 -0
- data/lib/volt/version.rb +1 -1
- data/spec/apps/kitchen_sink/Gemfile +5 -0
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +10 -0
- data/spec/apps/kitchen_sink/app/main/views/main/bindings.html +20 -0
- data/spec/apps/kitchen_sink/app/main/views/main/form.html +73 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
- data/spec/integration/bindings_spec.rb +33 -0
- data/spec/integration/user_spec.rb +51 -21
- data/spec/models/associations_spec.rb +8 -0
- data/spec/models/model_spec.rb +7 -0
- data/spec/models/user_spec.rb +20 -0
- data/spec/models/validations_spec.rb +2 -1
- data/spec/models/validators/block_validations_spec.rb +53 -0
- data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +10 -0
- data/spec/page/path_string_renderer_spec.rb +6 -0
- data/spec/reactive/eventable_spec.rb +24 -6
- data/spec/server/component_templates_spec.rb +21 -0
- data/spec/server/html_parser/sandlebars_parser_spec.rb +12 -13
- data/spec/server/html_parser/view_parser_spec.rb +3 -0
- data/spec/server/rack/asset_files_spec.rb +2 -2
- data/spec/server/rack/http_resource_spec.rb +10 -0
- data/spec/tasks/dispatcher_spec.rb +5 -0
- data/spec/tasks/user_tasks_spec.rb +59 -0
- data/spec/utils/task_argument_filtererer_spec.rb +6 -0
- data/templates/newgem/app/newgem/config/initializers/boot.rb +10 -0
- data/templates/newgem/lib/newgem.rb.tt +13 -0
- data/templates/project/Gemfile.tt +3 -0
- data/templates/project/app/main/lib/.empty_directory +0 -0
- data/volt.gemspec +3 -1
- metadata +24 -25
- data/lib/volt/data_stores/mongo_driver.rb +0 -69
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'volt/data_stores/base'
|
2
|
-
require 'mongo'
|
3
|
-
|
4
|
-
module Volt
|
5
|
-
class DataStore
|
6
|
-
class MongoDriver < Base
|
7
|
-
attr_reader :db, :mongo_db
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
if Volt.config.db_uri.present?
|
11
|
-
@mongo_db ||= Mongo::MongoClient.from_uri(Volt.config.db_uri)
|
12
|
-
@db ||= @mongo_db.db(Volt.config.db_uri.split('/').last || Volt.config.db_name)
|
13
|
-
else
|
14
|
-
@mongo_db ||= Mongo::MongoClient.new(Volt.config.db_host, Volt.config.db_path)
|
15
|
-
@db ||= @mongo_db.db(Volt.config.db_name)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def insert(collection, values)
|
20
|
-
@db[collection].insert(values)
|
21
|
-
end
|
22
|
-
|
23
|
-
def update(collection, values)
|
24
|
-
# TODO: Seems mongo is dumb and doesn't let you upsert with custom id's
|
25
|
-
begin
|
26
|
-
@db[collection].insert(values)
|
27
|
-
rescue Mongo::OperationFailure => error
|
28
|
-
# Really mongo client?
|
29
|
-
if error.message[/^11000[:]/]
|
30
|
-
# Update because the id already exists
|
31
|
-
update_values = values.dup
|
32
|
-
id = update_values.delete(:_id)
|
33
|
-
@db[collection].update({ _id: id }, update_values)
|
34
|
-
else
|
35
|
-
return { error: error.message }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
nil
|
40
|
-
end
|
41
|
-
|
42
|
-
def query(collection, query)
|
43
|
-
allowed_methods = %w(find skip limit)
|
44
|
-
|
45
|
-
cursor = @db[collection]
|
46
|
-
|
47
|
-
query.each do |query_part|
|
48
|
-
method_name, *args = query_part
|
49
|
-
|
50
|
-
unless allowed_methods.include?(method_name.to_s)
|
51
|
-
fail "`#{method_name}` is not part of a valid query"
|
52
|
-
end
|
53
|
-
|
54
|
-
cursor = cursor.send(method_name, *args)
|
55
|
-
end
|
56
|
-
|
57
|
-
cursor.to_a
|
58
|
-
end
|
59
|
-
|
60
|
-
def delete(collection, query)
|
61
|
-
@db[collection].remove(query)
|
62
|
-
end
|
63
|
-
|
64
|
-
def drop_database
|
65
|
-
db.connection.drop_database(Volt.config.db_name)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|