gamma 0.1.8 → 0.1.9

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d472f5f1939ba6651597a7a34069f99c5addd6f8
4
- data.tar.gz: 7cb6f00430abe9bd130d79aa55c25c16d59b76a2
3
+ metadata.gz: 734f8c0e5eb5b42cd1c65cd7b21e496be67c3ab7
4
+ data.tar.gz: 86291665b498c940064b29e3efab8b1cd5e87f6a
5
5
  SHA512:
6
- metadata.gz: 34066adb901d1d5cb86d868c59d9b99d673510cd294611938691a56a824ae8684d94ac2cc453453ebea7f7e42a764d31d20e5d4de304915c8ffe44a5f7cabee7
7
- data.tar.gz: 5ac6aa322a48589315437630a093436e1c91638fa98425347e6473144ef42def6402c245f75f0b85e9dee3390367ce07bf1a64ab0ee17c54481c6381febe1583
6
+ metadata.gz: 1a6b61e68d399a374d15bcb079f2ce06700442b3d00b70ee308bd166f2733dff45c9fe15912d0e82c17ebfaaed38979da301b6e75c220480c20c9373a1c78796
7
+ data.tar.gz: ac1f8a1d79f795cb08fa185f81c0066449a2c283a2a54ff0442199bd4f1af34f202619f81641ac299768d611e63a338b450c439e6ff6fc1c3eca78297cd05b3e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gamma (0.1.8)
4
+ gamma (0.1.9)
5
5
  activesupport
6
6
  colorize (~> 0.8.1)
7
7
  mysql2
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (5.2.0)
13
+ activesupport (5.2.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 0.7, < 2)
16
16
  minitest (~> 5.1)
@@ -18,11 +18,11 @@ GEM
18
18
  coderay (1.1.2)
19
19
  colorize (0.8.1)
20
20
  concurrent-ruby (1.0.5)
21
- i18n (1.0.1)
21
+ i18n (1.1.1)
22
22
  concurrent-ruby (~> 1.0)
23
23
  method_source (0.9.0)
24
24
  minitest (5.11.3)
25
- mysql2 (0.5.1)
25
+ mysql2 (0.5.2)
26
26
  pry (0.11.3)
27
27
  coderay (~> 1.1.0)
28
28
  method_source (~> 0.9.0)
@@ -19,6 +19,8 @@ class Gamma::Command::Apply < Gamma::Command
19
19
  case t.sync_mode
20
20
  when "replace"
21
21
  Gamma::Importer::Replace.new(@in_client, @out_client, t, apply: true).execute
22
+ when "force_replace"
23
+ Gamma::Importer::Replace.new(@in_client, @out_client, t, apply: true, ignore_error: true).execute
22
24
  else
23
25
  logger.info("[#{t.sync_mode}] Sync Failed #{t.table_name}. Unknown Sync mode".red)
24
26
  end
@@ -1,11 +1,12 @@
1
1
  class Gamma::Importer::Replace < Gamma::Importer
2
2
  BATCH_SIZE = 1000
3
3
 
4
- def initialize(in_client, out_client, table, apply: false)
4
+ def initialize(in_client, out_client, table, apply: false, ignore_error: false)
5
5
  @in_client = in_client
6
6
  @out_client = out_client
7
7
  @table = table
8
8
  @apply = apply
9
+ @ignore_error = ignore_error
9
10
  end
10
11
 
11
12
  def execute
@@ -70,7 +71,7 @@ class Gamma::Importer::Replace < Gamma::Importer
70
71
  logger.info(query) if ENV["DEBUG"]
71
72
 
72
73
  if @apply
73
- @out_client.client.query(query)
74
+ exec_query(query)
74
75
  else
75
76
  logger.info("DRYRUN: #{query}")
76
77
  end
@@ -90,7 +91,7 @@ class Gamma::Importer::Replace < Gamma::Importer
90
91
  logger.info(query) if ENV["DEBUG"]
91
92
 
92
93
  if @apply
93
- @out_client.client.query(query)
94
+ exec_query(query)
94
95
  else
95
96
  logger.info("DRYRUN: #{query}")
96
97
  end
@@ -119,4 +120,15 @@ class Gamma::Importer::Replace < Gamma::Importer
119
120
  "`#{v}` = \"#{@out_client.client.escape(c.to_s)}\""
120
121
  end.join(",")
121
122
  end
123
+
124
+ def exec_query(query)
125
+ @out_client.client.query(query)
126
+ rescue => e
127
+ if @ignore_error
128
+ logger.error("An ERROR has occurred and ignore it.")
129
+ logger.error(e)
130
+ else
131
+ throw e
132
+ end
133
+ end
122
134
  end
@@ -1,3 +1,3 @@
1
1
  module Gamma
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinsuke Nishio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2