naginegi 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a23dc48ebec8810113d0b5a3a085c106048bb8aa24cfffc25d7e9c420ff5504
4
- data.tar.gz: 3cdfdf331f116492d7457072fc16f93bb6ab88fb7b8c8efdfb286f745f8dd11d
3
+ metadata.gz: bffe8bf28a51050e58ef2ccb8d25da01691d27f1e28aec92a42c98c1d4a69248
4
+ data.tar.gz: 5e47d30b633d323c58c4dfc8cbcad5f6cd594567e13d3ae52b62717e9b733c5e
5
5
  SHA512:
6
- metadata.gz: 4af85f8bdad42f90f06478954ccda166f35028a4660b11b08dbfe7a3ef94a9e8c8652212673549d1d2bac485cebd4dd05102cf021328a63fb67ccf97e6e4dfef
7
- data.tar.gz: 803c5fe510fccc0e98dd9fec3294a576f58c2f25c3df531b4f53e1bad42e90fd68754bca8b5076dd6894c919112577ff3c5101de16cb6c68592ce59de3e42daa
6
+ metadata.gz: b967eedb71e86f4cf20a65bcb479fe008faf80cd3709e46c22cad69d9e310b92900105a1208db94cdacc0fc603bf2e7b5c17e043bce87ba504029d71ee2a83f6
7
+ data.tar.gz: 981dd5ebda7890cbc6b5cfba8dc8d2b5e1dd531dc7614225b2115beb235ef212bfb7a450c3efea275aa7058084fb3408cdc2e52addff1184a434b5381941efdc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- naginegi (0.1.0)
4
+ naginegi (0.3.0)
5
5
  google-cloud-bigquery (= 1.18.1)
6
6
  mysql2 (= 0.5.3)
7
7
  mysql2-cs-bind (= 0.0.7)
@@ -53,7 +53,6 @@ GEM
53
53
  mini_mime (1.0.2)
54
54
  multi_json (1.14.1)
55
55
  multipart-post (2.1.1)
56
- mysql2 (0.5.3)
57
56
  mysql2 (0.5.3-x64-mingw32)
58
57
  mysql2-cs-bind (0.0.7)
59
58
  mysql2
@@ -61,7 +60,6 @@ GEM
61
60
  parallel (1.19.1)
62
61
  parser (2.7.0.1)
63
62
  ast (~> 2.4.0)
64
- pg (1.2.2)
65
63
  pg (1.2.2-x64-mingw32)
66
64
  powerpack (0.1.2)
67
65
  public_suffix (4.0.3)
data/README.md CHANGED
@@ -77,8 +77,10 @@ db02:
77
77
  - name: configs
78
78
  ```
79
79
 
80
+ ### sample
80
81
  Naginegi requires BigQuery parameters like below.
81
82
 
83
+ #### using json key file path
82
84
  ```ruby
83
85
  [sample.rb]
84
86
  require 'naginegi'
@@ -101,6 +103,37 @@ client.run(config)
101
103
  ruby sample.rb
102
104
  ```
103
105
 
106
+ #### using key values
107
+ ```ruby
108
+ [sample.rb]
109
+ require 'naginegi'
110
+
111
+ json_key = {
112
+ "type" => "...",
113
+ "project_id" => "...",
114
+ "private_key_id" => "...",
115
+ "private_key" => "...",
116
+ ...
117
+ }
118
+
119
+ config = {
120
+ 'project_id' => 'BIGQUERY_PROJECT_ID',
121
+ 'service_email' => 'SERVICE_ACCOUNT_EMAIL',
122
+ 'auth_method' => 'json_key',
123
+ 'json_key' => json_key,
124
+ 'schema_dir' => '/var/tmp/embulk/schema',
125
+ 'config_dir' => '/var/tmp/embulk/config'
126
+ }
127
+
128
+ client = Naginegi::EmbulkRunner.new
129
+ client.generate_config(config)
130
+ client.run(config)
131
+ ```
132
+
133
+ ```bash
134
+ ruby sample.rb
135
+ ```
136
+
104
137
  ## Features
105
138
  ### process status
106
139
  `Naginegi` returns process status as boolean.
@@ -21,6 +21,7 @@ module Naginegi
21
21
  type: bigquery
22
22
  auth_method: <%= auth_method %>
23
23
  json_keyfile: <%= json_keyfile %>
24
+ <%= json_key_content %>
24
25
  project: <%= project %>
25
26
  service_account_email: <%= service_account_email %>
26
27
  dataset: <%= dataset %>
@@ -71,7 +72,15 @@ module Naginegi
71
72
  query = Naginegi::BigQuery.generate_sql(table_config, columns)
72
73
 
73
74
  auth_method = @config['auth_method']
74
- json_keyfile = @config['json_keyfile']
75
+ if @config['json_key']
76
+ values = @config['json_key'].map do |k, v|
77
+ value = v.gsub("\n", '\\n')
78
+ "\"#{k}\": \"#{value}\""
79
+ end
80
+ json_key_content = "content: |\n {#{values.join(',')}}"
81
+ else
82
+ json_keyfile = @config['json_keyfile']
83
+ end
75
84
  project = @config['project_id']
76
85
  service_account_email = @config['service_email']
77
86
  dataset = db_config['bq_dataset']
@@ -1,3 +1,3 @@
1
1
  module Naginegi
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naginegi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cobot00
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-20 00:00:00.000000000 Z
11
+ date: 2020-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler