padrino-core 0.13.0.beta1 → 0.13.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/lib/padrino-core/application/routing.rb +1 -0
- data/lib/padrino-core/application/show_exceptions.rb +0 -29
- data/lib/padrino-core/cli/rake_tasks.rb +21 -8
- data/lib/padrino-core/mounter/application_extension.rb +55 -0
- data/lib/padrino-core/mounter.rb +6 -52
- data/lib/padrino-core/version.rb +1 -1
- data/padrino-core.gemspec +1 -3
- data/test/fixtures/apps/mountable_apps/rack_apps.rb +4 -0
- data/test/helper.rb +0 -1
- data/test/test_filters.rb +11 -0
- data/test/test_mounter.rb +1 -0
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9157558167a224779bc75315038e491ff4817df7
|
4
|
+
data.tar.gz: 7b3b6f87d38b17584c7b4f513279062e262c69ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 808a48bbb9e9ce5963a80e9ecfca40ec6122f3152efe6aecc150d1a8a6a8c87958b3efc1f3c391c4792fb5169c8d96e223f1783ac908a4a644c3b1ef0d56d060
|
7
|
+
data.tar.gz: 94db6c26a4c2162e15a550c58fabe704da50f9d3d7adbb0ee479364441ea697828ff7ad25c34ff917143f2ef7de04b2a380f4453d33c8eed4ed953421fba3abb
|
data/README.rdoc
CHANGED
@@ -4,35 +4,6 @@ module Padrino
|
|
4
4
|
#
|
5
5
|
# @private
|
6
6
|
class ShowExceptions < Sinatra::ShowExceptions
|
7
|
-
if Sinatra::VERSION <= '1.4.5'
|
8
|
-
def call(env)
|
9
|
-
@app.call(env)
|
10
|
-
rescue Exception => e
|
11
|
-
errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
|
12
|
-
|
13
|
-
if prefers_plain_text?(env)
|
14
|
-
content_type = "text/plain"
|
15
|
-
exception_string = dump_exception(e)
|
16
|
-
else
|
17
|
-
content_type = "text/html"
|
18
|
-
exception_string = pretty(env, e)
|
19
|
-
end
|
20
|
-
|
21
|
-
env["rack.errors"] = errors
|
22
|
-
|
23
|
-
# Post 893a2c50 in rack/rack, the #pretty method above, implemented in
|
24
|
-
# Rack::ShowExceptions, returns a String instead of an array.
|
25
|
-
body = Array(exception_string)
|
26
|
-
|
27
|
-
[
|
28
|
-
500,
|
29
|
-
{"Content-Type" => content_type,
|
30
|
-
"Content-Length" => Rack::Utils.bytesize(body.join).to_s},
|
31
|
-
body
|
32
|
-
]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
7
|
private
|
37
8
|
|
38
9
|
def frame_class(frame)
|
@@ -1,11 +1,3 @@
|
|
1
|
-
Dir["{lib/tasks/**,tasks/**,test,spec}/*.rake"].each do |file|
|
2
|
-
begin
|
3
|
-
load(file)
|
4
|
-
rescue LoadError => e
|
5
|
-
warn "#{file}: #{e.message}"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
1
|
# Loads the Padrino applications mounted within the project.
|
10
2
|
# Setting up the required environment for Padrino.
|
11
3
|
task :environment do
|
@@ -43,6 +35,19 @@ def list_app_routes(app, args)
|
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
38
|
+
def env_migration_version
|
39
|
+
version = ENV["MIGRATION_VERSION"]
|
40
|
+
if version.nil? && ENV["VERSION"]
|
41
|
+
deprecated = true
|
42
|
+
warn "Environment variable VERSION is deprecated, use MIGRATION_VERSION"
|
43
|
+
version = ENV["VERSION"]
|
44
|
+
end
|
45
|
+
version ? Integer(version) : nil
|
46
|
+
rescue ArgumentError
|
47
|
+
warn "Environment variable #{deprecated ? '' : 'MIGRATION_'}VERSION=#{version} should be non-existant or Integer"
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
46
51
|
desc "Displays a listing of the named routes within a project, optionally only those matched by [query]"
|
47
52
|
task :routes, [:query] => :environment do |t, args|
|
48
53
|
Padrino.mounted_apps.each do |app|
|
@@ -57,3 +62,11 @@ namespace :routes do
|
|
57
62
|
list_app_routes(app, args) if app
|
58
63
|
end
|
59
64
|
end
|
65
|
+
|
66
|
+
Dir["{lib/tasks/**,tasks/**,test,spec}/*.rake"].each do |file|
|
67
|
+
begin
|
68
|
+
load(file)
|
69
|
+
rescue LoadError => e
|
70
|
+
warn "#{file}: #{e.message}"
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Padrino
|
2
|
+
class Mounter
|
3
|
+
module ApplicationExtension
|
4
|
+
attr_accessor :uri_root, :mounter_options
|
5
|
+
attr_writer :public_folder
|
6
|
+
|
7
|
+
def dependencies
|
8
|
+
@__dependencies ||= Dir.glob("#{root}/**/*.rb").delete_if { |path| path == app_file }
|
9
|
+
end
|
10
|
+
|
11
|
+
def prerequisites
|
12
|
+
@__prerequisites ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def app_file
|
16
|
+
@__app_file ||= trace_method(:app_file) { mounter_options[:app_file] }
|
17
|
+
end
|
18
|
+
|
19
|
+
def root
|
20
|
+
@__root ||= trace_method(:root) { File.expand_path("#{app_file}/../") }
|
21
|
+
end
|
22
|
+
|
23
|
+
def public_folder
|
24
|
+
@public_folder ||= trace_method(:public_folder) { "" }
|
25
|
+
end
|
26
|
+
|
27
|
+
def app_name
|
28
|
+
@__app_name ||= mounter_options[:app_name] || self.to_s.underscore.to_sym
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup_application!
|
32
|
+
@configured ||= trace_method(:setup_application!) do
|
33
|
+
$LOAD_PATH.concat(prerequisites)
|
34
|
+
require_dependencies if root.start_with?(Padrino.root)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def require_dependencies
|
42
|
+
Padrino.require_dependencies(dependencies, :force => true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def trace_method(method_name)
|
46
|
+
value = baseclass.send(method_name) if baseclass != self && baseclass.respond_to?(method_name)
|
47
|
+
value || yield
|
48
|
+
end
|
49
|
+
|
50
|
+
def baseclass
|
51
|
+
@__baseclass ||= respond_to?(:superclass) ? superclass : self
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/padrino-core/mounter.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'padrino-core/mounter/application_extension'
|
2
2
|
|
3
3
|
module Padrino
|
4
4
|
##
|
@@ -14,55 +14,6 @@ module Padrino
|
|
14
14
|
class MounterException < RuntimeError
|
15
15
|
end
|
16
16
|
|
17
|
-
class ApplicationWrapper < SimpleDelegator
|
18
|
-
attr_accessor :uri_root
|
19
|
-
attr_writer :public_folder
|
20
|
-
|
21
|
-
def initialize(app, options = {})
|
22
|
-
@options = options
|
23
|
-
super(app)
|
24
|
-
end
|
25
|
-
|
26
|
-
def dependencies
|
27
|
-
@__dependencies ||= Dir["#{root}/**/*.rb"]
|
28
|
-
end
|
29
|
-
|
30
|
-
def prerequisites
|
31
|
-
@__prerequisites ||= []
|
32
|
-
end
|
33
|
-
|
34
|
-
def app_file
|
35
|
-
return @__app_file if @__app_file
|
36
|
-
obj = __getobj__
|
37
|
-
@__app_file = obj.respond_to?(:app_file) ? obj.app_file : @options[:app_file]
|
38
|
-
end
|
39
|
-
|
40
|
-
def root
|
41
|
-
return @__root if @__root
|
42
|
-
obj = __getobj__
|
43
|
-
@__root = obj.respond_to?(:root) ? obj.root : File.expand_path("#{app_file}/../")
|
44
|
-
end
|
45
|
-
|
46
|
-
def public_folder
|
47
|
-
return @public_folder if @public_folder
|
48
|
-
obj = __getobj__
|
49
|
-
@public_folder = obj.respond_to?(:public_folder) ? obj.public_folder : ""
|
50
|
-
end
|
51
|
-
|
52
|
-
def app_name
|
53
|
-
@__app_name ||= @options[:app_name] || __getobj__.to_s.underscore.to_sym
|
54
|
-
end
|
55
|
-
|
56
|
-
def setup_application!
|
57
|
-
@configured ||=
|
58
|
-
begin
|
59
|
-
$LOAD_PATH.concat(prerequisites)
|
60
|
-
Padrino.require_dependencies(dependencies, :force => true) if root.start_with?(Padrino.root)
|
61
|
-
true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
17
|
attr_accessor :name, :uri_root, :app_file, :app_class, :app_root, :app_obj, :app_host, :cascade
|
67
18
|
|
68
19
|
##
|
@@ -83,7 +34,10 @@ module Padrino
|
|
83
34
|
@app_file = options[:app_file] || locate_app_file
|
84
35
|
@app_obj = options[:app_obj] || app_constant || locate_app_object
|
85
36
|
ensure_app_file! || ensure_app_object!
|
86
|
-
|
37
|
+
unless padrino_application?
|
38
|
+
@app_obj.extend ApplicationExtension
|
39
|
+
@app_obj.mounter_options = options
|
40
|
+
end
|
87
41
|
@app_root = options[:app_root] || (@app_obj.respond_to?(:root) && @app_obj.root || File.dirname(@app_file))
|
88
42
|
@uri_root = "/"
|
89
43
|
@cascade = options[:cascade] ? true == options[:cascade] ? DEFAULT_CASCADE.dup : Array(options[:cascade]) : []
|
@@ -174,7 +128,7 @@ module Padrino
|
|
174
128
|
def named_routes
|
175
129
|
app_obj.routes.map { |route|
|
176
130
|
route_name = route.name.to_s
|
177
|
-
route_name =
|
131
|
+
route_name =
|
178
132
|
if route.controller
|
179
133
|
route_name.split(" ", 2).map{|name| ":#{name}" }.join(", ")
|
180
134
|
else
|
data/lib/padrino-core/version.rb
CHANGED
data/padrino-core.gemspec
CHANGED
@@ -27,9 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
if ENV["SINATRA_EDGE"]
|
28
28
|
s.add_dependency("sinatra")
|
29
29
|
else
|
30
|
-
|
31
|
-
s.add_dependency("rack", "< 1.6.0")
|
32
|
-
s.add_dependency("sinatra", "~> 1.4.2")
|
30
|
+
s.add_dependency("sinatra", "~> 1.4.6")
|
33
31
|
end
|
34
32
|
s.add_dependency("mustermann19")
|
35
33
|
s.add_dependency("thor", "~> 0.18")
|
data/test/helper.rb
CHANGED
data/test/test_filters.rb
CHANGED
@@ -386,4 +386,15 @@ describe "Filters" do
|
|
386
386
|
assert_equal 'We broke after', body
|
387
387
|
assert_equal 'Been now and after', doodle
|
388
388
|
end
|
389
|
+
|
390
|
+
it 'should trigger filters if superclass responds to :filters' do
|
391
|
+
class FilterApp < Padrino::Application
|
392
|
+
before { @foo = "foo" }
|
393
|
+
end
|
394
|
+
mock_app FilterApp do
|
395
|
+
get("/") { @foo }
|
396
|
+
end
|
397
|
+
get "/"
|
398
|
+
assert_equal "foo", body
|
399
|
+
end
|
389
400
|
end
|
data/test/test_mounter.rb
CHANGED
@@ -269,6 +269,7 @@ describe "Mounter" do
|
|
269
269
|
assert_equal "hello sinatra app", res.body
|
270
270
|
res = Rack::MockRequest.new(app).get("/sinatra_app/static.html")
|
271
271
|
assert_equal "hello static file\n", res.body
|
272
|
+
assert_equal [], RackApp.prerequisites
|
272
273
|
end
|
273
274
|
|
274
275
|
it 'should support the Rack Application inside padrino project' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.0.
|
4
|
+
version: 0.13.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-support
|
@@ -19,42 +19,28 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.13.0.
|
22
|
+
version: 0.13.0.beta2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.13.0.
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rack
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
requirements:
|
34
|
-
- - <
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.6.0
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - <
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.6.0
|
29
|
+
version: 0.13.0.beta2
|
44
30
|
- !ruby/object:Gem::Dependency
|
45
31
|
name: sinatra
|
46
32
|
requirement: !ruby/object:Gem::Requirement
|
47
33
|
requirements:
|
48
34
|
- - ~>
|
49
35
|
- !ruby/object:Gem::Version
|
50
|
-
version: 1.4.
|
36
|
+
version: 1.4.6
|
51
37
|
type: :runtime
|
52
38
|
prerelease: false
|
53
39
|
version_requirements: !ruby/object:Gem::Requirement
|
54
40
|
requirements:
|
55
41
|
- - ~>
|
56
42
|
- !ruby/object:Gem::Version
|
57
|
-
version: 1.4.
|
43
|
+
version: 1.4.6
|
58
44
|
- !ruby/object:Gem::Dependency
|
59
45
|
name: mustermann19
|
60
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +136,7 @@ files:
|
|
150
136
|
- lib/padrino-core/logger.rb
|
151
137
|
- lib/padrino-core/module.rb
|
152
138
|
- lib/padrino-core/mounter.rb
|
139
|
+
- lib/padrino-core/mounter/application_extension.rb
|
153
140
|
- lib/padrino-core/path_router.rb
|
154
141
|
- lib/padrino-core/path_router/compiler.rb
|
155
142
|
- lib/padrino-core/path_router/error_handler.rb
|