active_importer 0.1.0 → 0.1.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.
- data/lib/active_importer/base.rb +13 -2
- data/lib/active_importer/version.rb +1 -1
- data/spec/active_importer/base_spec.rb +1 -0
- data/spec/stubs/employee.rb +10 -1
- metadata +3 -3
data/lib/active_importer/base.rb
CHANGED
@@ -61,13 +61,24 @@ module ActiveImporter
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def fire_event(event, param = nil)
|
64
|
-
self.class.
|
65
|
-
|
64
|
+
self.class.send(:fire_event, self, event, param)
|
65
|
+
unless self.class == ActiveImporter::Base
|
66
|
+
self.class.superclass.send(:fire_event, self, event, param)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.fire_event(instance, event, param = nil)
|
71
|
+
event_handlers[event].each do |block|
|
72
|
+
instance.instance_exec(param, &block)
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
69
76
|
private :fire_event
|
70
77
|
|
78
|
+
class << self
|
79
|
+
private :fire_event
|
80
|
+
end
|
81
|
+
|
71
82
|
#
|
72
83
|
# Implementation
|
73
84
|
#
|
@@ -31,6 +31,7 @@ describe ActiveImporter::Base do
|
|
31
31
|
expect(EmployeeImporter).to receive(:new).once.and_return(importer)
|
32
32
|
expect(importer).to receive(:import_started).once
|
33
33
|
expect(importer).to receive(:import_finished).once
|
34
|
+
expect(importer).to receive(:base_import_finished).once
|
34
35
|
EmployeeImporter.import('/dummy/file')
|
35
36
|
end
|
36
37
|
|
data/spec/stubs/employee.rb
CHANGED
@@ -9,7 +9,16 @@ class Employee < DataModel
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
class
|
12
|
+
class EmployeeBaseImporter < ActiveImporter::Base
|
13
|
+
on(:import_finished) { base_import_finished }
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def base_import_finished
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class EmployeeImporter < EmployeeBaseImporter
|
13
22
|
imports Employee
|
14
23
|
|
15
24
|
column 'Name', :name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash: -
|
115
|
+
hash: -839045621640734141
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash: -
|
124
|
+
hash: -839045621640734141
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
127
|
rubygems_version: 1.8.23
|