padrino-core 0.14.0.rc1 → 0.14.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f66c818246cf52288c834007f8c222f4a3454e3b
4
- data.tar.gz: 7b5e2bdd2e2d5be9f6d5b1bba60acea97cefe4bc
3
+ metadata.gz: 8404b8357ac37d668e460e0d3c696917e6ff9856
4
+ data.tar.gz: 3db11b004865f9764c20d32c4e46593a6e72245b
5
5
  SHA512:
6
- metadata.gz: f492f4522edc15844bd53c497777df32f0694b5f567def36be94d14a202bacf13c1074f1c369e6f0e21f68f021c7f2866da4e786c6c4d53aea849d34b11c9fe7
7
- data.tar.gz: 83f4a64e0f95c10091a2be9f2bb8c4c6555bda8a761de454679089bc6f68b5ec2930bce948df1abc2448a900a75b86969ffaa4dbc5cfa99391ed3b8c7d4fdfe2
6
+ metadata.gz: 0fcac954da380e620eb81d654682c88c58b3a7693e2bc5b5826576588983a8e5fce2ea5a2315adaee44dc3c05640b6d95a234e5319cec9512aff2a132bbb0074
7
+ data.tar.gz: b733600e6602e99991f2a73dcac2cba57eb3e0fdfa7d4b03cb905b7f286f9f105e239aed3be9412df6d62b4546b5e62b4511eed9017d27dd772b1b583164b237
@@ -112,8 +112,8 @@ module Padrino
112
112
  # @return [NilClass]
113
113
  #
114
114
  def set_encoding
115
- Encoding.default_external = Encoding::UTF_8
116
- Encoding.default_internal = Encoding::UTF_8
115
+ # remove after 0.15
116
+ warn 'Warning! Padrino.set_encoding is deprecated. Padrino no longer manages ruby default encodings'
117
117
  nil
118
118
  end
119
119
 
@@ -185,11 +185,11 @@ module Padrino
185
185
  #
186
186
  # @overload redirect(url, status_code)
187
187
  # @param [String] url
188
- # @param [Fixnum] status_code
188
+ # @param [Integer] status_code
189
189
  #
190
190
  # @overload redirect(url, status_code, flash_messages)
191
191
  # @param [String] url
192
- # @param [Fixnum] status_code
192
+ # @param [Integer] status_code
193
193
  # @param [Hash] flash_messages
194
194
  #
195
195
  # @overload redirect(url, flash_messages)
@@ -1,3 +1,5 @@
1
+ require 'padrino-support'
2
+
1
3
  module Padrino
2
4
  module Cli
3
5
  module Adapter
@@ -10,15 +10,6 @@ end
10
10
 
11
11
  module PadrinoTasks
12
12
  def self.init(init=false)
13
- lib_path = File.expand_path("lib")
14
- unless $LOAD_PATH.any?{ |path| File.expand_path(path) == lib_path }
15
- warn <<-EOT
16
- WARNING! In Padrino >= 0.14.0 cli command `padrino rake` will NOT add
17
- './lib' folder to $LOAD_PATH. Please alter your `require` calls accordingly
18
- if you depend on this behavior.
19
- EOT
20
- $LOAD_PATH.unshift lib_path
21
- end
22
13
  Padrino::Tasks.files.flatten.uniq.each { |rakefile| Rake.application.add_import(rakefile) rescue puts "<= Failed load #{ext}" }
23
14
  load(File.expand_path('../rake_tasks.rb', __FILE__))
24
15
  Rake.application.load_imports
@@ -51,7 +51,6 @@ module Padrino
51
51
  return false if loaded?
52
52
  began_at = Time.now
53
53
  @_called_from = first_caller
54
- set_encoding
55
54
  Padrino.logger
56
55
  Reloader.lock!
57
56
  before_load.each(&:call)
@@ -309,7 +309,7 @@ module Padrino
309
309
 
310
310
  @@mutex = Mutex.new
311
311
  def self.logger
312
- @_logger || setup!
312
+ (@_logger ||= nil) || setup!
313
313
  end
314
314
 
315
315
  def self.logger=(logger)
@@ -1,6 +1,6 @@
1
1
  module Padrino
