dir_model 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/UPGRADE.md +4 -1
- data/lib/dir_model/import/path.rb +13 -33
- data/lib/dir_model/import.rb +10 -11
- data/lib/dir_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32c8c722a8b0c90ae93ee5cebb654227ee188652
|
4
|
+
data.tar.gz: dec22a3e621cee606b3876ade2bbf1080b9ff52f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ac58fc2cb229093204a0adf789362eba762c752bc09a71f4beac51fd3e69f6b47ee90c272cef7816e5ec54e599933267f50aacfb400305eb82ad038d5d8480d
|
7
|
+
data.tar.gz: a52e040adc41f966f7d09ca8f75339c2587099aa6617bc41ade4f369fb9d7f8e14909ff6ca9838c02ca79c206ab37ccdb088b401b07fdf47d7d5289bc59eb11e
|
data/CHANGELOG.md
CHANGED
data/UPGRADE.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# Upgrading
|
2
2
|
|
3
|
-
|
3
|
+
# Upgrading from 0.3.0 to 0.3.1
|
4
|
+
|
5
|
+
* Nothing todo
|
4
6
|
|
5
7
|
# Upgrading from 0.2.0 to 0.3.0
|
6
8
|
|
9
|
+
* Model is now a module you have to change include from `include DirModel` to `include DirModel::Model`
|
7
10
|
|
8
11
|
# Upgrading from 0.1.0 to 0.2.0
|
9
12
|
|
@@ -5,10 +5,9 @@ module DirModel
|
|
5
5
|
attr_reader :path
|
6
6
|
attr_reader :index
|
7
7
|
attr_reader :current_path
|
8
|
-
attr_reader :previous_path
|
9
8
|
|
10
9
|
def initialize(path)
|
11
|
-
@path = path
|
10
|
+
@path, @index = path, -1
|
12
11
|
reset!
|
13
12
|
end
|
14
13
|
|
@@ -18,7 +17,7 @@ module DirModel
|
|
18
17
|
|
19
18
|
def reset!
|
20
19
|
@index = -1
|
21
|
-
@current_path = @ruby_path =
|
20
|
+
@current_path = @ruby_path = nil
|
22
21
|
end
|
23
22
|
|
24
23
|
def start?
|
@@ -30,45 +29,26 @@ module DirModel
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def next_path
|
33
|
-
|
32
|
+
ruby_path[index+1]
|
33
|
+
end
|
34
|
+
|
35
|
+
def previous_path
|
36
|
+
return nil if index < 1
|
37
|
+
ruby_path[index-1]
|
34
38
|
end
|
35
39
|
|
36
40
|
def read_path
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
return if end?
|
42
|
+
@index += 1
|
43
|
+
@current_path = ruby_path[index]
|
44
|
+
set_end unless current_path
|
41
45
|
current_path
|
42
46
|
end
|
43
47
|
|
44
48
|
protected
|
45
49
|
|
46
|
-
def caching_value?
|
47
|
-
if @next_path
|
48
|
-
@current_path = @next_path
|
49
|
-
@next_path = nil
|
50
|
-
forward!
|
51
|
-
true
|
52
|
-
else
|
53
|
-
false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
50
|
def ruby_path
|
58
|
-
@ruby_path ||=
|
59
|
-
end
|
60
|
-
|
61
|
-
def _read_path
|
62
|
-
path = ruby_path.next.to_path
|
63
|
-
yield if block_given?
|
64
|
-
path
|
65
|
-
rescue StopIteration
|
66
|
-
set_end
|
67
|
-
nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def forward!
|
71
|
-
@index += 1
|
51
|
+
@ruby_path ||= ::Dir.glob("#{path}/**/*")
|
72
52
|
end
|
73
53
|
|
74
54
|
def set_end
|
data/lib/dir_model/import.rb
CHANGED
@@ -45,22 +45,21 @@ module DirModel
|
|
45
45
|
|
46
46
|
def match?
|
47
47
|
return if load_state == :loaded
|
48
|
+
@_match = loader { find_match }
|
49
|
+
end
|
50
|
+
alias_method :load, :match?
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
options = self.class.options(file_name)
|
52
|
+
def find_match
|
53
|
+
self.class.file_names.each do |file_name|
|
54
|
+
options = self.class.options(file_name)
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
false
|
56
|
+
if match = (source_path||'').match(options[:regex].call)
|
57
|
+
@file_infos = { file: file_name, options: options.merge(match: match) }
|
58
|
+
return true
|
60
59
|
end
|
61
60
|
end
|
61
|
+
false
|
62
62
|
end
|
63
|
-
alias_method :load, :match?
|
64
63
|
|
65
64
|
def loader
|
66
65
|
@load_state = :loading
|
data/lib/dir_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dir_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Chung
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|