loader 1.1.1 → 1.2.0.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/VERSION +1 -1
- data/lib/loader/meta.rb +81 -65
- data/lib/loader/require.rb +2 -2
- data/test/sub/test2.rb +4 -0
- data/test/test.rb +3 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d5026a46aa747e48da743f3a97437c20f67a3c
|
4
|
+
data.tar.gz: ea2662f408bda885a2f13d59e0dbefd147c31b61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1fd02ec6480af17a9659562db8a4b93431730d663cf6baf367aa9d14c4988ff40d30465c2762c4ab9dc02a1db3356b0e59a1a5ac2816daca8aadf76d53d0a1
|
7
|
+
data.tar.gz: 6d79d2ed852bce1e85b304a704e91a35354733d4eda993e7deab879aac3b7f966339da2a5741bfb4beaf5f1e81d83d8d8d2fea54cea0f0e25f70f82424626371
|
data/README.md
CHANGED
@@ -18,10 +18,14 @@ the File Expand tricks
|
|
18
18
|
|
19
19
|
The end goal is to make an easy ruby file loader for gems. So Dir.pwd do not affect
|
20
20
|
|
21
|
-
|
21
|
+
### Examples
|
22
|
+
|
23
|
+
load relative directory (not based on Dir.pwd)
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
|
27
|
+
require 'loader'
|
28
|
+
|
25
29
|
# return and load the meta files from
|
26
30
|
# the lib/**/meta and return the hash obj build from the yamls
|
27
31
|
Loader.meta
|
@@ -34,4 +38,24 @@ the use cases are hell simple , like:
|
|
34
38
|
require_directory "lib", :r
|
35
39
|
#> require_directory is an alias for require_relative_directory
|
36
40
|
|
41
|
+
# you can use recursive by default call too
|
42
|
+
require_directory_r "lib" #> || require_relative_directory_r
|
43
|
+
|
37
44
|
```
|
45
|
+
|
46
|
+
Additional Syntax for caller magic
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
|
50
|
+
require 'loader'
|
51
|
+
|
52
|
+
__directory__ #> || __DIR__
|
53
|
+
#> return the current folder where the file is
|
54
|
+
|
55
|
+
caller_folder
|
56
|
+
#> return the folder what called the current file/method/object
|
57
|
+
|
58
|
+
caller_file
|
59
|
+
#> return the file what called the current file/method/object
|
60
|
+
|
61
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0.rc
|
data/lib/loader/meta.rb
CHANGED
@@ -1,11 +1,85 @@
|
|
1
1
|
module Loader
|
2
|
+
|
3
|
+
module ObjectCallerEXT
|
4
|
+
|
5
|
+
def __directory__
|
6
|
+
caller_folder(-1)
|
7
|
+
end
|
8
|
+
|
9
|
+
alias :__DIR__ :__directory__
|
10
|
+
|
11
|
+
def caller_file skip= 0
|
12
|
+
|
13
|
+
raise unless skip.class <= Integer
|
14
|
+
skip += 1
|
15
|
+
|
16
|
+
return nil if caller[skip].nil?
|
17
|
+
caller_file = caller[skip].scan(/^(.*)(:\d+:\w+)/)[0][0]
|
18
|
+
|
19
|
+
if caller_file[0] != File::Separator
|
20
|
+
caller_file= File.expand_path caller_file
|
21
|
+
end
|
22
|
+
|
23
|
+
return caller_file
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def caller_folder skip= 0
|
28
|
+
|
29
|
+
raise unless skip.class <= Integer
|
30
|
+
caller_file_path= caller_file(skip+1)
|
31
|
+
return nil if caller_file_path.nil?
|
32
|
+
|
33
|
+
if !File.directory?(caller_file_path)
|
34
|
+
caller_file_path= caller_file_path.split(File::Separator)
|
35
|
+
caller_file_path.pop
|
36
|
+
caller_file_path= caller_file_path.join(File::Separator)
|
37
|
+
end
|
38
|
+
|
39
|
+
return caller_file_path
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
extend ObjectCallerEXT
|
45
|
+
|
2
46
|
class << self
|
3
47
|
|
4
|
-
|
5
|
-
|
48
|
+
# you can give optional file names that will be searched for
|
49
|
+
def caller_root(*args)
|
50
|
+
|
51
|
+
what_can_be_in_the_root= %w[
|
52
|
+
gemfile Gemfile GemFile
|
53
|
+
rakefile Rakefile RakeFile
|
54
|
+
config.ru README.md LICENSE LICENSE.txt .gitignore ] + args.map{|e|e.to_s}
|
55
|
+
|
56
|
+
folder_path= caller_folder(1).split(File::Separator)
|
57
|
+
|
58
|
+
loop do
|
59
|
+
|
60
|
+
Dir.glob(File.join(folder_path.join(File::Separator),"*")).map do |element|
|
61
|
+
if !File.directory?(element)
|
62
|
+
if what_can_be_in_the_root.include? element.split(File::Separator).last
|
63
|
+
return folder_path.join(File::Separator)
|
64
|
+
end
|
65
|
+
else
|
66
|
+
if %W[ .git .bundler ].include? element.split(File::Separator).last
|
67
|
+
return folder_path.join(File::Separator)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if folder_path.count == 0
|
73
|
+
return nil
|
74
|
+
else
|
75
|
+
folder_path.pop
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
6
80
|
end
|
7
81
|
|
8
|
-
alias :
|
82
|
+
alias :caller_root_folder :caller_root
|
9
83
|
|
10
84
|
# gives you a basic meta load framework for easy config use (yaml)
|
11
85
|
# basic system is
|
@@ -108,67 +182,6 @@ module Loader
|
|
108
182
|
|
109
183
|
end
|
110
184
|
|
111
|
-
def caller_folder integer_num= 1
|
112
|
-
|
113
|
-
# path create from caller
|
114
|
-
begin
|
115
|
-
path= caller[integer_num].split(".{rb,ru}:").first.split(File::Separator)
|
116
|
-
path= path[0..(path.count-2)]
|
117
|
-
end
|
118
|
-
|
119
|
-
# after formatting
|
120
|
-
begin
|
121
|
-
|
122
|
-
if !File.directory?(path.join(File::SEPARATOR))
|
123
|
-
path.pop
|
124
|
-
end
|
125
|
-
path= File.join(path.join(File::SEPARATOR))
|
126
|
-
if path != File.expand_path(path)
|
127
|
-
path= File.expand_path(path)
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
return path
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
# you can give optional file names that will be searched for
|
137
|
-
def caller_root(*args)
|
138
|
-
|
139
|
-
what_can_be_in_the_root= %w[
|
140
|
-
gemfile Gemfile GemFile
|
141
|
-
rakefile Rakefile RakeFile
|
142
|
-
config.ru README.md LICENSE LICENSE.txt .gitignore ] + args.map{|e|e.to_s}
|
143
|
-
|
144
|
-
folder_path= caller_folder(2).split(File::Separator)
|
145
|
-
|
146
|
-
loop do
|
147
|
-
|
148
|
-
Dir.glob(File.join(folder_path.join(File::Separator),"*")).map do |element|
|
149
|
-
if !File.directory?(element)
|
150
|
-
if what_can_be_in_the_root.include? element.split(File::Separator).last
|
151
|
-
return folder_path.join(File::Separator)
|
152
|
-
end
|
153
|
-
else
|
154
|
-
if %W[ .git .bundler ].include? element.split(File::Separator).last
|
155
|
-
return folder_path.join(File::Separator)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
if folder_path.count == 0
|
161
|
-
return Dir.pwd
|
162
|
-
else
|
163
|
-
folder_path.pop
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|
169
|
-
|
170
|
-
alias :caller_root_folder :caller_root
|
171
|
-
|
172
185
|
# load meta folders rb files
|
173
186
|
# by default it will be the caller objects root folder (app root)
|
174
187
|
# else you must set with hand the path from your app root
|
@@ -257,4 +270,7 @@ module Loader
|
|
257
270
|
|
258
271
|
|
259
272
|
end
|
260
|
-
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
Object.__send__ :include, Loader::ObjectCallerEXT
|
data/lib/loader/require.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Loader
|
2
2
|
|
3
|
-
module
|
3
|
+
module ObjectRequireEXT
|
4
4
|
|
5
5
|
# Offline repo activate
|
6
6
|
#def mount_modules(target_folder= File.join(Dir.pwd,"{module,modules}","{gem,gems}") )
|
@@ -49,4 +49,4 @@ module Loader
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
Object.__send__ :include, Loader::
|
52
|
+
Object.__send__ :include, Loader::ObjectRequireEXT
|
data/test/sub/test2.rb
ADDED
data/test/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " dsl for gem helper calls such like relative folder calls that independ
|
14
14
|
on the Dir.pwd or File.expand tricks and config loader stuffs, Check out the GIT! "
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/loader/meta.rb
|
36
36
|
- lib/loader/require.rb
|
37
37
|
- loader.gemspec
|
38
|
+
- test/sub/test2.rb
|
38
39
|
- test/test.rb
|
39
40
|
homepage: https://github.com/adamluzsi/loader
|
40
41
|
licenses:
|
@@ -51,9 +52,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
52
|
version: '0'
|
52
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
54
|
requirements:
|
54
|
-
- - "
|
55
|
+
- - ">"
|
55
56
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
57
|
+
version: 1.3.1
|
57
58
|
requirements: []
|
58
59
|
rubyforge_project:
|
59
60
|
rubygems_version: 2.2.2
|
@@ -61,4 +62,5 @@ signing_key:
|
|
61
62
|
specification_version: 4
|
62
63
|
summary: DSL for helping make file require easy just like build configuration objects
|
63
64
|
test_files:
|
65
|
+
- test/sub/test2.rb
|
64
66
|
- test/test.rb
|