dir_model 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b37d3d709550ebba94791438eb647ff38631caaa
4
- data.tar.gz: 6897081d0e48e834a5e641b33097ec5b6bfd8e23
3
+ metadata.gz: 32c8c722a8b0c90ae93ee5cebb654227ee188652
4
+ data.tar.gz: dec22a3e621cee606b3876ade2bbf1080b9ff52f
5
5
  SHA512:
6
- metadata.gz: 6e4ea16033776a1d2d3b6a6e331b8ee4660b56365a2c4b5014e700aad49b5157b7ff7579f056de55eaf7b077bffb332d402e5ead8f5870a15a8bd2d9390d7020
7
- data.tar.gz: fa6270d818cca60016271b3a3bd31ba40982227cc817dcd320f530c892c6876c267a4d3d59c5196ecd2361aac9e81acc74c1323ff6265e2c6e8b2f260c8172ba
6
+ metadata.gz: 6ac58fc2cb229093204a0adf789362eba762c752bc09a71f4beac51fd3e69f6b47ee90c272cef7816e5ec54e599933267f50aacfb400305eb82ad038d5d8480d
7
+ data.tar.gz: a52e040adc41f966f7d09ca8f75339c2587099aa6617bc41ade4f369fb9d7f8e14909ff6ca9838c02ca79c206ab37ccdb088b401b07fdf47d7d5289bc59eb11e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### VERSION 0.3.1
2
+
3
+ * Technical changes, Simplication of Path, use Array skill to give previous, current and next Path instead of using Enumerator
4
+
1
5
  ### VERSION 0.3.0
2
6
 
3
7
  * Add Import feature
data/UPGRADE.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Upgrading
2
2
 
3
- * Model is now a module you have to change include from `include DirModel` to `include DirModel::Model`
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 = @previous_path = nil
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
- @next_path ||= _read_path
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
- @previous_path = @current_path
38
- unless caching_value?
39
- @current_path = _read_path { forward! }
40
- end
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 ||= Pathname.glob("#{path}/**/*").each
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
@@ -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
- @_match ||= begin
50
- loader do
51
- self.class.file_names.each do |file_name|
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
- if match = (source_path||'').match(options[:regex].call)
55
- @file_infos = { file: file_name, options: options.merge(match: match) }
56
- return true
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
@@ -1,3 +1,3 @@
1
1
  module DirModel
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport