samidare 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +3 -2
- data/lib/samidare.rb +2 -2
- data/lib/samidare/bigquery_utility.rb +31 -1
- data/lib/samidare/embulk_utility.rb +1 -0
- data/lib/samidare/version.rb +1 -1
- metadata +1 -3
- data/lib/samidare/embulk_config.erb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5773b739c82c8896501f93a28c8f9f16780fbcb
|
4
|
+
data.tar.gz: dcdf41eb57238dc34b6f399a0b7fc707d25549c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bf4586c4a43e98bd24e36515ae2ac2cdebc072e6c089ca0ac71914bece5266c2ec6f338fedd16cbddaf87f6fae86acb57c9851c8a46b1af34db4ebdc4540da0
|
7
|
+
data.tar.gz: 116af87aeae963a54116730a1d14e54d62323a96d39f5790028fd9e33e681ff2d1d3d5f793a746b54946bd0f3b62893c854f2be57118d175a1ab26a49cb804fd
|
data/README.md
CHANGED
data/lib/samidare.rb
CHANGED
@@ -2,12 +2,12 @@ require 'samidare/version'
|
|
2
2
|
require 'samidare/embulk_utility'
|
3
3
|
|
4
4
|
module Samidare
|
5
|
-
class
|
5
|
+
class EmbulkClient
|
6
6
|
def generate_config(config)
|
7
7
|
Samidare::EmbulkUtility::ConfigGenerator.new(config).generate_config
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def run(config)
|
11
11
|
db_infos = Samidare::EmbulkUtility::DBInfo.generate_db_infos
|
12
12
|
table_infos = Samidare::EmbulkUtility::TableInfo.generate_table_infos
|
13
13
|
db_infos.keys.each do |db_name|
|
@@ -1,9 +1,38 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'erb'
|
3
3
|
require 'big_query'
|
4
|
+
require 'unindent'
|
4
5
|
|
5
6
|
module Samidare
|
6
7
|
class BigQueryUtility
|
8
|
+
CONTENTS = <<-EOS.unindent
|
9
|
+
in:
|
10
|
+
type: mysql
|
11
|
+
user: <%= user %>
|
12
|
+
password: <%= password %>
|
13
|
+
database: <%= database %>
|
14
|
+
host: <%= host %>
|
15
|
+
query: |
|
16
|
+
<%= query %>
|
17
|
+
out:
|
18
|
+
type: bigquery
|
19
|
+
project: <%= project %>
|
20
|
+
p12_keyfile_path: <%= p12_keyfile_path %>
|
21
|
+
service_account_email: <%= service_account_email %>
|
22
|
+
dataset: <%= dataset %>
|
23
|
+
table: <%= table_name %>
|
24
|
+
schema_path: <%= schema_path %>
|
25
|
+
auto_create_table: 1
|
26
|
+
path_prefix: <%= path_prefix %>
|
27
|
+
source_format: NEWLINE_DELIMITED_JSON
|
28
|
+
file_ext: .json.gz
|
29
|
+
delete_from_local_when_job_end: 1
|
30
|
+
formatter:
|
31
|
+
type: jsonl
|
32
|
+
encoders:
|
33
|
+
- {type: gzip}
|
34
|
+
EOS
|
35
|
+
|
7
36
|
def initialize(config)
|
8
37
|
@config = config.dup
|
9
38
|
end
|
@@ -33,7 +62,8 @@ module Samidare
|
|
33
62
|
schema_path = "#{@config['schema_dir']}/#{db_name}/#{table_info.name}.json"
|
34
63
|
path_prefix = "/var/tmp/embulk_#{db_name}_#{table_info.name}"
|
35
64
|
|
36
|
-
File.open('lib/samidare/embulk_config.erb') { |f| ERB.new(f.read).result(binding) }
|
65
|
+
#File.open('lib/samidare/embulk_config.erb') { |f| ERB.new(f.read).result(binding) }
|
66
|
+
ERB.new(CONTENTS).result(binding)
|
37
67
|
end
|
38
68
|
|
39
69
|
def delete_table(dataset, table_name)
|
data/lib/samidare/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samidare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryoji Kobori
|
@@ -180,7 +180,6 @@ files:
|
|
180
180
|
- Rakefile
|
181
181
|
- lib/samidare.rb
|
182
182
|
- lib/samidare/bigquery_utility.rb
|
183
|
-
- lib/samidare/embulk_config.erb
|
184
183
|
- lib/samidare/embulk_utility.rb
|
185
184
|
- lib/samidare/version.rb
|
186
185
|
- samidare.gemspec
|
@@ -217,4 +216,3 @@ test_files:
|
|
217
216
|
- spec/samidare/embulk_utility_spec.rb
|
218
217
|
- spec/samidare_spec.rb
|
219
218
|
- spec/spec_helper.rb
|
220
|
-
has_rdoc:
|
@@ -1,25 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: mysql
|
3
|
-
user: <%= user %>
|
4
|
-
password: <%= password %>
|
5
|
-
database: <%= database %>
|
6
|
-
host: <%= host %>
|
7
|
-
query: |
|
8
|
-
<%= query %>
|
9
|
-
out:
|
10
|
-
type: bigquery
|
11
|
-
project: <%= project %>
|
12
|
-
p12_keyfile_path: <%= p12_keyfile_path %>
|
13
|
-
service_account_email: <%= service_account_email %>
|
14
|
-
dataset: <%= dataset %>
|
15
|
-
table: <%= table_name %>
|
16
|
-
schema_path: <%= schema_path %>
|
17
|
-
auto_create_table: 1
|
18
|
-
path_prefix: <%= path_prefix %>
|
19
|
-
source_format: NEWLINE_DELIMITED_JSON
|
20
|
-
file_ext: .json.gz
|
21
|
-
delete_from_local_when_job_end: 1
|
22
|
-
formatter:
|
23
|
-
type: jsonl
|
24
|
-
encoders:
|
25
|
-
- {type: gzip}
|