require_all 1.4.0 → 1.5.0

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: bff4ed09b77b7126ccec6e78b790db78c0bb2963
4
- data.tar.gz: f50a415e910319cd6882a65232a1ffbc03f606b9
3
+ metadata.gz: d0acf6c3cfe3c05348dc4f39a44862b3ff9e1588
4
+ data.tar.gz: dfd83ec51fd0c052866242da84e23ee677baa107
5
5
  SHA512:
6
- metadata.gz: 7096790f47739b0c2409ee5b0b01482dfd89154842aed4c4ca0e4e7d905a1f5994308e0d79845cf7cd524ead2d5ec1642f9a95234254323833efc75806d007da
7
- data.tar.gz: b43aba2d1d0954229d21f3c8980aa9c019b8acea1fa6325098442b1b9799981cffcab3e92fca4d5581929372cc1ddbfb5f25783294e0d49de611f411089a558e
6
+ metadata.gz: 5cf536e611f4a5d089be5890d01775628b564051d7c60d9f1827abea02b0b4b9eafad8270be8951000612f02d8f4ba0713ce396bc4190a712a9cddf30bcb4b0d
7
+ data.tar.gz: 9108afdd13f81ad242b5e9824ef6eb2477326d4979f1d51bae39739c256eaaa64046f3c1f777a08bde1fc6eacb974bcd70847a316adfde8c5198acb565d426cf
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 1.5.0:
2
+
3
+ * Merged PR #13 (https://github.com/jarmo/require_all/pull/13).
4
+ * Merged PR #18 (https://github.com/jarmo/require_all/pull/18).
5
+
1
6
  1.4.0:
2
7
 
3
8
  * License is now correctly as MIT. Thanks to Eric Kessler for pull request #16.
@@ -72,7 +72,7 @@ module RequireAll
72
72
  # Maybe it's an .rb file and the .rb was omitted
73
73
  if File.file?(arg + '.rb')
74
74
  file = arg + '.rb'
75
- options[:method] != :autoload ? Kernel.send(options[:method], file) : __autoload(file, file, options)
75
+ options[:method] != :autoload ? __require(options[:method], file) : __autoload(file, file, options)
76
76
  return true
77
77
  end
78
78
 
@@ -105,7 +105,7 @@ module RequireAll
105
105
  # files can be loaded, indicating unresolvable dependencies.
106
106
  files.each do |file_|
107
107
  begin
108
- Kernel.send(options[:method], file_)
108
+ __require(options[:method], file_)
109
109
  rescue NameError => ex
110
110
  failed << file_
111
111
  first_name_error ||= ex
@@ -239,6 +239,10 @@ module RequireAll
239
239
 
240
240
  private
241
241
 
242
+ def __require(method, file)
243
+ Kernel.send(method, file)
244
+ end
245
+
242
246
  def __autoload(file, full_path, options)
243
247
  last_module = "Object" # default constant where namespaces are created into
244
248
  begin
@@ -259,15 +263,16 @@ module RequireAll
259
263
  without_ext = entry.basename(entry.extname).to_s
260
264
  const = without_ext.split("_").map {|word| word.capitalize}.join
261
265
 
262
- if entry.directory?
263
- mod.class_eval "module #{const} end"
264
- last_module += "::#{const}"
265
- else
266
+ if entry.file? || (entry.directory? && entry.sub_ext('.rb').file?)
266
267
  mod.class_eval do
267
268
  puts "autoloading #{mod}::#{const} from #{full_path}" if $DEBUG
268
269
  autoload const, full_path
269
270
  end
271
+ else
272
+ mod.class_eval "module #{const} end" if entry.directory?
270
273
  end
274
+
275
+ last_module += "::#{const}" if entry.directory?
271
276
  end
272
277
  end
273
278
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "require_all"
3
- s.version = "1.4.0"
3
+ s.version = "1.5.0"
4
4
  s.authors = ["Jarmo Pertman", "Tony Arcieri"]
5
5
  s.email = "jarmo.p@gmail.com"
6
6
  s.summary = "A wonderfully simple way to load your code"
@@ -16,6 +16,14 @@ describe "autoload_all" do
16
16
  is_expected.not_to be_loaded("Autoloaded::WrongModule::WithWrongModule", "WrongModule::WithWrongModule")
17
17
  end
18
18
 
19
+ it "autoloads class nested into another class" do
20
+ is_expected.not_to be_loaded("Autoloaded::Class1", "Autoloaded::Class1::C")
21
+ autoload_all File.dirname(__FILE__) + "/fixtures/autoloaded"
22
+ is_expected.to be_loaded("Autoloaded::Class1")
23
+ expect(Autoloaded::Class1).to be_a Class
24
+ is_expected.to be_loaded("Autoloaded::Class1::C")
25
+ end
26
+
19
27
  it "needs to specify base_dir for autoloading if loading something from under top-level module directory" do
20
28
  is_expected.not_to be_loaded("Autoloaded::Module1::A", "Autoloaded::Module2::LongerName", "Autoloaded::Module2::Module3::B")
21
29
  autoload_all File.dirname(__FILE__) + "/fixtures/autoloaded/module1"
@@ -0,0 +1,4 @@
1
+ module Autoloaded
2
+ class Class1
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Autoloaded
2
+ class Class1
3
+ class C
4
+ end
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarmo Pertman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-06 00:00:00.000000000 Z
12
+ date: 2017-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -73,6 +73,8 @@ files:
73
73
  - require_all.gemspec
74
74
  - spec/autoload_shared.rb
75
75
  - spec/autoload_spec.rb
76
+ - spec/fixtures/autoloaded/class1.rb
77
+ - spec/fixtures/autoloaded/class1/c.rb
76
78
  - spec/fixtures/autoloaded/module1/a.rb
77
79
  - spec/fixtures/autoloaded/module2/longer_name.rb
78
80
  - spec/fixtures/autoloaded/module2/module3/b.rb
@@ -121,13 +123,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  version: '0'
122
124
  requirements: []
123
125
  rubyforge_project:
124
- rubygems_version: 2.5.2
126
+ rubygems_version: 2.6.13
125
127
  signing_key:
126
128
  specification_version: 4
127
129
  summary: A wonderfully simple way to load your code
128
130
  test_files:
129
131
  - spec/autoload_shared.rb
130
132
  - spec/autoload_spec.rb
133
+ - spec/fixtures/autoloaded/class1.rb
134
+ - spec/fixtures/autoloaded/class1/c.rb
131
135
  - spec/fixtures/autoloaded/module1/a.rb
132
136
  - spec/fixtures/autoloaded/module2/longer_name.rb
133
137
  - spec/fixtures/autoloaded/module2/module3/b.rb