loader 2.2.3 → 3.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/lib/loader/autoload.rb +1 -6
  5. data/lib/loader/core_ext/module.rb +10 -0
  6. data/lib/loader/core_ext/object.rb +10 -0
  7. data/lib/loader/core_ext.rb +4 -0
  8. data/lib/loader/fetcher.rb +57 -0
  9. data/lib/loader/{helpers.rb → utils.rb} +7 -1
  10. data/lib/loader.rb +17 -4
  11. data/loader.gemspec +2 -0
  12. data/spec/fixtures/autoload/lib/sample/cat/paw.rb +2 -0
  13. data/spec/fixtures/autoload/lib/sample/cat.rb +3 -0
  14. data/spec/fixtures/autoload/lib/sample/dog/tail.rb +3 -0
  15. data/spec/fixtures/autoload/lib/sample/dog.rb +3 -0
  16. data/spec/fixtures/autoload/sample.rb +3 -0
  17. data/spec/fixtures/require_relative_directory/relative_folder/test_constant/stuff.ru +2 -0
  18. data/spec/fixtures/require_relative_directory/relative_folder/test_constant.rb +2 -0
  19. data/spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2/stuff2.ru +2 -0
  20. data/spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2.rb +2 -0
  21. data/spec/loader/helpers_spec.rb +2 -4
  22. data/spec/loader_spec.rb +39 -0
  23. metadata +27 -28
  24. data/lib/loader/autoload/fetcher.rb +0 -55
  25. data/lib/loader/autoload/loader_patch.rb +0 -14
  26. data/lib/loader/autoload/module_patch.rb +0 -10
  27. data/lib/loader/meta.rb +0 -79
  28. data/lib/loader/require.rb +0 -74
  29. data/test/app/controllers/samples_controller.rb +0 -3
  30. data/test/helper.rb +0 -3
  31. data/test/lib/cat/sup.rb +0 -1
  32. data/test/lib/cat/tail.rb +0 -5
  33. data/test/lib/cat.rb +0 -3
  34. data/test/lib/dog.rb +0 -2
  35. data/test/manual_test.rb +0 -7
  36. data/test/sub/test2.rb +0 -4
  37. data/test/test.rb +0 -3
  38. data/test/test_autoload.rb +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fb6d587cdce79bd118d9613737d6748df3bfcc4
4
- data.tar.gz: 5e53ed93aab29a1e2eaf8ddebad0f4fd1fd88037
3
+ metadata.gz: 13b2d8b0d11367696e839694ae8efa0deae9d94c
4
+ data.tar.gz: 1e2918297cb642e5539e5a1fd94fe5b36012d2fc
5
5
  SHA512:
6
- metadata.gz: 8d43285977aba52256e2e448d56e014b7649d4c8bf624cd54d4826971836d3f385ab876cb342b6300bd58ff8a692dcab31ba6205a78323c2e88fffa1e425fcdd
7
- data.tar.gz: e7b0ca491da195e2733971f86111c453c0831135d16a5ac2108cd82f5350099d570d9171547ff6d2117f1df67c287c23206f25b7bfcb9118119baf9a70e14383
6
+ metadata.gz: 7bb3719bcb4642aa5f95a820a31b8deadd50eb729f02c4d91a43465b7b835367084a53e58c7eae0b151bce7a3c35194bf2532268361404092c20b14810ef11f7
7
+ data.tar.gz: 127a0d8f5a68212b46410d0661d05349ba807f20499c90344aa09ef779fc689f7e3f0f19505b35bfb6119c62080cbb8bf7e65338d8e7224996bbfcc69982a6fa
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  loader
2
2
  ======
3
3
 
4
- Ruby module for Easy File lifting :)
4
+ Ruby module for automatic file require based on convention :)
5
5
 
6
6
  ### Introduction
7
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 3.0.0
@@ -1,7 +1,2 @@
1
1
  require 'loader'
