padrino-core 0.14.3 → 0.14.4

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
- SHA1:
3
- metadata.gz: 67049ac27ef791df6b58644ea21bd12bcec00bc9
4
- data.tar.gz: fe0d8065a52c828803af721463be97ef4576e6b3
2
+ SHA256:
3
+ metadata.gz: d970982e5c919bfa97c39b3898bd59d396681d17c5b9eaf17854667ce52715ff
4
+ data.tar.gz: 4be78f1700017e77554317d4eeca9f94ccc00a685a1c47f1139e2b80816b80f7
5
5
  SHA512:
6
- metadata.gz: 6650c3db1e456e06bf421f7483c118159b03364508586eb96f1a96428a61f8982c1bdde44857c5eb5495333fa7a6d3b07c99ee84d4529d5488d660630c32cb64
7
- data.tar.gz: a44bd53e18a5de430b0f8605fd0546fb9425674279679cc7ee8922efab4c5d1df4bbb1fcac0da9726e38a74b81db950d0549dbcad03b03dd6c7a00ef9ff392ea
6
+ metadata.gz: 0cbf8c80aba78a17cab9ff325110d4045eb8363803ce47f94cc8b40b022bdeb3864e0a3804434cb5250c5bcb49df3b92c3577e87945b5c1642bf188d3ba59b7e
7
+ data.tar.gz: 4fcc0feb28750c7fe358162a7f40d2da0c73147610baa8e61b36d24eda1bc7119e31694178b59fed06a8d9eb865513b3ef250c8f2a5c0849de593b344081a826
@@ -21,7 +21,7 @@ module Padrino
21
21
  def match(pattern)
22
22
  if match_data = handler.match(pattern)
23
23
  match_data
24
- elsif mustermann? && pattern != "/" && pattern.end_with?("/")
24
+ elsif pattern != "/" && pattern.end_with?("/")
25
25
  handler.match(pattern[0..-2])
26
26
  end
27
27
  end
@@ -90,7 +90,7 @@ module Padrino
90
90
  return unless options[:force] || file_changed?(file)
91
91
  return require(file) if feature_excluded?(file)
92
92
 
93
- Storage.prepare(file) # might call #safe_load recursively
93
+ Storage.prepare(file, MTIMES) # might call #safe_load recursively
94
94
  logger.devel(file_new?(file) ? :loading : :reload, began_at, file)
95
95
  begin
96
96
  with_silence{ require(file) }
@@ -101,7 +101,7 @@ module Padrino
101
101
  logger.exception exception, :short
102
102
  logger.error "Failed to load #{file}; removing partially defined constants"
103
103
  end
104
- Storage.rollback(file)
104
+ Storage.rollback(file, MTIMES)
105
105
  raise
106
106
  end
107
107
  end
@@ -18,12 +18,13 @@ module Padrino
18
18
  files.delete(name)
19
19
  end
20
20
 
21
- def prepare(name)
21
+ def prepare(name, mtimes)
22
22
  file = remove(name)
23
23
  @old_entries ||= {}
24
24
  @old_entries[name] = {
25
25
  :constants => object_classes,
26
- :features => old_features = Set.new($LOADED_FEATURES.dup)
26
+ :features => old_features = Set.new($LOADED_FEATURES.dup),
27
+ :mtimes => mtimes.dup
27
28
  }
28
29
  features = file && file[:features] || []
29
30
  features.each{ |feature| Reloader.safe_load(feature, :force => true) }
@@ -39,8 +40,10 @@ module Padrino
39
40
  @old_entries.delete(name)
40
41
  end
41
42
 
42
- def rollback(name)
43
- new_constants = new_classes(@old_entries[name][:constants])
43
+ def rollback(name, mtimes)
44
+ new_constants = new_classes(@old_entries[name][:constants]).reject do |constant|
45
+ newly_commited_constant?(constant, mtimes, @old_entries[name][:mtimes])
46
+ end
44
47
  new_constants.each{ |klass| Reloader.remove_constant(klass) }
45
48
  @old_entries.delete(name)
46
49
  end
