csv_migration 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/csv_migration.rb +7 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5f74597cba0b6c9d98490bcd353432e9586e67a6ff1a01d6a7d51e821c20ddb
4
- data.tar.gz: c1b2f539cb7b58f8ccd98ef187212f9c21eb15e24da129b4407dbfb69aacdbd1
3
+ metadata.gz: 00f06e4a49f53bb66702884ad4ab06c5fa41bfb15c69e1eb6d637bf4fb9d0281
4
+ data.tar.gz: 6e667978527a2a0b55899315d3b1d98b4aa0e05e52eacdec961ae1efd67e2cf8
5
5
  SHA512:
6
- metadata.gz: 81fcc7ae7e50b3f1dfcc4f3f12f399720a1d7e8f87f17fe3b16f04217e4ee78c3abb792dbdcc41e143fb35e7c33ab1b8ae1c0d505de8c503ac293024b018e813
7
- data.tar.gz: cbc31f85f5ecbfc7d5dd063b035601fd00b12330dfd1e285a38de51a19c544b40bed433849eb035e25275f09d60733bc50d691bcfdf9e6061567271c69ba524f
6
+ metadata.gz: fe20b127b0ccf7fa5cad36d40e417bc211bd14ae9a93b8128f2e912ffcadbcaac7950f006dd3dd56fd6d4d024f1bd7694809c181bfc84e361696248da3084ead
7
+ data.tar.gz: bc9aca62d52e52f2d2be63a35e5acfc1edfca3aa63a6e904e1daecb27a8989ebcdb9b2e43fd45a25bc3a908c0923dc35fc15c0460d0255e86769ed037512f2a9
data/lib/csv_migration.rb CHANGED
@@ -11,7 +11,7 @@ class CsvMigration
11
11
 
12
12
  @file_name = @file_name_csv.split('.csv').first
13
13
 
14
- # File for export correct data from base file
14
+ # File for export correct data from the base file
15
15
  @correct_file_data_csv = File.expand_path("v_parser_correct_#{@file_name}.csv")
16
16
  @errors_log = File.expand_path("v_parser_errors_#{@file_name}.log")
17
17
  @duplicates_log = File.expand_path("v_parser_duplicates_#{@file_name}.log")
@@ -56,7 +56,7 @@ class CsvMigration
56
56
  # Key: column name in the csv file
57
57
  # Value:
58
58
  # field: a field name of a table in a DB (symbol)
59
- # require: a field should be not empty (true/false)
59
+ # require: a field should not be empty (true/false)
60
60
  # replace: need to use @replace_dict ( @replace_dict = { 'what need replace' => 'replace to this' } ) (true/false)
61
61
  # prefix: need to add value as a prefix from a field header name (header name from CSV file) (string)
62
62
  # validate: callback method which necessary call for validating a specific format (symbol)
@@ -100,7 +100,7 @@ class CsvMigration
100
100
 
101
101
  @parsed_data << { id: @line_num - 1 }.merge(records)
102
102
 
103
- puts "Left parse #{@count_file_lines - @line_num} lines"
103
+ puts "Parse left #{@count_file_lines - @line_num} lines"
104
104
  @line_num += 1
105
105
  @counter_good_records += 1
106
106
  end
@@ -120,7 +120,7 @@ class CsvMigration
120
120
  puts "Bad records: #{@errors.values.sum}"
121
121
  puts "Duplicate records: #{@counter_duplicates}"
122
122
  puts "Duplicates more than one field: #{double_duplicates}" if double_duplicates.positive?
123
- puts "Success parsed records: #{@parsed_data.size}"
123
+ puts "Successfully parsed records: #{@parsed_data.size}"
124
124
 
125
125
  error_actions if !@errors.values.sum.zero? || !@counter_duplicates.zero?
126
126
 
@@ -201,7 +201,7 @@ class CsvMigration
201
201
  # @param [Object] value hash data from dict
202
202
  def check_field(data, key, value)
203
203
  if @parsing_file_header.find_index(key).nil?
204
- puts "Please, correct settings in the @ref_csv_head_from_file hash. Key #{key} doesn't found in the header of #{@file_name_csv} file!"
204
+ puts "Please, correct settings in the @ref_csv_head_from_file hash. Key #{key} has not been found in the header of #{@file_name_csv} file!"
205
205
  exit
206
206
  end
207
207
 
@@ -447,11 +447,11 @@ class CsvMigration
447
447
  def add_record_to_db(_record)
448
448
  raise 'You should make realization callback method add_record_to_db(record)'
449
449
 
450
- # Search data of model if it necessary
450
+ # Search data of model if is necessary
451
451
  # user = User.find_by(email: record[:email].downcase)
452
452
  #
453
453
  # if user.nil?
454
- # save_error(record, "User doesn't found in the DB by email")
454
+ # save_error(record, "User has not been found in the DB by email")
455
455
  # next
456
456
  # end
457
457
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilevsky Kirill (Syndicode.com)