2
- module Loader::AutoLoad
3
- require 'loader/autoload/module_patch'
4
- require 'loader/autoload/loader_patch'
5
- require 'loader/autoload/fetcher'
6
- Loader.__send__(:extend,Loader::AutoLoad::LoaderPatch)
7
- end
2
+ Loader.autoload!
@@ -0,0 +1,10 @@
1
+ Module.class_eval do
2
+
3
+ alias const_missing_original const_missing
4
+
5
+ def const_missing(name)
6
+ constant = Loader::Fetcher.load(self, name)
7
+ constant || const_missing_original(name)
8
+ end
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ Object.class_eval do
2
+
3
+ def require_relative_directory(relative_directory_path)
4
+ Dir.glob(File.join(File.dirname(caller[0]), relative_directory_path, '*.{ru,rb}'))
5
+ .sort_by { |file_path| file_path.length }
6
+ .each { |file_path| Loader::Utils.require(file_path) }
7
+
8
+ end
9
+
10
+ end
@@ -0,0 +1,4 @@
1
+ module Loader::CoreExt
2
+ require 'loader/core_ext/object'
3
+ require 'loader/core_ext/module'
4
+ end
@@ -0,0 +1,57 @@
1
+ module Loader::Fetcher
2
+
3
+ extend self
4
+ extend ::Loader::Utils
5
+
6
+ def load_gem(caller_class, constant_name)
7
+ underscore_name = Loader::Utils.underscore(constant_name)
8
+ gem_symbolic_name = underscore_name.sub(File::Separator, '-')
9
+
10
+ begin
11
+ require(underscore_name)
12
+ rescue LoadError
13
+ require(gem_symbolic_name)
14
+ end
15
+
16
+ return fetch_constant(caller_class, constant_name)
17
+ rescue LoadError
18
+ nil
19
+ end
20
+
21
+ def load(caller_class, name)
22
+ folder_path = get_folder_path(caller_class)
23
+ file_name = Loader::Utils.underscore(name)
24
+
25
+ Loader.project_root_folders.each do |project_root|
26
+ Dir.glob(File.join(project_root, '**', [folder_path, "#{file_name}.{rb,ru}"].compact)).each do |ruby_file_path|
27
+ if Loader::Utils.require(ruby_file_path)
28
+ c = fetch_constant(caller_class, name)
29
+
30
+ return c unless c.nil?
31
+ end
32
+ end
33
+ end
34
+
35
+ return load_gem(caller_class, name)
36
+ end
37
+
38
+
39
+ protected
40
+
41
+ def get_folder_path(caller_class)
42
+ return if caller_class == ::Object
43
+ caller_class.to_s.split('::').map { |camel_case| Loader::Utils.underscore(camel_case) }.join(File::Separator)
44
+ end
45
+
46
+ def fetch_constant(caller_class, name)
47
+ class_name = ([caller_class, name] - [Object]).join('::')
48
+ rgx = /^#{Regexp.escape(class_name)}$/
49
+
50
+ ObjectSpace.each_object(Module) do |obj|
51
+ return obj if !!(obj.to_s =~ rgx)
52
+ end
53
+
54
+ return nil
55
+ end
56
+
57
+ end
@@ -1,8 +1,14 @@
1
1
  require 'loader'
2
- module Loader::Helpers
2
+ module Loader::Utils
3
3
 
4
4
  extend self
5
5
 
6
+ def require(file_path)
7
+ Kernel.require(file_path)
8
+ rescue LoadError
9
+ Kernel.load(file_path)
10
+ end
11
+
6
12
  def pwd
7
13
  if !!ENV['BUNDLE_GEMFILE']
8
14
  ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
data/lib/loader.rb CHANGED
@@ -1,7 +1,20 @@
1
1
  #encoding: UTF-8
2
2
  module Loader
3
- require 'loader/meta'
4
- require 'loader/helpers'
5
- require 'loader/require'
6
- require 'loader/autoload'
3
+
4
+ require 'loader/utils'
5
+ require 'loader/fetcher'
6
+ require 'loader/core_ext'
7
+
8
+ extend self
9
+
10
+ def project_root_folders
11
+ @project_root_folders ||= []
12
+ end
13
+
14
+ def autoload!(project_root_folder=Loader::Utils.pwd)
15
+ project_root_folders.push(File.expand_path(project_root_folder))
16
+ end
17
+
18
+ alias autoload autoload!
19
+
7
20
  end
data/loader.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.require_paths = ['lib']
22
22
 
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
23
25
  spec.add_development_dependency('rspec')