@@ -78,6 +81,26 @@ module Padrino
78
81
  snapshot.include?(klass) ? nil : klass
79
82
  end
80
83
  end
84
+
85
+ ##
86
+ # Returns true if and only if constant is commited after prepare
87
+ #
88
+ def newly_commited_constant?(constant, mtimes, old_mtimes)
89
+ newly_commited_files(files, mtimes, old_mtimes).each do |_, entry|
90
+ return true if entry[:constants].include?(constant)
91
+ end
92
+ false
93
+ end
94
+
95
+ ##
96
+ # Returns a list of entries in "files" that is commited after prepare
97
+ #
98
+ def newly_commited_files(files, mtimes, old_mtimes)
99
+ files.select do |file, _|
100
+ next true unless old_mtimes[file]
101
+ old_mtimes[file] < mtimes[file]
102
+ end
103
+ end
81
104
  end
82
105
  end
83
106
  end
@@ -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.3' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.14.4' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
@@ -0,0 +1,2 @@
1
+ class J < K
2
+ end
@@ -0,0 +1,2 @@
1
+ class K
2
+ end
@@ -0,0 +1,4 @@
1
+ Padrino.require_dependencies(
2
+ Padrino.root("fixtures/dependencies/nested/m.rb"),
3
+ Padrino.root("fixtures/dependencies/nested/n.rb")
4
+ )
@@ -0,0 +1,5 @@
1
+ class M
2
+ def self.hello
3
+ "hello"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ class N < J
2
+ end
@@ -65,5 +65,16 @@ describe "Dependencies" do
65
65
  end
66
66
  end
67
67
  end
68
+
69
+ it 'should not remove constants that are newly commited in nested require_dependencies' do
70
+ capture_io do
71
+ Padrino.require_dependencies(
72
+ Padrino.root("fixtures/dependencies/nested/j.rb"),
73
+ Padrino.root("fixtures/dependencies/nested/k.rb"),
74
+ Padrino.root("fixtures/dependencies/nested/l.rb")
75
+ )
76
+ end
77
+ assert_equal "hello", M.hello
78
+ end
68
79
  end
69
80
  end
@@ -156,6 +156,16 @@ describe "Routing" do
156
156
  assert_equal "My lucky number: 99 99", body
157
157
  end
158
158
 
159
+ it 'should ignore trailing slashes' do
160
+ mock_app do
161
+ get(%r./trailing.) { "slash" }
162
+ end
163
+ get "/trailing"
164
+ assert_equal "slash", body
165
+ get "/trailing/"
166
+ assert_equal "slash", body
167
+ end
168
+
159
169
  it 'should accept regexp routes with generate with :generate_with' do
160
170
  mock_app do
161
171
  get(%r{/fob|/baz}, :name => :foo, :generate_with => '/fob') { "regexp" }
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.3
4
+ version: 0.14.4
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: 2018-02-23 00:00:00.000000000 Z
14
+ date: 2018-11-05 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.3
22
+ version: 0.14.4
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.3
29
+ version: 0.14.4
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sinatra
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,11 @@ files:
154
154
  - test/fixtures/dependencies/d.rb
155
155
  - test/fixtures/dependencies/linear/h.rb
156
156
  - test/fixtures/dependencies/linear/i.rb
157
+ - test/fixtures/dependencies/nested/j.rb
158
+ - test/fixtures/dependencies/nested/k.rb
159
+ - test/fixtures/dependencies/nested/l.rb
160
+ - test/fixtures/dependencies/nested/m.rb
161
+ - test/fixtures/dependencies/nested/n.rb
157
162
  - test/fixtures/reloadable_apps/external/app/app.rb
158
163
  - test/fixtures/reloadable_apps/external/app/controllers/base.rb
159
164
  - test/fixtures/reloadable_apps/main/app.rb
@@ -198,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
203
  version: 1.3.6
199
204
  requirements: []
200
205
  rubyforge_project: padrino-core
201
- rubygems_version: 2.6.12
206
+ rubygems_version: 2.7.8
202
207
  signing_key:
203
208
  specification_version: 4
204
209
  summary: The required Padrino core gem