tarvit-helpers 0.0.22 → 0.0.23
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 +4 -4
- data/VERSION +1 -1
- data/lib/tarvit-helpers/modules/recursive_loader.rb +20 -8
- data/spec/modules/recursive_loader_spec.rb +29 -0
- data/spec/support/load/a.rb +1 -0
- data/spec/support/load/b.rb +1 -0
- data/spec/support/load/x/c.rb +1 -0
- data/spec/support/load/y/d.rb +1 -0
- data/spec/support/load/y/e.rb +1 -0
- data/spec/support/load/z/a.rb +1 -0
- data/spec/support/load/z/b.rb +1 -0
- data/tarvit-helpers.gemspec +11 -3
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b16138a784f01b8049d41ba0dde396852b91b7fe
|
4
|
+
data.tar.gz: e72adcab6aae27ca0708b4b37f16e7a59876083e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5de6712b2f92d44d639efe4e6a0e753084e84db72ed89e9b834e624b58e701d7c65904ea2c070ec35f05b7ddb1ae6ec4cfe9c137ab310716e47961f1b17cffa
|
7
|
+
data.tar.gz: 099c85a226640012916bcf82bfbe297acff36943cea0ad1ce57013df306457ddf7581d8452721a36923c0011acbbf5fe02d5da23867347474e00d8d5b828a3ec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.23
|
@@ -9,10 +9,9 @@ module TarvitHelpers
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def load_modules(dir, priorities=[])
|
12
|
-
load_ruby_files(dir)
|
13
|
-
|
14
|
-
|
15
|
-
load_modules_in dir.join(subdir)
|
12
|
+
load_ruby_files(dir, priorities)
|
13
|
+
prioritize(global_dirs(dir), priorities).each do |subdir|
|
14
|
+
load_modules dir.join(subdir), priorities
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
@@ -34,7 +33,7 @@ module TarvitHelpers
|
|
34
33
|
private
|
35
34
|
|
36
35
|
def global_dirs(dir)
|
37
|
-
(valid_directories(dir)).uniq
|
36
|
+
(valid_directories(dir)).uniq.sort
|
38
37
|
end
|
39
38
|
|
40
39
|
def valid_directories(dir)
|
@@ -43,16 +42,29 @@ module TarvitHelpers
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
def load_ruby_files(dir)
|
47
|
-
ruby_files(dir).each do |rb|
|
45
|
+
def load_ruby_files(dir, priorities=[])
|
46
|
+
prioritize_files(ruby_files(dir), priorities).each do |rb|
|
48
47
|
send(method, dir.join(rb))
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
51
|
+
RB_EXT = '.rb'
|
52
|
+
|
52
53
|
def ruby_files(dir)
|
53
54
|
Dir.open(dir).entries.select do |entry|
|
54
|
-
entry.ends_with?
|
55
|
+
entry.ends_with? RB_EXT
|
56
|
+
end.sort
|
57
|
+
end
|
58
|
+
|
59
|
+
def prioritize(list, priorities)
|
60
|
+
(priorities.select{|p| list.include?(p) } + list ).uniq
|
61
|
+
end
|
62
|
+
|
63
|
+
def prioritize_files(files, priorities)
|
64
|
+
files_priorities = priorities.map do |p|
|
65
|
+
p.include?(RB_EXT) ? p : (p+RB_EXT)
|
55
66
|
end
|
67
|
+
prioritize(files, files_priorities)
|
56
68
|
end
|
57
69
|
end
|
58
70
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RecursiveLoader do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
$arr = []
|
7
|
+
@dir = Pathname.new(File.expand_path('./spec/support/load'))
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'load with default order' do
|
11
|
+
loader.load_modules(@dir)
|
12
|
+
expect($arr).to eq([:a, :b, :c, :d, :e, :a, :b])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'load with default order' do
|
16
|
+
loader.load_modules(@dir, %w{ b })
|
17
|
+
expect($arr).to eq([:b, :a, :c, :d, :e, :b, :a])
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'load with default order' do
|
21
|
+
loader.load_modules(@dir, %w{ z y x })
|
22
|
+
expect($arr).to eq([:a, :b, :a, :b, :d, :e, :c])
|
23
|
+
end
|
24
|
+
|
25
|
+
def loader(method = :load)
|
26
|
+
RecursiveLoader.new(method)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :a
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :b
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :c
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :d
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :e
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :a
|
@@ -0,0 +1 @@
|
|
1
|
+
$arr << :b
|
data/tarvit-helpers.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.23 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.23"
|
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"]
|
13
13
|
s.authors = ["Vitaly Tarasenko"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-11-16"
|
15
15
|
s.description = " Simple extensions to standard Ruby classes and useful helpers. "
|
16
16
|
s.email = "vetal.tarasenko@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -45,9 +45,17 @@ Gem::Specification.new do |s|
|
|
45
45
|
"spec/modules/hash_presenter/simple_spec.rb",
|
46
46
|
"spec/modules/hash_presenter_spec.rb",
|
47
47
|
"spec/modules/non_shared_accessors_spec.rb",
|
48
|
+
"spec/modules/recursive_loader_spec.rb",
|
48
49
|
"spec/modules/simple_crypt_spec.rb",
|
49
50
|
"spec/spec_helper.rb",
|
50
51
|
"spec/support/base_tests/base_hash_presenter_test.rb",
|
52
|
+
"spec/support/load/a.rb",
|
53
|
+
"spec/support/load/b.rb",
|
54
|
+
"spec/support/load/x/c.rb",
|
55
|
+
"spec/support/load/y/d.rb",
|
56
|
+
"spec/support/load/y/e.rb",
|
57
|
+
"spec/support/load/z/a.rb",
|
58
|
+
"spec/support/load/z/b.rb",
|
51
59
|
"tarvit-helpers.gemspec"
|
52
60
|
]
|
53
61
|
s.homepage = "http://github.com/tarvit/tarvit-helpers"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Tarasenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,9 +128,17 @@ files:
|
|
128
128
|
- spec/modules/hash_presenter/simple_spec.rb
|
129
129
|
- spec/modules/hash_presenter_spec.rb
|
130
130
|
- spec/modules/non_shared_accessors_spec.rb
|
131
|
+
- spec/modules/recursive_loader_spec.rb
|
131
132
|
- spec/modules/simple_crypt_spec.rb
|
132
133
|
- spec/spec_helper.rb
|
133
134
|
- spec/support/base_tests/base_hash_presenter_test.rb
|
135
|
+
- spec/support/load/a.rb
|
136
|
+
- spec/support/load/b.rb
|
137
|
+
- spec/support/load/x/c.rb
|
138
|
+
- spec/support/load/y/d.rb
|
139
|
+
- spec/support/load/y/e.rb
|
140
|
+
- spec/support/load/z/a.rb
|
141
|
+
- spec/support/load/z/b.rb
|
134
142
|
- tarvit-helpers.gemspec
|
135
143
|
homepage: http://github.com/tarvit/tarvit-helpers
|
136
144
|
licenses:
|