loader 1.0.6 → 1.1.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.
- checksums.yaml +5 -13
- data/.gitignore +18 -0
- data/README.md +14 -3
- data/VERSION +1 -1
- data/examples/simple_require.rb +4 -1
- data/files.rb +7 -3
- data/lib/loader/array.rb +6 -2
- data/lib/loader/hash.rb +24 -20
- data/lib/loader/meta.rb +8 -4
- data/lib/loader/require.rb +37 -18
- data/loader.gemspec +4 -3
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NTFiNjFkOTNhYjkzNDk0YzA1YzgzYjgwOTIzNmY1YjgyZDM3YjYxYg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 953abadad958da2a6f0da25272c967c0cb71fa79
|
4
|
+
data.tar.gz: 959c1dbd1744ea681eb2b61dbb4d9085c4ad6bf8
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MGE2Yzk0NDkxMWZhNzIzYjJkNWM4NDk2OWQwMjBiOTkzZTQ1ODRiYWRjNTE4
|
11
|
-
ZmIzZjMyNTdmODQxYWJjMDhiN2RiOWVjOGQ3MzcxMzA0MjQ1NzA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDI1MmRhM2UyNTcyMjE5OTVhZjY5MWU0YzlmODU5NTgxYWQ3MzBmMDc0NjBk
|
14
|
-
NjJmYTViZWFhNDI2ODYyOWNiMzYwNzZhMTIzZjc5NzJhNGJhNmRlYjU5MmNi
|
15
|
-
MzBjYjQ4NTA5NmI5Y2EyOTM5M2JjMGU5OGE5NTEwMWUzMDhiYjk=
|
6
|
+
metadata.gz: 53f3d8e787831bafb04187b21ff0f84c246528c4e8185ea029bd2a83bcfbb887574a8567d3cff41144d88c4ff05ef0d534123fcfaacffb6c74141e0f1bdfe489
|
7
|
+
data.tar.gz: 5e1d9e3c8a6e43cb93b2715d8e85c948f56d77fb798672f3d999abd2234369b3b9c37d1246851a3fade036fcef373402c01b3916797a95b3864e64459a15e2df
|
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -7,20 +7,31 @@ Meta config file loaders and much more
|
|
7
7
|
### Introduction
|
8
8
|
|
9
9
|
Okey, before you even think about use this gem, let's say this gem only for lazy ones...
|
10
|
-
the basic idea is to have an easy to use relative require system
|
11
|
-
|
10
|
+
the basic idea is to have an easy to use relative require system
|
11
|
+
The plus is a yaml config file loading mechanism for picking up yamls
|
12
|
+
into a constant,
|
13
|
+
maybe into some other config specific gem that make config objects from hash.
|
12
14
|
|
13
15
|
The fun part is , that this stuffs can be used in making a new gem,
|
14
16
|
because it do not depend on the Dir.pwd or
|
15
17
|
the File Expand tricks
|
16
18
|
|
19
|
+
The end goal is to make an easy ruby file loader for gems. So Dir.pwd do not affect
|
20
|
+
|
17
21
|
the use cases are hell simple , like:
|
18
22
|
|
23
|
+
```ruby
|
24
|
+
|
19
25
|
# return and load the meta files from
|
20
26
|
# the lib/**/meta and return the hash obj build from the yamls
|
21
27
|
Loader.meta
|
22
28
|
|
23
|
-
# load all
|
29
|
+
# load all ruby file that was not loaded already
|
24
30
|
# from that relative folder
|
25
31
|
require_relative_directory "folder_name"
|
26
32
|
|
33
|
+
# for recursive use try the following
|
34
|
+
require_directory "lib", :r
|
35
|
+
#> require_directory is an alias for require_relative_directory
|
36
|
+
|
37
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/examples/simple_require.rb
CHANGED
@@ -18,4 +18,7 @@ puts Loader.meta absolute: File.expand_path(File.join(File.dirname(__FILE__),"li
|
|
18
18
|
#> {"asdf"=>{"else"=>{"world"=>"hello"}, "stuff"=>{"hello"=>"world"}}}
|
19
19
|
|
20
20
|
puts Loader.metaloader_framework root: File.expand_path(File.dirname(__FILE__))
|
21
|
-
#> {"asdf"=>{"else"=>{"world"=>"hello"}, "stuff"=>{"hello"=>"world"}}}
|
21
|
+
#> {"asdf"=>{"else"=>{"world"=>"hello"}, "stuff"=>{"hello"=>"world"}}}
|
22
|
+
|
23
|
+
require_directory "lib", :r #> recursive
|
24
|
+
#> hello world! from stuff.rb
|
data/files.rb
CHANGED
@@ -3,7 +3,9 @@ begin
|
|
3
3
|
|
4
4
|
files_to_be_loaded = %w[version.rb]
|
5
5
|
|
6
|
-
|
6
|
+
module Loader
|
7
|
+
SpecFiles= Array.new
|
8
|
+
end
|
7
9
|
|
8
10
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
|
9
11
|
one_file_name = File.expand_path one_file_name
|
@@ -11,11 +13,13 @@ begin
|
|
11
13
|
|
12
14
|
if !one_file_name.include?("pkg")
|
13
15
|
if !File.directory? file_name
|
14
|
-
|
15
|
-
|
16
|
+
|
17
|
+
Loader::SpecFiles.push file_name
|
18
|
+
|
16
19
|
if files_to_be_loaded.include? one_file_name.split(File::SEPARATOR).last
|
17
20
|
load one_file_name
|
18
21
|
end
|
22
|
+
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
data/lib/loader/array.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
module Loader
|
2
|
+
module ArrayEXT
|
2
3
|
|
3
4
|
# generate params structure from array
|
4
5
|
# return_array
|
@@ -19,4 +20,7 @@ class Array
|
|
19
20
|
|
20
21
|
end unless method_defined? :extract_class!
|
21
22
|
|
22
|
-
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Array.__send__ :include, Loader::ArrayEXT
|
data/lib/loader/hash.rb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
|
-
|
1
|
+
module Loader
|
2
|
+
module HashEXT
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
5
|
+
#
|
6
|
+
# h1 = {:x => {:y => [4,5,6]}, :z => [7,8,9]}
|
7
|
+
# h2 = {:x => {:y => [7,8,9]}, :z => "xyz"}
|
8
|
+
#
|
9
|
+
# h1.deep_merge(h2) #=> { :x => {:y => [7, 8, 9]}, :z => "xyz" }
|
10
|
+
# h2.deep_merge(h1) #=> { :x => {:y => [4, 5, 6]}, :z => [7, 8, 9] }
|
11
|
+
def deep_merge(other_hash)
|
12
|
+
dup.deep_merge!(other_hash)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
alias :+ :deep_merge unless method_defined? :deep_merge
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# Same as +deep_merge+, but modifies +self+.
|
18
|
+
def deep_merge!(other_hash)
|
19
|
+
other_hash.each_pair do |k,v|
|
20
|
+
tv = self[k]
|
21
|
+
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
|
22
|
+
end
|
23
|
+
self
|
21
24
|
end
|
22
|
-
self
|
23
|
-
end unless method_defined? :deep_merge!
|
24
25
|
|
25
|
-
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Hash.__send__ :include, Loader::HashEXT
|
data/lib/loader/meta.rb
CHANGED
@@ -139,7 +139,7 @@ module Loader
|
|
139
139
|
what_can_be_in_the_root= %w[
|
140
140
|
gemfile Gemfile GemFile
|
141
141
|
rakefile Rakefile RakeFile
|
142
|
-
config.ru README.md ] + args.map{|e|e.to_s}
|
142
|
+
config.ru README.md LICENSE LICENSE.txt .gitignore ] + args.map{|e|e.to_s}
|
143
143
|
|
144
144
|
folder_path= caller_folder(2).split(File::Separator)
|
145
145
|
|
@@ -150,13 +150,17 @@ module Loader
|
|
150
150
|
if what_can_be_in_the_root.include? element.split(File::Separator).last
|
151
151
|
return folder_path.join(File::Separator)
|
152
152
|
end
|
153
|
+
else
|
154
|
+
if %W[ .git .bundler ].include? element.split(File::Separator).last
|
155
|
+
return folder_path.join(File::Separator)
|
156
|
+
end
|
153
157
|
end
|
154
158
|
end
|
155
159
|
|
156
|
-
if folder_path.count
|
157
|
-
|
160
|
+
if folder_path.count == 0
|
161
|
+
return Dir.pwd
|
158
162
|
else
|
159
|
-
|
163
|
+
folder_path.pop
|
160
164
|
end
|
161
165
|
|
162
166
|
end
|
data/lib/loader/require.rb
CHANGED
@@ -1,28 +1,47 @@
|
|
1
|
-
module
|
1
|
+
module Loader
|
2
2
|
|
3
|
-
|
4
|
-
#def mount_modules(target_folder= File.join(Dir.pwd,"{module,modules}","{gem,gems}") )
|
5
|
-
# Dir.glob(File.join(target_folder,"**","lib")).select{|f| File.directory?(f)}.each do |one_path|
|
6
|
-
# $LOAD_PATH.unshift one_path
|
7
|
-
# end
|
8
|
-
#end
|
3
|
+
module ObjectEXT
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
# Offline repo activate
|
6
|
+
#def mount_modules(target_folder= File.join(Dir.pwd,"{module,modules}","{gem,gems}") )
|
7
|
+
# Dir.glob(File.join(target_folder,"**","lib")).select{|f| File.directory?(f)}.each do |one_path|
|
8
|
+
# $LOAD_PATH.unshift one_path
|
9
|
+
# end
|
10
|
+
#end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
# require sender relative directory's files
|
13
|
+
# return the directory and the sub directories file names (rb/ru)
|
14
|
+
def require_relative_directory( folder, *args )
|
15
|
+
|
16
|
+
recursive= nil
|
17
|
+
[:recursive,:r, :R, 'r', 'R', '-r', '-R'].each{|e| args.include?(e) ? recursive ||= true : nil }
|
18
|
+
|
19
|
+
# opts[:extension] ||= opts[:extensions] || opts[:ex] || opts[:e] || []
|
20
|
+
# raise(ArgumentError,"invalid extension object, must be array like") unless opts[:extension].class <= Array
|
21
|
+
|
22
|
+
unless folder.to_s[0] == File::Separator
|
23
|
+
folder= Loader.caller_folder,folder
|
24
|
+
end
|
25
|
+
|
26
|
+
path_parts= [folder]
|
27
|
+
if recursive
|
28
|
+
path_parts.push("**")
|
29
|
+
end
|
30
|
+
path_parts.push("*.{rb,ru}")
|
31
|
+
|
32
|
+
|
33
|
+
return_value= false
|
34
|
+
Dir.glob(File.join(*path_parts)).each do |one_path|
|
35
|
+
require(one_path) ? return_value=( true ) : nil
|
36
|
+
end
|
17
37
|
|
18
|
-
|
19
|
-
require one_path
|
38
|
+
return return_value
|
20
39
|
end
|
21
40
|
|
22
|
-
|
41
|
+
alias :require_directory :require_relative_directory
|
23
42
|
|
24
43
|
end
|
25
44
|
|
26
|
-
|
45
|
+
end
|
27
46
|
|
28
|
-
|
47
|
+
Object.__send__ :include, Loader::ObjectEXT
|
data/loader.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__),"files.rb"))
|
3
|
+
# require File.expand_path(File.join(File.dirname(__FILE__),"files.rb"))
|
4
4
|
|
5
5
|
### Specification for the new Gem
|
6
6
|
Gem::Specification.new do |spec|
|
@@ -10,13 +10,14 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ["Adam Luzsi"]
|
11
11
|
spec.email = ["adamluzsi@gmail.com"]
|
12
12
|
spec.description = %q{ dsl for gem helper calls such like relative folder calls that independ on the Dir.pwd or File.expand tricks and config loader stuffs, Check out the GIT! }
|
13
|
-
spec.summary = %q{DSL for helping make file
|
13
|
+
spec.summary = %q{DSL for helping make file require easy just like build configuration objects }
|
14
14
|
spec.homepage = "https://github.com/adamluzsi/loader"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files =
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
|
20
21
|
spec.require_paths = ["lib"]
|
21
22
|
|
22
23
|
end
|
metadata
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
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-
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
on the Dir.pwd or File.expand tricks and config loader stuffs, Check out the GIT!
|
13
|
+
description: " dsl for gem helper calls such like relative folder calls that independ
|
14
|
+
on the Dir.pwd or File.expand tricks and config loader stuffs, Check out the GIT! "
|
15
15
|
email:
|
16
16
|
- adamluzsi@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- ".gitignore"
|
21
22
|
- Gemfile
|
22
23
|
- LICENSE
|
23
24
|
- README.md
|
@@ -45,20 +46,19 @@ require_paths:
|
|
45
46
|
- lib
|
46
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
48
|
requirements:
|
48
|
-
- -
|
49
|
+
- - ">="
|
49
50
|
- !ruby/object:Gem::Version
|
50
51
|
version: '0'
|
51
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
|
-
- -
|
54
|
+
- - ">="
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: '0'
|
56
57
|
requirements: []
|
57
58
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.2.
|
59
|
+
rubygems_version: 2.2.2
|
59
60
|
signing_key:
|
60
61
|
specification_version: 4
|
61
|
-
summary: DSL for helping make file
|
62
|
+
summary: DSL for helping make file require easy just like build configuration objects
|
62
63
|
test_files:
|
63
64
|
- test/test.rb
|
64
|
-
has_rdoc:
|