rseed 1.0.0 → 1.0.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 +8 -8
- data/README.rdoc +30 -0
- data/lib/generators/rseed/templates/data.csv.erb +1 -1
- data/lib/rseed/converter.rb +6 -2
- data/lib/rseed/csv_adapter.rb +2 -2
- data/lib/rseed/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDhjYWI1ZWY0YjFkZWI5NTI0MDZjOWZiNDdjYzFhMzEzMjNhY2JkNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjI3NWQyMmZhZjc3Zjk2MmNkMTllNjA0YWQzYjJkNWI5MjMwOWFmMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmRiNGY5MWJkNjk4NDFhNThkODMxZTE2ZmY2MDE0YTlmYmJmYzE0MDMxOTk1
|
10
|
+
MTlhYzg0MzE0NWFiMWMzYTNjYmMyODk5NThlNjZkNzk2NGM5MDU1NjFhZDdk
|
11
|
+
NjU2OWUwNzA1YjJlOTFhYTgxNmI1ZGUzNGY5MGE5ZDhhOWY1OTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODEzNTIwNzk0NzQ4Y2JkOGFlMWFhYjA2YzI3YWI2Mzg1NmQ4YzFiOTYwZjcz
|
14
|
+
ODU4ZGE5YTYzNTAzMWJiNDYyZWEyNTBlNTZlODNlYzRlOGI0YmY2MGRkYTlm
|
15
|
+
ZGNiYzJjNWNkZjY4MjAwNGY1MGY4YmQ5OTQ3MmIxOTY4OTBkYzU=
|
data/README.rdoc
CHANGED
@@ -45,6 +45,36 @@ This will cause the generator to create a file with fewer
|
|
45
45
|
|
46
46
|
== The Converter File
|
47
47
|
|
48
|
+
=== before_deserialize
|
49
|
+
|
50
|
+
If you define a function called before_serialize you can do any preprocessing you require. One example of this is
|
51
|
+
marking an archive flag on existing data:
|
52
|
+
|
53
|
+
def before_deserialize
|
54
|
+
HtmlColor.where(import_archive: true).update_all({:import_archive => false})
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
Note that you must return true from this function. Returning false will cause the processor to give up and log an error.
|
59
|
+
Thus you can also use the following:
|
60
|
+
|
61
|
+
def before_deserialize
|
62
|
+
return fail_with_error "Mandatory option is missing" unless options["mandatory_option"]
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
=== after_deserialize
|
67
|
+
|
68
|
+
You can define this function to be called at the end of processing. Following from the example above, if you set
|
69
|
+
*import_archive* to be false for each model in the deserialize method, you could do the following to remove old
|
70
|
+
records:
|
71
|
+
|
72
|
+
def after_deserialize
|
73
|
+
HtmlColor.where(import_archive: true).destroy_all
|
74
|
+
end
|
75
|
+
|
76
|
+
This is obviously fairly destructive and there are better ways to deal with this situation than destroying the records.
|
77
|
+
|
48
78
|
=== Attribute Options
|
49
79
|
|
50
80
|
* :header
|
@@ -1 +1 @@
|
|
1
|
-
<%= CSV.generate { |csv| csv << @columns.keys } %>
|
1
|
+
<%= CSV.generate { |csv| csv << ( @columns.keys + @relationships.keys) } %>
|
data/lib/rseed/converter.rb
CHANGED
@@ -10,12 +10,16 @@ module Rseed
|
|
10
10
|
attr_reader :error
|
11
11
|
attr_writer :options
|
12
12
|
|
13
|
-
def name
|
14
|
-
class_name = self.
|
13
|
+
def self.name
|
14
|
+
class_name = self.to_s
|
15
15
|
m = /^(?<name>.*)Converter$/.match(class_name)
|
16
16
|
m ? m[:name] : class_name
|
17
17
|
end
|
18
18
|
|
19
|
+
def name
|
20
|
+
self.class.name
|
21
|
+
end
|
22
|
+
|
19
23
|
def logger
|
20
24
|
@logger.nil? ? Rseed.logger : @logger
|
21
25
|
end
|
data/lib/rseed/csv_adapter.rb
CHANGED
@@ -70,8 +70,8 @@ module Rseed
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
if found_at_least_one
|
73
|
-
logger.
|
74
|
-
logger.
|
73
|
+
logger.warn "Missing optional headers: #{@missing_headers_optional.join(',')}".yellow unless @missing_headers_optional.empty?
|
74
|
+
logger.warn "Missing mandatory headers: #{@missing_headers_mandatory.join(',')}".red unless @missing_headers_mandatory.empty?
|
75
75
|
end
|
76
76
|
return false unless @missing_headers_mandatory.empty?
|
77
77
|
true
|
data/lib/rseed/version.rb
CHANGED