24
26
  spec.add_development_dependency('rake')
25
27
 
@@ -0,0 +1,2 @@
1
+ module Sample::Cat::Paw
2
+ end
@@ -0,0 +1,3 @@
1
+ module Sample::Cat
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Sample::Dog::Tail
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Sample::Dog
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ module Sample
2
+
3
+ end
@@ -0,0 +1,2 @@
1
+ module TestConstant::Stuff
2
+ end
@@ -0,0 +1,2 @@
1
+ module TestConstant
2
+ end
@@ -1,8 +1,8 @@
1
1
  require_relative '../spec_helper'
2
- describe Loader::Helpers do
2
+ describe Loader::Utils do
3
3
 
4
4
  let(:project_folder) { 'Path/To/Project/Folder' }
5
- subject { Loader::Helpers }
5
+ subject { Loader::Utils }
6
6
 
7
7
  describe '#pwd' do
8
8
 
@@ -46,6 +46,4 @@ describe Loader::Helpers do
46
46
 
47
47
  end
48
48
 
49
-
50
-
51
49
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ describe Loader do
3
+
4
+ describe '.autoload!' do
5
+ let(:root_folder) { File.absolute_path(File.join(File.dirname(__FILE__), 'fixtures', 'autoload')) }
6
+ before { Loader.autoload!(root_folder) }
7
+
8
+ it 'should lazy load all the constants upon being used' do
9
+ expect { Sample }.to_not raise_error
10
+ expect { Sample::Dog }.to_not raise_error
11
+ expect { Sample::Dog::Tail }.to_not raise_error
12
+ expect { Sample::Cat::Paw }.to_not raise_error
13
+ end
14
+
15
+ it 'should require unrequired gems' do
16
+ expect { JSON }.to_not raise_error
17
+ end
18
+
19
+ end
20
+
21
+ describe '.require_relative_directory' do
22
+
23
+ it 'should require the given relative folder content' do
24
+ require_relative_directory 'fixtures/require_relative_directory/relative_folder'
25
+
26
+ expect { TestConstant::Stuff }.to raise_error(NameError, 'uninitialized constant TestConstant::Stuff')
27
+
28
+ expect { TestConstant }.to_not raise_error
29
+ end
30
+
31
+ it 'should require the given relative folder content recursively like this' do
32
+ require_relative_directory 'fixtures/require_relative_directory/relative_folder_recursive/**'
33
+
34
+ expect{ TestConstant2::Stuff2 }.to_not raise_error
35
+ end
36
+
37
+ end
38
+
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
@@ -65,25 +65,24 @@ files:
65
65
  - files.rb
66
66
  - lib/loader.rb
67
67
  - lib/loader/autoload.rb
68
- - lib/loader/autoload/fetcher.rb
69
- - lib/loader/autoload/loader_patch.rb
70
- - lib/loader/autoload/module_patch.rb
71
- - lib/loader/helpers.rb
72
- - lib/loader/meta.rb
73
- - lib/loader/require.rb
68
+ - lib/loader/core_ext.rb
69
+ - lib/loader/core_ext/module.rb
70
+ - lib/loader/core_ext/object.rb
71
+ - lib/loader/fetcher.rb
72
+ - lib/loader/utils.rb
74
73
  - loader.gemspec
74
+ - spec/fixtures/autoload/lib/sample/cat.rb
75
+ - spec/fixtures/autoload/lib/sample/cat/paw.rb
76
+ - spec/fixtures/autoload/lib/sample/dog.rb
77
+ - spec/fixtures/autoload/lib/sample/dog/tail.rb
78
+ - spec/fixtures/autoload/sample.rb
79
+ - spec/fixtures/require_relative_directory/relative_folder/test_constant.rb
80
+ - spec/fixtures/require_relative_directory/relative_folder/test_constant/stuff.ru
81
+ - spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2.rb
82
+ - spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2/stuff2.ru
75
83
  - spec/loader/helpers_spec.rb
84
+ - spec/loader_spec.rb
76
85
  - spec/spec_helper.rb
