padrino-core 0.12.2 → 0.12.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,14 +26,16 @@ module Padrino
26
26
  Padrino.logger
27
27
  end
28
28
 
29
- # TODO: Remove this hack after getting rid of thread-unsafe http_router:
30
- alias_method :original_call, :call
31
- def call(*args)
32
- settings.init_mutex.synchronize do
33
- instance_eval{ undef :call }
34
- class_eval{ alias_method :call, :original_call }
35
- instance_eval{ undef :original_call }
36
- super(*args)
29
+ # TODO: Remove this hack (issue #863) after getting rid of thread-unsafe http_router:
30
+ if RUBY_PLATFORM == "java"
31
+ alias_method :original_call, :call
32
+ def call(*args)
33
+ settings.init_mutex.synchronize do
34
+ instance_eval{ undef :call }
35
+ class_eval{ alias_method :call, :original_call }
36
+ instance_eval{ undef :original_call }
37
+ super(*args)
38
+ end
37
39
  end
38
40
  end
39
41
 
@@ -126,20 +128,6 @@ module Padrino
126
128
  Padrino.run!(options)
127
129
  end
128
130
 
129
- ##
130
- # @return [Array]
131
- # directory that need to be added to +$LOAD_PATHS+ from this application
132
- #
133
- def load_paths
134
- @_load_paths ||= [
135
- 'models',
136
- 'lib',
137
- 'mailers',
138
- 'controllers',
139
- 'helpers',
140
- ].map { |path| File.join(settings.root, path) }
141
- end
142
-
143
131
  ##
144
132
  # Returns default list of path globs to load as dependencies.
145
133
  # Appends custom dependency patterns to the be loaded for your Application.
@@ -161,7 +149,7 @@ module Padrino
161
149
  'controllers.rb',
162
150
  'helpers/**/*.rb',
163
151
  'helpers.rb',
164
- ].map { |file| Dir[File.join(settings.root, file)] }.flatten
152
+ ].map { |file| Dir.glob(File.join(settings.root, file)) }.flatten
165
153
  end
166
154
 
167
155
  ##
@@ -187,13 +175,18 @@ module Padrino
187
175
  set(option, *args, &block) unless respond_to?(option)
188
176
  end
189
177
 
178
+ # Deprecated
179
+ def load_paths
180
+ warn 'Padrino::Application#load_paths is deprecated. Please, use #prerequisites'
181
+ []
182
+ end
183
+
190
184
  protected
191
185
 
192
186
  ##
193
187
  # Requires all files within the application load paths.
194
188
  #
195
189
  def require_dependencies
196
- Padrino.set_load_paths(*load_paths)
197
190
  Padrino.require_dependencies(dependencies, :force => true)
198
191
  end
199
192
  end
@@ -1,47 +1,8 @@
1
- require 'thor'
1
+ require 'padrino-core/cli/launcher'
2
2
 
3
3
  module Padrino
4
4
  module Cli
5
-
6
- class Base < Thor
7
- include Thor::Actions
8
-
9
- class_option :chdir, :type => :string, :aliases => "-c", :desc => "Change to dir before starting."
10
- class_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development, :desc => "Padrino Environment."
11
- class_option :help, :type => :boolean, :desc => "Show help usage"
12
-
13
- desc "start", "Starts the Padrino application (alternatively use 's')."
14
- map "s" => :start
15
- method_option :server, :type => :string, :aliases => "-a", :desc => "Rack Handler (default: autodetect)"
16
- method_option :host, :type => :string, :aliases => "-h", :desc => "Bind to HOST address (default: 127.0.0.1)"
17
- method_option :port, :type => :numeric, :aliases => "-p", :desc => "Use PORT (default: 3000)"
18
- method_option :daemonize, :type => :boolean, :aliases => "-d", :desc => "Run daemonized in the background."
19
- method_option :pid, :type => :string, :aliases => "-i", :desc => "File to store pid."
20
- method_option :debug, :type => :boolean, :desc => "Set debugging flags."
21
- method_option :options, :type => :array, :aliases => "-O", :desc => "--options NAME=VALUE NAME2=VALUE2'. pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} --server_options"
22
- method_option :server_options, :type => :boolean, :desc => "Tells the current server handler's options that can be used with --options"
23
-
24
- def start(*args)
25
- prepare :start
26
- require File.expand_path("../adapter", __FILE__)
27
- require File.expand_path('config/boot.rb')
28
-
29
- if options[:server_options]
30
- puts server_options(options)
31
- else
32
- Padrino::Cli::Adapter.start(args.last ? options.merge(:config => args.last).freeze : options)
33
- end
34
- end
35
-
36
- desc "stop", "Stops the Padrino application (alternatively use 'st')."
37
- map "st" => :stop
38
- method_option :pid, :type => :string, :aliases => "-p", :desc => "File to store pid", :default => 'tmp/pids/server.pid'
39
- def stop
40
- prepare :stop
41
- require File.expand_path("../adapter", __FILE__)
42
- Padrino::Cli::Adapter.stop(options)
43
- end
44
-
5
+ class Base < Launcher
45
6
  desc "rake", "Execute rake tasks."