2
2
  module Module
3
- attr_accessor :root
3
+ attr_writer :root
4
4
 
5
5
  ##
6
6
  # Register this module as being loaded from a gem. This automatically
@@ -129,6 +129,8 @@ module Padrino
129
129
  # Array of routes.
130
130
  #
131
131
  def named_routes
132
+ return [] unless app_obj.respond_to?(:routes)
133
+
132
134
  app_obj.routes.map { |route|
133
135
  request_method = route.request_methods.first
134
136
  next if !route.name || request_method == 'HEAD'
@@ -58,8 +58,8 @@ module Padrino
58
58
  params = args.last.is_a?(Hash) ? args.pop : {}
59
59
  candidates = @routes.select { |route| route.name == name }
60
60
  fail InvalidRouteException if candidates.empty?
61
- route = candidates.sort_by! { |route|
62
- (params.keys.map(&:to_s) - route.matcher.names).length }.shift
61
+ route = candidates.sort_by! { |candidate|
62
+ (params.keys.map(&:to_s) - candidate.matcher.names).length }.shift
63
63
  matcher = route.matcher
64
64
  params_for_expand = params.dup
65
65
  if !args.empty? && matcher.mustermann?
@@ -14,7 +14,7 @@ module Padrino
14
14
  @capture = options[:capture]
15
15
  @default_values = options[:default_values]
16
16
  end
17
-
17
+
18
18
  ##
19
19
  # Matches a pattern with the route matcher.
20
20
  #
@@ -32,12 +32,12 @@ module Padrino
32
32
  def to_regexp
33
33
  mustermann? ? handler.to_regexp : handler
34
34
  end
35
-
35
+
36
36
  ##
37
37
  # Expands the path by using parameters.
38
38
  #
39
39
  def expand(params)
40
- params = params.merge(@default_values) if @default_values.is_a?(Hash)
40
+ params = @default_values.merge(params) if @default_values.is_a?(Hash)
41
41
  params, query = params.each_with_object([{}, {}]) do |(key, val), parts|
42
42
  parts[handler.names.include?(key.to_s) ? 0 : 1][key] = val
43
43
  end
@@ -45,7 +45,7 @@ module Padrino
45
45
  expanded_path += ?? + Padrino::Utils.build_uri_query(query) unless query.empty?
46
46
  expanded_path
47
47
  end
48
-
48
+
49
49
  ##
50
50
  # Returns true if handler is an instance of Mustermann.
51
51
  #
@@ -72,7 +72,7 @@ module Padrino
72
72
  end
73
73
  params
74
74
  end
75
-
75
+
76
76
  ##
77
77
  # Returns the handler which is an instance of Mustermann or Regexp.
78
78
  #
@@ -87,14 +87,14 @@ module Padrino
87
87
  @path
88
88
  end
89
89
  end
90
-
90
+
91
91
  ##
92
92
  # Converts the handler into string.
93
93
  #
94
94
  def to_s
95
95
  handler.to_s
96
96
  end
97
-
97
+
98
98
  ##
99
99
  # Returns names of the handler.
100
100
  # @see Regexp#names
@@ -104,7 +104,7 @@ module Padrino
104
104
  #
105
105
  def self.parse_server_options(options)
106
106
  parsed_server_options = Array(options).flat_map{ |option| option.split('=', 2) }
107
- Hash[*parsed_server_options].symbolize_keys
107
+ Utils.symbolize_keys(Hash[*parsed_server_options])
108
108
  end
109
109
 
110
110
  # Detects Host and Port for Rack server.
@@ -6,7 +6,7 @@
6
6
  #
7
7
  module Padrino
8
8
  # The version constant for the current version of Padrino.
9
- VERSION = '0.14.0.rc1' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.14.0.rc2' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
@@ -20,13 +20,7 @@ describe "Core" do
20
20
  it 'should validate global helpers' do
21
21
  assert_equal :test, Padrino.env
22
22
  assert_match /\/test/, Padrino.root
23
- refute_nil Padrino.version
24
- end
25
-
26
- it 'should set correct utf-8 encoding' do
27
- Padrino.set_encoding
28
- assert_equal Encoding.default_external, Encoding::UTF_8
29
- assert_equal Encoding.default_internal, Encoding::UTF_8
23
+ assert Padrino.version
30
24
  end
31
25
 
32
26
  it 'should raise application error if I instantiate a new padrino application without mounted apps' do
@@ -337,7 +337,7 @@ describe "Filters" do
337
337
  end
338
338
 
339
339
  it 'should catch exceptions in before filters' do
340
- doodle = nil
340
+ doodle = ''
341
341
  mock_app do
342
342
  after do
343
343
  doodle = 'Been after'
@@ -355,7 +355,7 @@ describe "Filters" do
355
355
 
356
356
  get '/'
357
357
  assert_equal 'We broke before', body
358
- assert_equal nil, doodle
358
+ assert_equal '', doodle
359
359
  end
360
360
 
361
361
  it 'should catch exceptions in after filters if no exceptions caught before' do
@@ -45,7 +45,7 @@ describe Padrino::Flash do
45
45
 
46
46
  it 'should not know the values you set right away' do
47
47
  @storage[:foo] = 'bar'
48
- assert_nil @storage[:foo]
48
+ refute_includes @storage, :foo
49
49
  end
50
50
 
51
51
  it 'should knows the values you set next time' do
@@ -62,7 +62,7 @@ describe Padrino::Flash do
62
62
  it 'should forgets values you set only for now next time' do
63
63
  @storage.now[:foo] = 'bar'
64
64
  @storage.sweep
65
- assert_nil @storage[:foo]
65
+ refute_includes @storage, :foo
66
66
  end
67
67
  end
68
68
 
@@ -94,13 +94,13 @@ describe "Router" do
94
94
 
95
95
  res = Rack::MockRequest.new(map).get("/werewolf")
96
96
  assert_equal 404, res.status
97
- assert_equal nil, res["X-API"]
98
- assert_equal nil, res["X-ScriptName"]
99
- assert_equal nil, res["X-PathInfo"]
97
+ refute_includes res, "X-API"
98
+ refute_includes res, "X-ScriptName"
99
+ refute_includes res, "X-PathInfo"
100
100
 
101
101
  res = Rack::MockRequest.new(map).get("/bar/mitzvah")
102
102
  assert res.ok?
103
- assert_equal nil, res["X-API"]
103
+ refute_includes res, "X-API"
104
104
  assert_equal 'text/plain', res["Content-Type"]
105
105
  assert_equal "/bar", res["X-ScriptName"]
106
106
  assert_equal "/mitzvah", res["X-PathInfo"]
@@ -114,7 +114,7 @@ describe "Router" do
114
114
 
115
115
  res = Rack::MockRequest.new(map).get("/bar/scary")
116
116
  assert_equal 404, res.status
117
- assert_equal nil, res["X-API"]
117
+ refute_includes res, "X-API"
118
118
  assert_equal 'text/plain', res["Content-Type"]
119
119
  assert_equal "/bar", res["X-ScriptName"]
120
120
  assert_equal "/scary", res["X-PathInfo"]
@@ -1247,6 +1247,17 @@ describe "Routing" do
1247
1247
  assert_equal "lang is en", body
1248
1248
  end
1249
1249
 
1250
+ it 'should override default values when parameters are passed' do
1251
+ mock_app do
1252
+ controller lang: :it do
1253
+ get(:index, map: '/:lang') { "lang is #{params[:lang]}" }
1254
+ end
1255
+ end
1256
+ assert_equal '/pt', @app.url(:index, lang: 'pt')
1257
+ get '/pt'
1258
+ assert_equal 'lang is pt', body
1259
+ end
1260
+
1250
1261
  it 'should transitions to the next matching route on pass' do
1251
1262
  mock_app do
1252
1263
  get '/:foo' 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.14.0.rc1
4
+ version: 0.14.0.rc2
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: 2016-11-02 00:00:00.000000000 Z
14
+ date: 2017-01-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.14.0.rc1
22
+ version: 0.14.0.rc2
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.14.0.rc1
29
+ version: 0.14.0.rc2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sinatra
32
32
  requirement: !ruby/object:Gem::Requirement