77
- - test/app/controllers/samples_controller.rb
78
- - test/helper.rb
79
- - test/lib/cat.rb
80
- - test/lib/cat/sup.rb
81
- - test/lib/cat/tail.rb
82
- - test/lib/dog.rb
83
- - test/manual_test.rb
84
- - test/sub/test2.rb
85
- - test/test.rb
86
- - test/test_autoload.rb
87
86
  homepage: https://github.com/adamluzsi/loader.rb
88
87
  licenses: []
89
88
  metadata: {}
@@ -95,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
94
  requirements:
96
95
  - - ">="
97
96
  - !ruby/object:Gem::Version
98
- version: '0'
97
+ version: 2.0.0
99
98
  required_rubygems_version: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -110,15 +109,15 @@ summary: easy to use File loader that allow directories/project both Lazy Load a
110
109
  Eager load for files and constants. The Eager load for relative directory made for
111
110
  gems by default
112
111
  test_files:
112
+ - spec/fixtures/autoload/lib/sample/cat.rb
113
+ - spec/fixtures/autoload/lib/sample/cat/paw.rb
114
+ - spec/fixtures/autoload/lib/sample/dog.rb
115
+ - spec/fixtures/autoload/lib/sample/dog/tail.rb
116
+ - spec/fixtures/autoload/sample.rb
117
+ - spec/fixtures/require_relative_directory/relative_folder/test_constant.rb
118
+ - spec/fixtures/require_relative_directory/relative_folder/test_constant/stuff.ru
119
+ - spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2.rb
120
+ - spec/fixtures/require_relative_directory/relative_folder_recursive/test_constant2/stuff2.ru
113
121
  - spec/loader/helpers_spec.rb
122
+ - spec/loader_spec.rb
114
123
  - spec/spec_helper.rb