46
7
  method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
47
8
  method_option :list, :type => :string, :aliases => "-T", :desc => "Display the tasks (matching optional PATTERN) with descriptions, then exit."
@@ -120,61 +81,12 @@ module Padrino
120
81
  end
121
82
  end
122
83
 
123
- private
124
-
125
- def prepare(task)
126
- if options.help?
127
- help(task.to_s)
128
- raise SystemExit
129
- end
130
- ENV["RACK_ENV"] ||= options.environment.to_s
131
- chdir(options.chdir)
132
- unless File.exist?('config/boot.rb')
133
- puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
134
- raise SystemExit
135
- end
136
- end
137
-
138
- # https://github.com/rack/rack/blob/master/lib/rack/server.rb\#L100
139
- def server_options(options)
140
- begin
141
- info = []
142
- server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
143
- if server && server.respond_to?(:valid_options)
144
- info << ""
145
- info << "Server-specific options for #{server.name}:"
146
-
147
- has_options = false
148
- server.valid_options.each do |name, description|
149
- next if name.to_s.match(/^(Host|Port)[^a-zA-Z]/) # ignore handler's host and port options, we do our own.
150
- info << " -O %-21s %s" % [name, description]
151
- has_options = true
152
- end
153
- return "" if !has_options
154
- end
155
- info.join("\n")
156
- rescue NameError
157
- return "Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options"
158
- end
159
- end
160
-
161
84
  protected
162
85
 
163
86
  def self.banner(task=nil, *args)
164
87
  "padrino #{task.name}"
165
88
  end
166
89
 
167
- def chdir(dir)
168
- return unless dir
169
- begin
170
- Dir.chdir(dir.to_s)
171
- rescue Errno::ENOENT
172
- puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
173
- rescue Errno::EACCES
174
- puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
175
- end
176
- end
177
-
178
90
  def capture(stream)
179
91
  begin
180
92
  stream = stream.to_s
