excursion 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/excursion/pool/application.rb +9 -3
- data/lib/excursion/pool/dsl.rb +30 -0
- data/lib/excursion/pool.rb +35 -7
- data/lib/excursion/version.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/log/development.log +46193 -0
- data/spec/excursion/pool/dsl_spec.rb +99 -0
- data/spec/excursion/pool_spec.rb +47 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31ae3beacdf213dacf60c6fe3030b3e7a15edc8e
|
4
|
+
data.tar.gz: 06beac4115e7521cc821013cbdb17b8e11f55ff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b4f9dc9c685b6d9c0ebff8565a057342c7ba05c154ddd59567c5d584c6801fb297d297f151c7dc6064163c7e8bb0f183afe652008f26b6b3c6fcc8d073be384
|
7
|
+
data.tar.gz: 025ef5e40dc828570a9b1094bdd1ceca843ebf879a5b10aeec3f61d9477ab70c1189ebb0ee7f6c3d376bf4d53b5ca6f1b1666891a96365df64e97e977bd467e1
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Excursion
|
2
2
|
module Pool
|
3
3
|
class Application
|
4
|
-
|
4
|
+
attr_accessor :name, :default_url_options
|
5
5
|
|
6
6
|
def self.from_cache(cached)
|
7
7
|
new(cached[:name], cached) unless cached.nil?
|
@@ -11,6 +11,11 @@ module Excursion
|
|
11
11
|
routes[key.to_sym]
|
12
12
|
end
|
13
13
|
|
14
|
+
def add_route(key, route)
|
15
|
+
route = journey_route(key, Rails.application, journey_path(route), {required_defaults: []}) unless route.is_a?(journey_route_class)
|
16
|
+
routes.add(key.to_sym, route)
|
17
|
+
end
|
18
|
+
|
14
19
|
def routes
|
15
20
|
@routes ||= ActionDispatch::Routing::RouteSet::NamedRouteCollection.new
|
16
21
|
end
|
@@ -20,7 +25,8 @@ module Excursion
|
|
20
25
|
raise ArgumentError, 'routes must be a Hash or NamedRouteCollection' unless routes.is_a?(Hash)
|
21
26
|
@routes = ActionDispatch::Routing::RouteSet::NamedRouteCollection.new
|
22
27
|
routes.each do |name, route|
|
23
|
-
|
28
|
+
route = journey_route(name, Rails.application, journey_path(route), {required_defaults: []}) unless route.is_a?(journey_route_class)
|
29
|
+
@routes.add(name.to_sym, route)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
@@ -54,7 +60,7 @@ module Excursion
|
|
54
60
|
def routes_from_cache(routes)
|
55
61
|
collection = ActionDispatch::Routing::RouteSet::NamedRouteCollection.new
|
56
62
|
routes.each do |name, path|
|
57
|
-
collection.add(name, journey_route(name, Rails.application, journey_path(path), {required_defaults: []}))
|
63
|
+
collection.add(name.to_sym, journey_route(name, Rails.application, journey_path(path), {required_defaults: []}))
|
58
64
|
end
|
59
65
|
collection
|
60
66
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Excursion
|
2
|
+
module Pool
|
3
|
+
class DSL
|
4
|
+
|
5
|
+
def self.block_eval(app=nil, &block)
|
6
|
+
@application = app.is_a?(Excursion::Pool::Application) ? app : Excursion::Pool::Application.new('', {})
|
7
|
+
instance_eval &block if block_given?
|
8
|
+
|
9
|
+
raise "You must assign a name to the application" if @application.name.blank?
|
10
|
+
@application
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.name(name_str)
|
14
|
+
@application.name = name_str
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.default_url_options(url_options)
|
18
|
+
@application.default_url_options = url_options
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.routes(route_hash)
|
22
|
+
@application.routes = route_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.route(name, path)
|
26
|
+
@application.add_route(name.to_sym, path)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/excursion/pool.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'excursion/pool/application'
|
2
|
+
require 'excursion/pool/dsl'
|
2
3
|
require 'excursion/exceptions/pool'
|
3
4
|
require 'excursion/exceptions/datastores'
|
4
5
|
|
@@ -7,7 +8,9 @@ module Excursion
|
|
7
8
|
@@applications = {}
|
8
9
|
|
9
10
|
def self.all_applications
|
10
|
-
datastore.all_apps
|
11
|
+
datastore.all_apps.each do |app|
|
12
|
+
@@applications[app.name] = app
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
def self.application(name)
|
@@ -16,14 +19,39 @@ module Excursion
|
|
16
19
|
@@applications[name] = datastore.app(name)
|
17
20
|
end
|
18
21
|
|
19
|
-
def self.register_application(app)
|
20
|
-
raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application)
|
22
|
+
def self.register_application(app=nil, opts={}, &block)
|
23
|
+
raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application) || block_given?
|
24
|
+
opts = {cache: true}.merge(opts)
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
if app.is_a?(Rails::Application)
|
27
|
+
name = app.class.name.underscore.split("/").first
|
28
|
+
config = {default_url_options: Excursion.configuration.default_url_options}
|
29
|
+
routes = app.routes.named_routes
|
30
|
+
@@applications[name] = Application.new(name, config, routes)
|
31
|
+
end
|
32
|
+
|
33
|
+
if block_given?
|
34
|
+
if @@applications.has_key?(name)
|
35
|
+
DSL.block_eval(@@applications[name], &block)
|
36
|
+
else
|
37
|
+
block_app = DSL.block_eval(&block)
|
38
|
+
name = block_app.name
|
39
|
+
@@applications[name] = block_app
|
40
|
+
end
|
41
|
+
end
|
24
42
|
|
25
|
-
@@applications[name]
|
26
|
-
|
43
|
+
datastore.set(name, @@applications[name].to_cache) if opts[:cache]
|
44
|
+
@@applications[name]
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.register_hash(app_hash)
|
48
|
+
raise ArgumentError, "you must provide at minimum a hash with a :name key" unless app_hash.is_a?(Hash) && app_hash.has_key?(:name)
|
49
|
+
|
50
|
+
app_hash = {default_url_options: Excursion.configuration.default_url_options, routes: {}, registered_at: Time.now}.merge(app_hash)
|
51
|
+
name = app_hash[:name]
|
52
|
+
|
53
|
+
datastore.set(name, app_hash)
|
54
|
+
@@applications[name] = datastore.app(name)
|
27
55
|
end
|
28
56
|
|
29
57
|
def self.remove_application(app)
|
data/lib/excursion/version.rb
CHANGED
@@ -53,7 +53,7 @@ module Dummy
|
|
53
53
|
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
54
|
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
55
|
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
-
config.active_record.whitelist_attributes = true
|
56
|
+
#config.active_record.whitelist_attributes = true
|
57
57
|
|
58
58
|
# Enable the asset pipeline
|
59
59
|
config.assets.enabled = true
|
@@ -21,11 +21,11 @@ Dummy::Application.configure do
|
|
21
21
|
config.action_dispatch.best_standards_support = :builtin
|
22
22
|
|
23
23
|
# Raise exception on mass assignment protection for Active Record models
|
24
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
24
|
+
#config.active_record.mass_assignment_sanitizer = :strict
|
25
25
|
|
26
26
|
# Log the query plan for queries taking more than this (works
|
27
27
|
# with SQLite, MySQL, and PostgreSQL)
|
28
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
28
|
+
#config.active_record.auto_explain_threshold_in_seconds = 0.5
|
29
29
|
|
30
30
|
# Do not compress assets
|
31
31
|
config.assets.compress = false
|
@@ -28,7 +28,7 @@ Dummy::Application.configure do
|
|
28
28
|
config.action_mailer.delivery_method = :test
|
29
29
|
|
30
30
|
# Raise exception on mass assignment protection for Active Record models
|
31
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
31
|
+
#config.active_record.mass_assignment_sanitizer = :strict
|
32
32
|
|
33
33
|
# Print deprecation notices to the stderr
|
34
34
|
config.active_support.deprecation = :stderr
|