115
- - test/app/controllers/samples_controller.rb
116
- - test/helper.rb
117
- - test/lib/cat.rb
118
- - test/lib/cat/sup.rb
119
- - test/lib/cat/tail.rb
120
- - test/lib/dog.rb
121
- - test/manual_test.rb
122
- - test/sub/test2.rb
123
- - test/test.rb
124
- - test/test_autoload.rb
@@ -1,55 +0,0 @@
1
- module Loader::AutoLoad::Fetcher
2
-
3
- extend self
4
- extend ::Loader::Helpers
5
-
6
- def try_load_by(caller_class, name)
7
- levels = generate_levels(caller_class, name)
8
- [
9
- nil,
10
- 'lib',
11
- File.join('{application,app,api}', '*'),
12
- File.join('**', '*')
13
- ].each do |folder|
14
- return if load_by_folder(levels, folder)
15
- end
16
- end
17
-
18
- def load_by_folder(levels, folder=nil)
19
-
20
- Loader.project_folders.each do |project_folder|
21
-
22
- desc_ary(levels.map { |str| File.join(*[project_folder, folder, "#{underscore(str)}.rb"].compact) }).each do |path_constructor|
23
- desc_ary(Dir.glob(path_constructor)).each do |path|
24
- return true if File.exist?(path) && require(path)
25
- end
26
- end
27
-
28
- end
29
-
30
- return false
31
-
32
- end
33
-
34
- def desc_ary(array)
35
- array.sort { |a, b| b.length <=> a.length }
36
- end
37
-
38
- def generate_levels(klass, name)
39
- levels = klass.to_s.split('::').reduce([]) { |m, c|
40
- m << [(last_obj = m.last), c].compact.join('::'); m
41
- }.map { |str| [str, name].join('::') }
42
- levels.unshift(name.to_s)
43
- return levels
44
- end
45
-
46
- def try_fetch_constant(caller_class, name)
47
- levels = generate_levels(caller_class, name).map { |str| Regexp.escape(str) }
48
- ObjectSpace.each_object(Module) { |obj|
49
- if !!(obj.to_s =~ /^(#{levels.join('|')})$/)
50
- return obj
51
- end
52
- }; nil
53
- end
54
-
55
- end
@@ -1,14 +0,0 @@
1
- module Loader::AutoLoad::LoaderPatch
2
-
3
- def project_folders
4
- @project_folders ||= []
5
- end
6
-
7
- def autoload!(project_folder=Loader::Helpers.pwd)
8
- project_folders.push(project_folder)
9
- ::Module.__send__(:prepend, Loader::AutoLoad::ModulePatch)
10
- end
11
-
12
- alias autoload autoload!
13
-
14
- end
@@ -1,10 +0,0 @@
1
- module Loader::AutoLoad::ModulePatch
2
-
3
- def const_missing(name)
4
- c = Loader::AutoLoad::Fetcher
5
- c.try_load_by(self,name)
6
- constant = c.try_fetch_constant(self, name)
7
- constant ? constant : super
8
- end
9
-
10
- end
data/lib/loader/meta.rb DELETED
@@ -1,79 +0,0 @@
1
- module Loader
2
-
3
- class << self
4
-
5
- def caller_file(skip=0)
6
-
7
- raise unless skip.class <= Integer
8
- skip += 1
9
-
10
- return nil if caller[skip].nil?
11
- caller_file = caller[skip].scan(/^(.*)(:\d+:\w+)/)[0][0]
12
-
13
- if caller_file[0] != File::Separator
14
- caller_file= File.expand_path caller_file
15
- end
16
-
17
- return caller_file
18
-
19
- end
20
-
21
- def caller_folder skip= 0
22
-
23
- raise unless skip.class <= Integer
24
- caller_file_path= caller_file(skip+1)
25
- return nil if caller_file_path.nil?
26
-
27
- if !File.directory?(caller_file_path)
28
- caller_file_path= caller_file_path.split(File::Separator)
29
- caller_file_path.pop
30
- caller_file_path= caller_file_path.join(File::Separator)
31
- end
32
-
33
- return caller_file_path
34
-
35
- end
36
-
37
-
38
-
39
- # you can give optional file names that will be searched for
40
- def caller_root(*args)
41
-
42
- what_can_be_in_the_root= %w[
43
- gemfile Gemfile GemFile
44
- rakefile Rakefile RakeFile
45
- config.ru README.md LICENSE LICENSE.txt .gitignore ] + args.map{|e|e.to_s}
46
-
47
- folder_path= caller_folder(1).split(File::Separator)
48
-
49
- loop do
50
-
51
- Dir.glob(File.join(folder_path.join(File::Separator),"*")).map do |element|
52
- if !File.directory?(element)
53
- if what_can_be_in_the_root.include? element.split(File::Separator).last
54
- return folder_path.join(File::Separator)
55
- end
56
- else
57
- if %W[ .git .bundler ].include? element.split(File::Separator).last
58
- return folder_path.join(File::Separator)
59
- end
60
- end
61
- end
62
-
63
- if folder_path.count == 0
64
- return nil
65
- else
66
- folder_path.pop
67
- end
68
-
69
- end
70
-
71
- end
72
-
73
- alias :caller_root_folder :caller_root
74
-
75
- end
76
-
77
- end
78
-
79
- # Object.__send__ :include, Loader::ObjectCallerEXT
@@ -1,74 +0,0 @@
1
- require 'loader'
2
- module Loader::ObjectExtension
3
-
4
- # require sender relative directory's files
5
- # return the directory and the sub directories file names (rb/ru)
6
- def require_relative_directory(*args)
7
-
8
- folder= args.select { |e| (e.class <= ::String) }.join(File::Separator)
9
- opts= {}
10
- args.select { |e| (e.class <= ::Hash) }.each { |hash| hash.each { |sk, sv| opts[sk]=sv } }
11
- args.select! { |e| (e.class <= ::Symbol) }
12
-
13
- opts[:recursive] ||= opts.delete(:r) || opts.delete(:R) || !([:recursive, :r, :R,].select { |e| args.include?(e) }.empty?)
14
- opts[:recursive] = !!opts[:recursive]
15
-
16
- # inclusion and exclusion
17
- [[:exclude, [:ex, :e, :EX, :E]], [:include, [:in, :i, :IN, :I]]].each do |name, aliases|
18
-
19
- aliases.each do |one_alias|
20
- opts[name] ||= opts.delete(one_alias)
21
- end
22
-
23
- opts[name] ||= []
24
-
25
- # should be REGEXP collection
26
- opts[name] = [*opts[name]].map { |e| !(e.class <= ::Regexp) ? Regexp.new(e.to_s) : e }
27
-
28
- end
29
-
30
-
31
- opts[:caller_folder] ||= opts.delete(:f) || opts.delete(:folder) || ::Loader.caller_folder
32
-
33
- unless folder.to_s[0] == File::Separator
34
- folder= [opts[:caller_folder], folder]
35
- end
36
-
37
- #> recursive option
38
- begin
39
- path_parts= [*folder]
40
- if opts[:recursive]
41
- path_parts.push("**")
42
- end
43
- path_parts.push("*.{rb,ru}")
44
- end
45
-
46
- return Dir.glob(File.join(*path_parts)).sort_by { |e| e.split(File::Separator).size }.map { |one_path|
47
-
48
- next unless opts[:exclude].select { |regex| one_path =~ regex ? true : false }.empty?
49
-
50
- if opts[:include].empty?
51
- require(one_path); one_path
52
- else
53
- opts[:include].each do |regex|
54
- if one_path =~ regex
55
- require(one_path); one_path
56
- end
57
- end
58
- end
59
-
60
- }.compact
61
-
62
- end
63
-
64
- alias :require_directory :require_relative_directory
65
-
66
- def require_relative_directory_r(*args)
67
- require_relative_directory *args, r: true, f: Loader.caller_folder
68
- end
69
-
70
- alias :require_directory_r :require_relative_directory_r
71
-
72
- end
73
-
74
- Object.__send__ :include, Loader::ObjectExtension
@@ -1,3 +0,0 @@
1
- class SamplesController
2
-
3
- end
data/test/helper.rb DELETED
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'..','lib'))
2
- require 'minitest/autorun'
3
- require 'loader'
data/test/lib/cat/sup.rb DELETED
@@ -1 +0,0 @@
1
- puts 'hello world!'
data/test/lib/cat/tail.rb DELETED
@@ -1,5 +0,0 @@
1
- class Cat
2
- class Tail
3
-
4
- end
5
- end
data/test/lib/cat.rb DELETED
@@ -1,3 +0,0 @@
1
- class Cat
2
-
3
- end
data/test/lib/dog.rb DELETED
@@ -1,2 +0,0 @@
1
- class Dog
2
- end
data/test/manual_test.rb DELETED
@@ -1,7 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(__dir__,'..','lib'))
2
- require 'loader'
3
-
4
- Loader.autoload __dir__
5
-
6
- p Cat
7
-
data/test/sub/test2.rb DELETED
@@ -1,4 +0,0 @@
1
-
2
-
3
- puts test
4
- # test
data/test/test.rb DELETED
@@ -1,3 +0,0 @@
1
- class TEST
2
-
3
- end
@@ -1,70 +0,0 @@
1
- require_relative 'helper'
2
- describe Loader::AutoLoad do
3
-
4
- before do
5
- Loader::Helpers.__send__(:define_singleton_method,:pwd){ __dir__ }
6
- end
7
-
8
- it 'should raise an constant missing error than' do
9
-
10
- -> {
11
- begin
12
- TEST
13
- rescue Exception => e
14
- e
15
- end
16
- }.call.is_a?(Exception).must_be :==, true
17
-
18
- Loader.autoload!
19
-
20
- -> {
21
- begin
22
- TEST
23
- rescue Exception => e
24
- e
25
- end
26
- }.call.is_a?(Exception).must_be :==, false
27
-
28
- -> {
29
- begin
30
- Cat::Tail
31
- rescue Exception => e
32
- e
33
- end
34
- }.call.is_a?(Exception).must_be :==, false
35
-
36
- -> {
37
- begin
38
-
39
- class Cat
40
- Dog
41
- end
42
-
43
- rescue Exception => e
44
- e
45
- end
46
- }.call.is_a?(Exception).must_be :==, false
47
-
48
- -> {
49
- begin
50
-
51
- SamplesController
52
-
53
- rescue Exception => e
54
- e
55
- end
56
- }.call.is_a?(Exception).must_be :==, false
57
-
58
- -> {
59
- begin
60
- BOOOM
61
- rescue Exception => e
62
- e
63
- end
64
- }.call.is_a?(Exception).must_be :==, true
65
-
66
- end
67
-
68
- # require_relative_directory_r 'lib'
69
-
70
- end