tarvit-helpers 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tarvit-helpers/modules/recursive_loader.rb +54 -0
- data/lib/tarvit-helpers.rb +1 -0
- data/tarvit-helpers.gemspec +3 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15ef1eee9f1f9efdc8fab0768343e4765eeeb250
|
4
|
+
data.tar.gz: 26c9ccd012e749a231d1c507821b9fecad8e17eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e78c6c70897206a9120aceb9617f78e1b441547d89bbe9bca4a57cf0b058a787754ed0f48659f41ed1295d99408e0e5c71a807f43e688052e7b65c39cd32c4
|
7
|
+
data.tar.gz: caaee97390d61f5ca2029fcf11ae2b04aa4dda7984bf3b942e1debcea77226740660e1938e91cc64473eb4307f2a07cbcf032795299863b53436a1709bfbf799
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module TarvitHelpers
|
2
|
+
|
3
|
+
class RecursiveLoader
|
4
|
+
attr_reader :method
|
5
|
+
|
6
|
+
def initialize(method=:require)
|
7
|
+
raise "Method #{method} is invalid, must be :require or :load" unless [ :require, :load ].include?(method)
|
8
|
+
@method = method
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_modules(dir, priorities=[])
|
12
|
+
load_ruby_files(dir)
|
13
|
+
dirs = global_dirs(dir)
|
14
|
+
(priorities.select{|p| dirs.include?(p)} + dirs ).each do |subdir|
|
15
|
+
load_modules_in dir.join(subdir)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_modules_in(dir)
|
20
|
+
load_ruby_files(dir)
|
21
|
+
valid_directories(dir).each do |subdir|
|
22
|
+
load_modules_in dir.join(subdir)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load_modules(dir, priorities=[], method=:require)
|
27
|
+
new(method).load_modules(dir, priorities)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def global_dirs(dir)
|
33
|
+
(valid_directories(dir)).uniq
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_directories(dir)
|
37
|
+
Dir.open(dir).entries.select do |entry|
|
38
|
+
!%w{ . .. }.include?(entry) && File.directory?(dir.join(entry))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_ruby_files(dir)
|
43
|
+
ruby_files(dir).each do |rb|
|
44
|
+
send(method, dir.join(rb))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def ruby_files(dir)
|
49
|
+
Dir.open(dir).entries.select do |entry|
|
50
|
+
entry.ends_with? '.rb'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/tarvit-helpers.rb
CHANGED
data/tarvit-helpers.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: tarvit-helpers 0.0.
|
5
|
+
# stub: tarvit-helpers 0.0.13 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tarvit-helpers"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.13"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/tarvit-helpers/modules/conditional_logger.rb",
|
32
32
|
"lib/tarvit-helpers/modules/hash_presenter.rb",
|
33
33
|
"lib/tarvit-helpers/modules/non_shared_accessors.rb",
|
34
|
+
"lib/tarvit-helpers/modules/recursive_loader.rb",
|
34
35
|
"lib/tarvit-helpers/modules/simple_crypt.rb",
|
35
36
|
"spec/extensions/counter_spec.rb",
|
36
37
|
"spec/modules/hash_presenter_spec.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tarvit-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Tarasenko
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/tarvit-helpers/modules/conditional_logger.rb
|
115
115
|
- lib/tarvit-helpers/modules/hash_presenter.rb
|
116
116
|
- lib/tarvit-helpers/modules/non_shared_accessors.rb
|
117
|
+
- lib/tarvit-helpers/modules/recursive_loader.rb
|
117
118
|
- lib/tarvit-helpers/modules/simple_crypt.rb
|
118
119
|
- spec/extensions/counter_spec.rb
|
119
120
|
- spec/modules/hash_presenter_spec.rb
|