padrino-core 0.10.5 → 0.10.6.a
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.
- data/lib/padrino-core.rb +0 -15
- data/lib/padrino-core/application/routing.rb +38 -29
- data/lib/padrino-core/cli/base.rb +2 -4
- data/lib/padrino-core/locale/lv.yml +2 -2
- data/lib/padrino-core/server.rb +1 -1
- data/lib/padrino-core/version.rb +1 -1
- data/padrino-core.gemspec +1 -1
- data/test/helper.rb +2 -0
- data/test/test_core.rb +0 -2
- data/test/test_routing.rb +7 -0
- metadata +47 -9
data/lib/padrino-core.rb
CHANGED
@@ -112,21 +112,6 @@ module Padrino
|
|
112
112
|
nil
|
113
113
|
end
|
114
114
|
|
115
|
-
##
|
116
|
-
# Determines whether the dependencies are locked by Bundler.
|
117
|
-
# otherwise return nil
|
118
|
-
#
|
119
|
-
# @return [:locked, :unlocked, nil]
|
120
|
-
# Returns +:locked+ if the +Gemfile.lock+ file exists, or +:unlocked+
|
121
|
-
# if only the +Gemfile+ exists.
|
122
|
-
#
|
123
|
-
# @deprecated Will be removed in 1.0.0
|
124
|
-
#
|
125
|
-
def bundle
|
126
|
-
return :locked if File.exist?(root('Gemfile.lock'))
|
127
|
-
return :unlocked if File.exist?(root("Gemfile"))
|
128
|
-
end
|
129
|
-
|
130
115
|
##
|
131
116
|
# A Rack::Builder object that allows to add middlewares in front of all
|
132
117
|
# Padrino applications.
|
@@ -519,24 +519,24 @@ module Padrino
|
|
519
519
|
# Rewrite default routes.
|
520
520
|
#
|
521
521
|
# @example
|
522
|
-
# get :index
|
523
|
-
# get :index, "/"
|
524
|
-
# get :index, :map => "/"
|
525
|
-
# get :show, "/show-me"
|
526
|
-
# get :show, :map => "/show-me"
|
527
|
-
# get "/foo/bar"
|
528
|
-
# get :index, :parent => :user
|
529
|
-
# get :show, :with => :id, :parent => :user
|
530
|
-
# get :show, :with => :id
|
531
|
-
# get [:show, :id]
|
532
|
-
# get :show, :with => [:id, :name]
|
533
|
-
# get [:show, :id, :name]
|
534
|
-
# get :list, :provides => :js
|
535
|
-
# get :list, :provides => :any
|
536
|
-
# get :list, :provides => [:js, :json]
|
537
|
-
# get :list, :provides => [:html, :js, :json]
|
538
|
-
# get :list, :priority => :low
|
539
|
-
#
|
522
|
+
# get :index # => "/"
|
523
|
+
# get :index, "/" # => "/"
|
524
|
+
# get :index, :map => "/" # => "/"
|
525
|
+
# get :show, "/show-me" # => "/show-me"
|
526
|
+
# get :show, :map => "/show-me" # => "/show-me"
|
527
|
+
# get "/foo/bar" # => "/show"
|
528
|
+
# get :index, :parent => :user # => "/user/:user_id/index"
|
529
|
+
# get :show, :with => :id, :parent => :user # => "/user/:user_id/show/:id"
|
530
|
+
# get :show, :with => :id # => "/show/:id"
|
531
|
+
# get [:show, :id] # => "/show/:id"
|
532
|
+
# get :show, :with => [:id, :name] # => "/show/:id/:name"
|
533
|
+
# get [:show, :id, :name] # => "/show/:id/:name"
|
534
|
+
# get :list, :provides => :js # => "/list.{:format,js)"
|
535
|
+
# get :list, :provides => :any # => "/list(.:format)"
|
536
|
+
# get :list, :provides => [:js, :json] # => "/list.{!format,js|json}"
|
537
|
+
# get :list, :provides => [:html, :js, :json] # => "/list(.{!format,js|json})"
|
538
|
+
# get :list, :priority => :low # Defers route to be last
|
539
|
+
# get /pattern/, :name => :foo, :generate_with => '/foo' # Generates :foo as /foo
|
540
540
|
def route(verb, path, *args, &block)
|
541
541
|
options = case args.size
|
542
542
|
when 2
|
@@ -557,7 +557,7 @@ module Padrino
|
|
557
557
|
route_options = options.dup
|
558
558
|
route_options[:provides] = @_provides if @_provides
|
559
559
|
path, *route_options[:with] = path if path.is_a?(Array)
|
560
|
-
path, name, options = *parse_route(path, route_options, verb)
|
560
|
+
path, name, options, route_options = *parse_route(path, route_options, verb)
|
561
561
|
options.reverse_merge!(@_conditions) if @_conditions
|
562
562
|
|
563
563
|
# Sinatra defaults
|
@@ -571,7 +571,7 @@ module Padrino
|
|
571
571
|
invoke_hook(:route_added, verb, path, block)
|
572
572
|
|
573
573
|
# HTTPRouter route construction
|
574
|
-
route = router.add(path)
|
574
|
+
route = router.add(path, route_options)
|
575
575
|
route.name(name) if name
|
576
576
|
priority_name = options.delete(:priority) || :normal
|
577
577
|
priority = ROUTE_PRIORITY[priority_name] or raise("Priority #{priority_name} not recognized, try #{ROUTE_PRIORITY.keys.join(', ')}")
|
@@ -620,6 +620,9 @@ module Padrino
|
|
620
620
|
# We need save our originals path/options so we can perform correctly cache.
|
621
621
|
original = [path, options.dup]
|
622
622
|
|
623
|
+
# options for the route directly
|
624
|
+
route_options = {}
|
625
|
+
|
623
626
|
# We need check if path is a symbol, if that it's a named route
|
624
627
|
map = options.delete(:map)
|
625
628
|
|
@@ -628,7 +631,11 @@ module Padrino
|
|
628
631
|
path = map ? map.dup : (path == :index ? '/' : path.to_s) # The route path
|
629
632
|
end
|
630
633
|
|
631
|
-
|
634
|
+
# Build our controller
|
635
|
+
controller = Array(@_controller).map { |c| c.to_s }
|
636
|
+
|
637
|
+
case path
|
638
|
+
when String # path i.e "/index" or "/show"
|
632
639
|
# Now we need to parse our 'with' params
|
633
640
|
if with_params = options.delete(:with)
|
634
641
|
path = process_path_for_with_params(path, with_params)
|
@@ -643,9 +650,6 @@ module Padrino
|
|
643
650
|
options[:matching][:format] = /[^\.]+/
|
644
651
|
end
|
645
652
|
|
646
|
-
# Build our controller
|
647
|
-
controller = Array(@_controller).map { |c| c.to_s }
|
648
|
-
|
649
653
|
absolute_map = map && map[0] == ?/
|
650
654
|
|
651
655
|
unless controller.empty?
|
@@ -656,10 +660,6 @@ module Padrino
|
|
656
660
|
path = File.join(controller_path, path)
|
657
661
|
end
|
658
662
|
# Here we build the correct name route
|
659
|
-
if name
|
660
|
-
controller_name = controller.join("_")
|
661
|
-
name = "#{controller_name}_#{name}".to_sym unless controller_name.blank?
|
662
|
-
end
|
663
663
|
end
|
664
664
|
|
665
665
|
# Now we need to parse our 'parent' params and parent scope
|
@@ -678,12 +678,21 @@ module Padrino
|
|
678
678
|
path.sub!(%r{/(\))?$}, '\\1') if path != "/" # Remove latest trailing delimiter
|
679
679
|
path.gsub!(/\/(\(\.|$)/, '\\1') # Remove trailing slashes
|
680
680
|
path.squeeze!('/')
|
681
|
+
when Regexp
|
682
|
+
route_options[:path_for_generation] = options.delete(:generate_with) if options.key?(:generate_with)
|
683
|
+
end
|
684
|
+
|
685
|
+
name = options.delete(:route_name) if name.nil? && options.key?(:route_name)
|
686
|
+
name = options.delete(:name) if name.nil? && options.key?(:name)
|
687
|
+
if name
|
688
|
+
controller_name = controller.join("_")
|
689
|
+
name = "#{controller_name}_#{name}".to_sym unless controller_name.blank?
|
681
690
|
end
|
682
691
|
|
683
692
|
# Merge in option defaults
|
684
693
|
options.reverse_merge!(:default_values => @_defaults)
|
685
694
|
|
686
|
-
[path, name, options]
|
695
|
+
[path, name, options, route_options]
|
687
696
|
end
|
688
697
|
|
689
698
|
##
|
@@ -41,7 +41,6 @@ module Padrino
|
|
41
41
|
method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
|
42
42
|
method_option :list, :type => :string, :aliases => "-T", :desc => "Display the tasks (matching optional PATTERN) with descriptions, then exit."
|
43
43
|
method_option :trace, :type => :boolean, :aliases => "-t", :desc => "Turn on invoke/execute tracing, enable full backtrace."
|
44
|
-
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Log message to standard output."
|
45
44
|
def rake(*args)
|
46
45
|
prepare :rake
|
47
46
|
args << "-T" if options[:list]
|
@@ -51,9 +50,8 @@ module Padrino
|
|
51
50
|
ARGV.clear
|
52
51
|
ARGV.concat(args)
|
53
52
|
puts "=> Executing Rake #{ARGV.join(' ')} ..."
|
54
|
-
ENV['PADRINO_LOG_LEVEL'] ||= "test"
|
55
53
|
load File.expand_path('../rake.rb', __FILE__)
|
56
|
-
|
54
|
+
require File.expand_path('config/boot.rb')
|
57
55
|
PadrinoTasks.init(true)
|
58
56
|
end
|
59
57
|
|
@@ -80,7 +78,7 @@ module Padrino
|
|
80
78
|
require 'padrino-core/command'
|
81
79
|
require 'padrino-gen/command'
|
82
80
|
ARGV.shift
|
83
|
-
Padrino.bin_gen(ARGV)
|
81
|
+
Padrino.bin_gen(*ARGV)
|
84
82
|
rescue
|
85
83
|
puts "<= You need padrino-gen! Run: gem install padrino-gen"
|
86
84
|
end
|
@@ -4,7 +4,7 @@ lv:
|
|
4
4
|
# Use the strftime parameters for formats.
|
5
5
|
# When no format has been given, it uses default.
|
6
6
|
# You can provide other formats here if you like!
|
7
|
-
default: "%d.%m.%Y
|
7
|
+
default: "%d.%m.%Y"
|
8
8
|
short: "%e. %B"
|
9
9
|
long: "%Y. gada %e. %B"
|
10
10
|
only_day: "%e"
|
@@ -21,7 +21,7 @@ lv:
|
|
21
21
|
time:
|
22
22
|
formats:
|
23
23
|
default: "%Y. gada %e. %B, %H:%M"
|
24
|
-
short: "%d.%m.%Y
|
24
|
+
short: "%d.%m.%Y, %H:%M"
|
25
25
|
long: "%Y. gada %e. %B, %H:%M:%S"
|
26
26
|
am: "priekšpusdiena"
|
27
27
|
pm: "pēcpusdiena"
|
data/lib/padrino-core/server.rb
CHANGED
@@ -44,7 +44,7 @@ module Padrino
|
|
44
44
|
[:INT, :TERM].each { |sig| trap(sig) { exit } }
|
45
45
|
super
|
46
46
|
ensure
|
47
|
-
puts "<= Padrino
|
47
|
+
puts "<= Padrino leaves the gun, takes the cannoli" unless options[:daemonize]
|
48
48
|
end
|
49
49
|
|
50
50
|
# The application the server will run.
|
data/lib/padrino-core/version.rb
CHANGED
data/padrino-core.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_dependency("sinatra", "~> 1.3.1")
|
35
35
|
s.add_dependency("http_router", "~> 0.10.2")
|
36
36
|
s.add_dependency("thor", "~> 0.14.3")
|
37
|
-
s.add_dependency("activesupport", "~> 3.
|
37
|
+
s.add_dependency("activesupport", "~> 3.2.0")
|
38
38
|
end
|
data/test/helper.rb
CHANGED
data/test/test_core.rb
CHANGED
@@ -15,7 +15,6 @@ describe "Core" do
|
|
15
15
|
assert_respond_to Padrino, :load!
|
16
16
|
assert_respond_to Padrino, :reload!
|
17
17
|
assert_respond_to Padrino, :version
|
18
|
-
assert_respond_to Padrino, :bundle
|
19
18
|
assert_respond_to Padrino, :configure_apps
|
20
19
|
end
|
21
20
|
|
@@ -23,7 +22,6 @@ describe "Core" do
|
|
23
22
|
should 'validate global helpers' do
|
24
23
|
assert_equal :test, Padrino.env
|
25
24
|
assert_match /\/test/, Padrino.root
|
26
|
-
assert_equal nil, Padrino.bundle
|
27
25
|
assert_not_nil Padrino.version
|
28
26
|
end
|
29
27
|
|
data/test/test_routing.rb
CHANGED
@@ -78,6 +78,13 @@ describe "Routing" do
|
|
78
78
|
assert_equal "My lucky number: 99 99", body
|
79
79
|
end
|
80
80
|
|
81
|
+
should 'accept regexp routes with generate with :generate_with' do
|
82
|
+
mock_app do
|
83
|
+
get(%r{/fob|/baz}, :name => :foo, :generate_with => '/fob') { "regexp" }
|
84
|
+
end
|
85
|
+
assert_equal "/fob", @app.url(:foo)
|
86
|
+
end
|
87
|
+
|
81
88
|
should "parse routes with question marks" do
|
82
89
|
mock_app do
|
83
90
|
get("/foo/?"){ "okey" }
|
metadata
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 98
|
5
|
+
prerelease: 7
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 10
|
9
|
+
- 6
|
10
|
+
- a
|
11
|
+
version: 0.10.6.a
|
6
12
|
platform: ruby
|
7
13
|
authors:
|
8
14
|
- Padrino Team
|
@@ -13,8 +19,7 @@ autorequire:
|
|
13
19
|
bindir: bin
|
14
20
|
cert_chain: []
|
15
21
|
|
16
|
-
date:
|
17
|
-
default_executable:
|
22
|
+
date: 2012-01-23 00:00:00 Z
|
18
23
|
dependencies:
|
19
24
|
- !ruby/object:Gem::Dependency
|
20
25
|
name: tilt
|
@@ -24,6 +29,11 @@ dependencies:
|
|
24
29
|
requirements:
|
25
30
|
- - ~>
|
26
31
|
- !ruby/object:Gem::Version
|
32
|
+
hash: 27
|
33
|
+
segments:
|
34
|
+
- 1
|
35
|
+
- 3
|
36
|
+
- 0
|
27
37
|
version: 1.3.0
|
28
38
|
type: :runtime
|
29
39
|
version_requirements: *id001
|
@@ -35,6 +45,11 @@ dependencies:
|
|
35
45
|
requirements:
|
36
46
|
- - ~>
|
37
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 25
|
49
|
+
segments:
|
50
|
+
- 1
|
51
|
+
- 3
|
52
|
+
- 1
|
38
53
|
version: 1.3.1
|
39
54
|
type: :runtime
|
40
55
|
version_requirements: *id002
|
@@ -46,6 +61,11 @@ dependencies:
|
|
46
61
|
requirements:
|
47
62
|
- - ~>
|
48
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 51
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
- 10
|
68
|
+
- 2
|
49
69
|
version: 0.10.2
|
50
70
|
type: :runtime
|
51
71
|
version_requirements: *id003
|
@@ -57,6 +77,11 @@ dependencies:
|
|
57
77
|
requirements:
|
58
78
|
- - ~>
|
59
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 33
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
- 14
|
84
|
+
- 3
|
60
85
|
version: 0.14.3
|
61
86
|
type: :runtime
|
62
87
|
version_requirements: *id004
|
@@ -68,7 +93,12 @@ dependencies:
|
|
68
93
|
requirements:
|
69
94
|
- - ~>
|
70
95
|
- !ruby/object:Gem::Version
|
71
|
-
|
96
|
+
hash: 15
|
97
|
+
segments:
|
98
|
+
- 3
|
99
|
+
- 2
|
100
|
+
- 0
|
101
|
+
version: 3.2.0
|
72
102
|
type: :runtime
|
73
103
|
version_requirements: *id005
|
74
104
|
description: The Padrino core gem required for use of this framework
|
@@ -156,7 +186,6 @@ files:
|
|
156
186
|
- test/test_restful_routing.rb
|
157
187
|
- test/test_router.rb
|
158
188
|
- test/test_routing.rb
|
159
|
-
has_rdoc: true
|
160
189
|
homepage: http://www.padrinorb.com
|
161
190
|
licenses: []
|
162
191
|
|
@@ -170,17 +199,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
199
|
requirements:
|
171
200
|
- - ">="
|
172
201
|
- !ruby/object:Gem::Version
|
202
|
+
hash: 3
|
203
|
+
segments:
|
204
|
+
- 0
|
173
205
|
version: "0"
|
174
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
207
|
none: false
|
176
208
|
requirements:
|
177
|
-
- - "
|
209
|
+
- - ">"
|
178
210
|
- !ruby/object:Gem::Version
|
179
|
-
|
211
|
+
hash: 25
|
212
|
+
segments:
|
213
|
+
- 1
|
214
|
+
- 3
|
215
|
+
- 1
|
216
|
+
version: 1.3.1
|
180
217
|
requirements: []
|
181
218
|
|
182
219
|
rubyforge_project: padrino-core
|
183
|
-
rubygems_version: 1.
|
220
|
+
rubygems_version: 1.8.15
|
184
221
|
signing_key:
|
185
222
|
specification_version: 3
|
186
223
|
summary: The required Padrino core gem
|
@@ -211,3 +248,4 @@ test_files:
|
|
211
248
|
- test/test_restful_routing.rb
|
212
249
|
- test/test_router.rb
|
213
250
|
- test/test_routing.rb
|
251
|
+
has_rdoc:
|