dir_model 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 488a7e3ac0284d3de0d578ff43fe0293132b4a03
4
- data.tar.gz: 61b2bf17b362a211bddda139effe0cbcf628d594
3
+ metadata.gz: 942349c8ad33f73a980864f457aebca25fdd62a0
4
+ data.tar.gz: 07c2e63f7d8ddfd63bb5622bc6be8e8696bb8f24
5
5
  SHA512:
6
- metadata.gz: a91b3e607bdc5e8baa616cd1c4541edb45a733307d69128366bac0f0f9cf423a192e5af3dc8630194538fcc9371c023b778df7d4cef163060c97b0b415486457
7
- data.tar.gz: e2477c238e7c641cff600fa2fb0db60b7c613438d73aa3ef3a2c4b0936aa36970ad25eaa7e51f60e7c45f965c7e240278d01fb3b7131707422b93f9006d85742
6
+ metadata.gz: 17c0a84bec8dd64f799faee0b81aa6f4b8954ae3e684fe96d721020df6f4d1ffdba706f9eb5062144d47df076052ee1e126a9eca45264a66b517f49e6fe4ff35
7
+ data.tar.gz: 086fc4fa9c8f33675701ae8a3b59b8f6f33e5a9fe24f7a9337caa62e2fd3e756825d8d2bd9ac062eb4e4608be48709fa6527cac28fd55ace21ff97486bad9f28
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  /tmp/
10
10
 
11
11
  .idea/*
12
- .byebug_history
12
+ .byebug_history
13
+ *.gem
@@ -1,6 +1,10 @@
1
+ ### VERSION 0.7.1
2
+
3
+ Add `ActiveModel::Callbacks` to play around next, basically tracking progress
4
+
1
5
  ### VERSION 0.7.0
2
6
 
3
- * Change the design of `AggregateDir` to make it composable
7
+ * Change the design of `AggregateDir` to make it composable
4
8
 
5
9
  ### VERSION 0.6.2
6
10
 
data/README.md CHANGED
@@ -112,6 +112,23 @@ class SectorImportDirModel < SectorDirModel
112
112
  end
113
113
  ```
114
114
 
115
+ ### Import Callbacks
116
+ `DirModel::Import::Dir` can be subclassed to access
117
+ [`ActiveModel::Callbacks`](http://api.rubyonrails.org/classes/ActiveModel/Callbacks.html).
118
+
119
+ * next - `before`, `around`, or `after` each change in `current_dir_model`
120
+
121
+ and implement the callbacks:
122
+ ```ruby
123
+ class ImportDir < DirModel::Import::Dir
124
+ before_next :track_progress
125
+
126
+ def track_progress
127
+ ...
128
+ end
129
+ end
130
+ ```
131
+
115
132
  ### Export
116
133
 
117
134
  ```ruby
data/UPGRADE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Upgrading
2
2
 
3
+ # Upgrading from 0.7.0 to 0.7.1
4
+
5
+ Nothing
6
+
3
7
  # Upgrading from 0.6.2 to 0.7.0
4
8
 
5
9
  * Change the manner of call AggregateDir like
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'activesupport', '~> 4.2'
22
+ spec.add_dependency 'activemodel', '~> 4.2'
22
23
  spec.add_dependency 'inherited_class_var', '1.0.0.beta1'
23
24
  spec.add_dependency 'fastimage', '~> 1.8'
24
25
  end
@@ -1,9 +1,13 @@
1
- require 'forwardable'
1
+ require 'active_model'
2
2
 
3
3
  module DirModel
4
4
  module Import
5
5
  class Dir # File
6
- extend Forwardable
6
+ extend ActiveModel::Callbacks
7
+
8
+ define_model_callbacks :next
9
+
10
+ delegate :size, :index, :end?, to: :path
7
11
 
8
12
  attr_reader :index
9
13
  attr_reader :path
@@ -12,8 +16,6 @@ module DirModel
12
16
  attr_reader :current_dir_model
13
17
  attr_reader :previous_dir_model
14
18
 
15
- def_delegators :@path, :end?
16
-
17
19
  def initialize(source_path, import_dir_model_class, context={})
18
20
  @path, @import_dir_model_class, @context = Path.new(source_path), import_dir_model_class, context.to_h.symbolize_keys
19
21
  reset
@@ -37,11 +39,13 @@ module DirModel
37
39
  def next(context={})
38
40
  return if end?
39
41
 
40
- context = context.to_h.reverse_merge(self.context)
41
- @previous_dir_model = current_dir_model
42
- @current_dir_model = import_dir_model_class.next(path, context, previous_dir_model)
43
- @index += 1
44
- @current_dir_model = @index = nil if end?
42
+ run_callbacks :next do
43
+ context = context.to_h.reverse_merge(self.context)
44
+ @previous_dir_model = current_dir_model
45
+ @current_dir_model = import_dir_model_class.next(path, context, previous_dir_model)
46
+ @index += 1
47
+ @current_dir_model = @index = nil if end?
48
+ end
45
49
 
46
50
  current_dir_model
47
51
  end
@@ -1,3 +1,3 @@
1
1
  module DirModel
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dir_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Chung
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: inherited_class_var
29
43
  requirement: !ruby/object:Gem::Requirement