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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTljZGYyMzkyZjE0MzQyZjVhYTdiZGM5YmMwNjdiM2RmN2M3ODFkNw==
4
+ NDhjYWI1ZWY0YjFkZWI5NTI0MDZjOWZiNDdjYzFhMzEzMjNhY2JkNA==
5
5
  data.tar.gz: !binary |-
6
- NWM2ZDNmNmRhMmU0NjdkNzk5YjQ2ODAxMmZiYzM2YzYzYTU4MWI0ZQ==
6
+ ZjI3NWQyMmZhZjc3Zjk2MmNkMTllNjA0YWQzYjJkNWI5MjMwOWFmMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjMxM2IyY2VkZTI4YTg4MGQzNzk2MzMzMmYxYTdlYmQ4YzI5YTgyYmQ0NjQz
10
- ZmYyMWJhYzkwN2QzYWUzOGRmZTdiNDIwMDQ1NTljOGQ2MjJjZjY0ZjRlYjAw
11
- MDAyMDcyZmQ2M2IyZjA1ZjY4Y2QyYjQ1N2E5MjM2ZTRmOWEyNjU=
9
+ ZmRiNGY5MWJkNjk4NDFhNThkODMxZTE2ZmY2MDE0YTlmYmJmYzE0MDMxOTk1
10
+ MTlhYzg0MzE0NWFiMWMzYTNjYmMyODk5NThlNjZkNzk2NGM5MDU1NjFhZDdk
11
+ NjU2OWUwNzA1YjJlOTFhYTgxNmI1ZGUzNGY5MGE5ZDhhOWY1OTI=
12
12
  data.tar.gz: !binary |-
13
- ZmU5YWQ5ZmY1N2MwOWRlZWE0ZDI0OTNjMmEwYjAzMjE2NWI5ZjU4ZjZhOWQ4
14
- YThkZThmYWFlNDAxNzNmZWQzMDk3Njg3NjgxZDI5YTQ3MWI0MDkyNzk1MzJk
15
- YzE3ZGQ5MWEwNDkwNDIxY2MyYzYxNjkxODdiZTY0OTIxYjYyZGE=
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) } %>
@@ -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.class.to_s
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
@@ -70,8 +70,8 @@ module Rseed
70
70
  end
71
71
  end
72
72
  if found_at_least_one
73
- logger.warning "Missing optional headers: #{@missing_headers_optional.join(',')}".yellow unless @missing_headers_optional.empty?
74
- logger.warning "Missing mandatory headers: #{@missing_headers_mandatory.join(',')}".red unless @missing_headers_mandatory.empty?
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
@@ -1,3 +1,3 @@
1
1
  module Rseed
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rseed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Monagle