@@ -0,0 +1,95 @@
1
+ require 'thor'
2
+
3
+ module Padrino
4
+ module Cli
5
+ class Launcher < Thor
6
+ include Thor::Actions
7
+
8
+ class_option :chdir, :type => :string, :aliases => "-c", :desc => "Change to dir before starting."
9
+ class_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development, :desc => "Padrino Environment."
10
+ class_option :help, :type => :boolean, :desc => "Show help usage"
11
+
12
+ desc "start", "Starts the Padrino application (alternatively use 's')."
13
+ map "s" => :start
14
+ method_option :server, :type => :string, :aliases => "-a", :desc => "Rack Handler (default: autodetect)"
15
+ method_option :host, :type => :string, :aliases => "-h", :desc => "Bind to HOST address (default: 127.0.0.1)"
16
+ method_option :port, :type => :numeric, :aliases => "-p", :desc => "Use PORT (default: 3000)"
17
+ method_option :daemonize, :type => :boolean, :aliases => "-d", :desc => "Run daemonized in the background."
18
+ method_option :pid, :type => :string, :aliases => "-i", :desc => "File to store pid."
19
+ method_option :debug, :type => :boolean, :desc => "Set debugging flags."
20
+ method_option :options, :type => :array, :aliases => "-O", :desc => "--options NAME=VALUE NAME2=VALUE2'. pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} --server_options"
21
+ method_option :server_options, :type => :boolean, :desc => "Tells the current server handler's options that can be used with --options"
22
+ def start(*args)
23
+ prepare :start
24
+ require File.expand_path("../adapter", __FILE__)
25
+ require File.expand_path('config/boot.rb')
26
+
27
+ if options[:server_options]
28
+ puts server_options(options)
29
+ else
30
+ Padrino::Cli::Adapter.start(args.last ? options.merge(:config => args.last).freeze : options)
31
+ end
32
+ end
33
+
34
+ desc "stop", "Stops the Padrino application (alternatively use 'st')."
35
+ map "st" => :stop
36
+ method_option :pid, :type => :string, :aliases => "-p", :desc => "File to store pid", :default => 'tmp/pids/server.pid'
37
+ def stop
38
+ prepare :stop
39
+ require File.expand_path("../adapter", __FILE__)
40
+ Padrino::Cli::Adapter.stop(options)
41
+ end
42
+
43
+ private
44
+
45
+ # https://github.com/rack/rack/blob/master/lib/rack/server.rb\#L100
46
+ def server_options(options)
47
+ begin
48
+ info = []
49
+ server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
50
+ if server && server.respond_to?(:valid_options)
51
+ info << ""
52
+ info << "Server-specific options for #{server.name}:"
53
+
54
+ has_options = false
55
+ server.valid_options.each do |name, description|
56
+ next if name.to_s.match(/^(Host|Port)[^a-zA-Z]/) # ignore handler's host and port options, we do our own.
57
+ info << " -O %-21s %s" % [name, description]
58
+ has_options = true
59
+ end
60
+ return "" if !has_options
61
+ end
62
+ info.join("\n")
63
+ rescue NameError
64
+ return "Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options"
65
+ end
66
+ end
67
+
68
+ protected
69
+
70
+ def prepare(task)
71
+ if options.help?
72
+ help(task.to_s)
73
+ raise SystemExit
74
+ end
75
+ ENV["RACK_ENV"] ||= options.environment.to_s
76
+ chdir(options.chdir)
77
+ unless File.exist?('config/boot.rb')
78
+ puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
79
+ raise SystemExit
80
+ end
81
+ end
82
+
83
+ def chdir(dir)
84
+ return unless dir
85
+ begin
86
+ Dir.chdir(dir.to_s)
87
+ rescue Errno::ENOENT
88
+ puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
89
+ rescue Errno::EACCES
90
+ puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,181 @@
1
+ require 'http_router' unless defined?(HttpRouter)
2
+
3
+ class HttpRouter
4
+ def rewrite_partial_path_info(env, request); end
5
+ def rewrite_path_info(env, request); end
6
+
7
+ def process_destination_path(path, env)
8
+ Thread.current['padrino.instance'].instance_eval do
9
+ request.route_obj = path.route
10
+ @_response_buffer = nil
11
+ @route = path.route
12
+ @params ||= {}
13
+ @params.update(env['router.params'])
14
+ @block_params = if match_data = env['router.request'].extra_env['router.regex_match']
15
+ params_list = match_data.to_a
16
+ params_list.shift
17
+ @params[:captures] = params_list
18
+ params_list
19
+ else
20
+ env['router.request'].params
21
+ end
22
+ # Provide access to the current controller to the request
23
+ # Now we can eval route, but because we have "throw halt" we need to be
24
+ # (en)sure to reset old layout and run controller after filters.
25
+ original_params = @params
26
+ parent_layout = @layout
27
+ successful = false
28
+ begin
29
+ filter! :before
30
+ (@route.before_filters - settings.filters[:before]).each { |block| instance_eval(&block) }
31
+ @layout = path.route.use_layout if path.route.use_layout
32
+ @route.custom_conditions.each { |block| pass if block.bind(self).call == false }
33
+ halt_response = catch(:halt) { route_eval { @route.dest[self, @block_params] } }
34
+ @_response_buffer = halt_response.is_a?(Array) ? halt_response.last : halt_response
35
+ successful = true
36
+ halt halt_response
37
+ ensure
38
+ (@route.after_filters - settings.filters[:after]).each { |block| instance_eval(&block) } if successful
39
+ @layout = parent_layout
40
+ @params = original_params
41
+ end
42
+ end
43
+ end
44
+
45
+ class Route
46
+ VALID_HTTP_VERBS.replace %w[GET POST PUT PATCH DELETE HEAD OPTIONS LINK UNLINK]
47
+
48
+ attr_accessor :use_layout, :controller, :action, :cache, :cache_key, :cache_expires, :parent
49
+
50
+ def before_filters(&block)
51
+ @_before_filters ||= []
52
+ @_before_filters << block if block_given?
53
+
54
+ @_before_filters
55
+ end
56
+
57
+ def after_filters(&block)
58
+ @_after_filters ||= []
59
+ @_after_filters << block if block_given?
60
+
61
+ @_after_filters
62
+ end
63
+
64
+ def custom_conditions(&block)
65
+ @_custom_conditions ||= []
66
+ @_custom_conditions << block if block_given?
67
+
68
+ @_custom_conditions
69
+ end
70
+
71
+ def significant_variable_names
72
+ @significant_variable_names ||= if @original_path.is_a?(String)
73
+ @original_path.scan(/(^|[^\\])[:\*]([a-zA-Z0-9_]+)/).map{|p| p.last.to_sym}
74
+ elsif @original_path.is_a?(Regexp) and @original_path.respond_to?(:named_captures)
75
+ @original_path.named_captures.keys.map(&:to_sym)
76
+ else
77
+ []
78
+ end
79
+ end
80
+
81
+ def to(dest = nil, &dest_block)
82
+ @dest = dest || dest_block || raise("you didn't specify a destination")
83
+
84
+ @router.current_order ||= 0
85
+ @order = @router.current_order
86
+ @router.current_order += 1
87
+
88
+ if @dest.respond_to?(:url_mount=)
89
+ urlmount = UrlMount.new(@path_for_generation, @default_values || {}) # TODO url mount should accept nil here.
90
+ urlmount.url_mount = @router.url_mount if @router.url_mount
91
+ @dest.url_mount = urlmount
92
+ end
93
+ self
94
+ end
95
+
96
+ attr_accessor :order
97
+
98
+ end
99
+
100
+ attr_accessor :current_order
101
+
102
+ def sort!
103
+ @routes.sort!{ |a, b| a.order <=> b.order }
104
+ end
105
+
106
+ class Node::Glob
107
+ def to_code
108
+ id = root.next_counter
109
+ "request.params << (globbed_params#{id} = [])
110
+ until request.path.empty?
111
+ globbed_params#{id} << request.path.shift
112
+ #{super}
113
+ end
114
+ request.path[0,0] = globbed_params#{id}
115
+ request.params.pop"
116
+ end
117
+ end
118
+
119
+ class Node::SpanningRegex
120
+ def to_code
121
+ params_count = @ordered_indicies.size
122
+ whole_path_var = "whole_path#{root.next_counter}"
123
+ "#{whole_path_var} = request.joined_path
124
+ if match = #{@matcher.inspect}.match(#{whole_path_var}) and match.begin(0).zero?
125
+ _#{whole_path_var} = request.path.dup
126
+ " << param_capturing_code << "
127
+ remaining_path = #{whole_path_var}[match[0].size + (#{whole_path_var}[match[0].size] == ?/ ? 1 : 0), #{whole_path_var}.size]
128
+ request.path = remaining_path.split('/')
129
+ #{node_to_code}
130
+ request.path = _#{whole_path_var}
131
+ request.params.slice!(#{-params_count}, #{params_count})
132
+ end
133
+ "
134
+ end
135
+ end
136
+
137
+ # Monkey patching the Request class. Using Rack::Utils.unescape rather than
138
+ # URI.unescape which can't handle utf-8 chars
139
+ class Request
140
+ def initialize(path, rack_request)
141
+ @rack_request = rack_request
142
+ @path = path.split(/\//).map{|part| Rack::Utils.unescape(part) }
143
+ @path.shift if @path.first == ''
144
+ @path.push('') if path[-1] == ?/
145
+ @extra_env = {}
146
+ @params = []
147
+ @acceptable_methods = Set.new
148
+ end
149
+ end
150
+
151
+ class Node::Path
152
+ def to_code
153
+ path_ivar = inject_root_ivar(self)
154
+ "#{"if !callback && request.path.size == 1 && request.path.first == '' && (request.rack_request.head? || request.rack_request.get?) && request.rack_request.path_info[-1] == ?/
155
+ catch(:pass) do
156
+ response = ::Rack::Response.new
157
+ response.redirect(request.rack_request.path_info[0, request.rack_request.path_info.size - 1], 302)
158
+ return response.finish
159
+ end
160
+ end" if router.redirect_trailing_slash?}
161
+
162
+ #{"if request.#{router.ignore_trailing_slash? ? 'path_finished?' : 'path.empty?'}" unless route.match_partially}
163
+ catch(:pass) do
164
+ if callback
165
+ request.called = true
166
+ callback.call(Response.new(request, #{path_ivar}))
167
+ else
168
+ env = request.rack_request.dup.env
169
+ env['router.request'] = request
170
+ env['router.params'] ||= {}
171
+ #{"env['router.params'].merge!(Hash[#{param_names.inspect}.zip(request.params)])" if dynamic?}
172
+ env['router.params'] = env['router.params'].with_indifferent_access
173
+ @router.rewrite#{"_partial" if route.match_partially}_path_info(env, request)
174
+ response = @router.process_destination_path(#{path_ivar}, env)
175
+ return response unless router.pass_on_response(response)
176
+ end
177
+ end
178
+ #{"end" unless route.match_partially}"
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,29 @@
1
+ require 'sinatra/base'
2
+
3
+ ##
4
+ # Adds to Sinatra +controller+ informations
5
+ #
6
+ class Sinatra::Request
7
+ attr_accessor :route_obj
8
+
9
+ def controller
10
+ route_obj && route_obj.controller
11
+ end
12
+ def action
13
+ route_obj && route_obj.action
14
+ end
15
+ end
16
+
17
+ ##
18
+ # This patches Sinatra to accept UTF-8 urls on JRuby 1.7.6
19
+ #
20
+ if RUBY_ENGINE == 'jruby' && defined?(JRUBY_VERSION) && JRUBY_VERSION > '1.7.4'
21
+ class Sinatra::Base
22
+ class << self
23
+ alias_method :old_generate_method, :generate_method
24
+ def generate_method(method_name, &block)
25
+ old_generate_method(method_name.to_sym, &block)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,47 @@
1
+ module Padrino
2
+ class Filter
3
+ attr_reader :block
4
+
5
+ def initialize(mode, scoped_controller, options, args, &block)
6
+ @mode, @scoped_controller, @options, @args, @block = mode, scoped_controller, options, args, block
7
+ end
8
+
9
+ def apply?(request)
10
+ detect = match_with_arguments?(request) || match_with_options?(request)
11
+ detect ^ !@mode
12
+ end
13
+
14
+ def to_proc
15
+ if @args.empty? && @options.empty?
16
+ block
17
+ else
18
+ filter = self
19
+ proc { instance_eval(&filter.block) if filter.apply?(request) }
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def scoped_controller_name
26
+ @scoped_controller_name ||= Array(@scoped_controller).join("_")
27
+ end
28
+
29
+ def match_with_arguments?(request)
30
+ route, path = request.route_obj, request.path_info
31
+ @args.any? do |argument|
32
+ if argument.instance_of?(Symbol)
33
+ next unless route
34
+ name = route.name
35
+ argument == name || name == [scoped_controller_name, argument].join(" ").to_sym
36
+ else
37
+ argument === path
38
+ end
39
+ end
40
+ end
41
+
42
+ def match_with_options?(request)
43
+ user_agent = request.user_agent
44
+ @options.any?{|name, value| value === (name == :agent ? user_agent : request.send(name)) }
45
+ end
46
+ end
47
+ end
@@ -52,9 +52,7 @@ module Padrino
52
52
  began_at = Time.now
53
53
  @_called_from = first_caller
54
54
  set_encoding
55
- set_load_paths(*load_paths)
56
- Logger.setup!
57
- require_dependencies("#{root}/config/database.rb")
55
+ Padrino.logger
58
56
  Reloader.lock!
59
57
  before_load.each(&:call)
60
58
  require_dependencies(*dependency_paths)
@@ -71,9 +69,7 @@ module Padrino
71
69
  def clear!
72
70
  clear_middleware!
73
71
  mounted_apps.clear
74
- @_load_paths = nil
75
72
  @_dependency_paths = nil
76
- @_global_configuration = nil
77
73
  before_load.clear
78
74
  after_load.clear
79
75
  Reloader.clear!
@@ -134,9 +130,9 @@ module Padrino
134
130
  #
135
131
  def require_dependencies(*paths)
136
132
  options = paths.extract_options!.merge( :cyclic => true )
137
- files = paths.flatten.map{|path| Dir[path].sort_by{|v| v.count('/') }}.flatten.uniq
133
+ files = paths.flatten.map{ |path| Dir.glob(path).sort_by{ |filename| filename.count('/') } }.flatten.uniq
138
134
 
139
- while files.present?
135
+ until files.empty?
140
136
  error, fatal, loaded = nil, nil, nil
141
137
 
142
138
  files.dup.each do |file|
@@ -144,44 +140,21 @@ module Padrino
144
140
  Reloader.safe_load(file, options)
145
141
  files.delete(file)
146
142
  loaded = true
147
- rescue NameError, LoadError => e
148
- logger.devel "Cyclic dependency reload for #{e.class}: #{e.message}"
149
- error = e
150
- rescue Exception => e
151
- fatal = e
143
+ rescue NameError, LoadError => error
144
+ logger.devel "Cyclic dependency reload for #{error.class}: #{error.message}"
145
+ rescue Exception => fatal
152
146
  break
153
147
  end
154
148
  end
155
149
 
156
150
  if fatal || !loaded
157
- e = fatal || error
158
- logger.exception e, :short
159
- raise e
151
+ exception = fatal || error
152
+ logger.exception exception, :short
153
+ raise exception
160
154
  end
161
155
  end
162
156
  end
163
157
 
164
- ##
165
- # Concat to +$LOAD_PATH+ the given paths.
166
- #
167
- # @param [Array<String>] paths
168
- # The paths to concat.
169
- #
170
- def set_load_paths(*paths)
171
- load_paths.concat(paths).uniq!
172
- $LOAD_PATH.concat(paths).uniq!
173
- end
174
-
175
- ##
176
- # The used +$LOAD_PATHS+ from Padrino.
177
- #
178
- # @return [Array<String>]
179
- # The load paths used by Padrino.
180
- #
181
- def load_paths
182
- @_load_paths ||= load_paths_was.dup
183
- end
184
-
185
158
  ##
186
159
  # Returns default list of path globs to load as dependencies.
187
160
  # Appends custom dependency patterns to the be loaded for Padrino.
@@ -193,32 +166,36 @@ module Padrino
193
166
  # Padrino.dependency_paths << "#{Padrino.root}/uploaders/*.rb"
194
167
  #
195
168
  def dependency_paths
196
- @_dependency_paths ||= dependency_paths_was + module_paths
169
+ @_dependency_paths ||= default_dependency_paths + modules_dependency_paths
197
170
  end
198
171
 
199
- private
172
+ # Deprecated
173
+ def set_load_paths(*)
174
+ warn 'Padrino.set_load_paths is deprecated. Please, use $LOAD_PATH.concat(paths)'
175
+ []
176
+ end
200
177
 
201
- def module_paths
202
- modules.map(&:dependency_paths).flatten
178
+ # Deprecated
179
+ def load_paths
180
+ warn 'Padrino.load_paths is deprecated. Please, use Padrino::Application#prerequisites'
181
+ []
203
182
  end
204
183
 
205
- def load_paths_was
206
- @_load_paths_was ||= [
207
- "#{root}/lib",
208
- "#{root}/models",
209
- "#{root}/shared",
210
- ].freeze
184
+ private
185
+
186
+ def modules_dependency_paths
187
+ modules.map(&:dependency_paths).flatten
211
188
  end
212
189
 
213
- def dependency_paths_was
214
- @_dependency_paths_was ||= [
190
+ def default_dependency_paths
191
+ @default_dependency_paths ||= [
215
192
  "#{root}/config/database.rb",
216
193
  "#{root}/lib/**/*.rb",
217
194
  "#{root}/models/**/*.rb",
218
195
  "#{root}/shared/lib/**/*.rb",
219
196
  "#{root}/shared/models/**/*.rb",
220
- "#{root}/config/apps.rb"
221
- ].freeze
197
+ "#{root}/config/apps.rb",
198
+ ]
222
199
  end
223
200
  end
224
201
  end