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 +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +5 -1
- data/README.md +17 -0
- data/UPGRADE.md +4 -0
- data/dir_model.gemspec +1 -0
- data/lib/dir_model/import/dir.rb +13 -9
- data/lib/dir_model/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942349c8ad33f73a980864f457aebca25fdd62a0
|
4
|
+
data.tar.gz: 07c2e63f7d8ddfd63bb5622bc6be8e8696bb8f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c0a84bec8dd64f799faee0b81aa6f4b8954ae3e684fe96d721020df6f4d1ffdba706f9eb5062144d47df076052ee1e126a9eca45264a66b517f49e6fe4ff35
|
7
|
+
data.tar.gz: 086fc4fa9c8f33675701ae8a3b59b8f6f33e5a9fe24f7a9337caa62e2fd3e756825d8d2bd9ac062eb4e4608be48709fa6527cac28fd55ace21ff97486bad9f28
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
data/dir_model.gemspec
CHANGED
@@ -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
|
data/lib/dir_model/import/dir.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_model'
|
2
2
|
|
3
3
|
module DirModel
|
4
4
|
module Import
|
5
5
|
class Dir # File
|
6
|
-
extend
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
data/lib/dir_model/version.rb
CHANGED
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.
|
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
|