cns 2.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10d60e5c5e683a7c2ad17d60532961115ebb9cc11675a9cdd3645023e1d6d341
4
- data.tar.gz: 9433d97fb80918e5692876a5c587ea8c49675b7428bd3d997b83ecf582d07998
3
+ metadata.gz: ba101a6a6bbdbb1272e8cc61fe00f03b779b907066dd3c2ac6c29ee2543c8ec5
4
+ data.tar.gz: fdb6a8433f4e738851490b07baae241b524326f6917f07e260039ac19d6b5df6
5
5
  SHA512:
6
- metadata.gz: 43705d3c61efbce62cb6a2ea81521d82b68e5037b813be3f98f768428a6b1c8d2663b61bfa3445bf46725ea523ee8e208fcb5834de17d14a24d433a7fb4572e2
7
- data.tar.gz: 9966889ee9f1bd6b2b30f121f36ed425c977dc2a6f27e9be3382aad3b7dcb780959cdff07f9bf6d7262ec208cc76e4a21cdb44af6901fe5c61f3968c5e248e0a
6
+ metadata.gz: 6070637e17f7176b2bb28be217c0a7b1ad1f88066a9fa8befe312a2f687237cfe503f744c14652d2654ad0dfd8b878358286b097a7fd3a966e87fdb37410029c
7
+ data.tar.gz: d5de5d4806a1cfd64f349f120532557d3c161f5ddfec78a8972062c181f644906b0f3c8d85287bd9d879d1b2ed4131fcb2d76fde225569a51ca803e3e176a544
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cns (2.0.0)
4
+ cns (2.0.2)
5
5
  curb
6
6
  faraday
7
7
  faraday-retry
@@ -59,7 +59,7 @@ GEM
59
59
  net-http (>= 0.5.0)
60
60
  faraday-retry (2.2.1)
61
61
  faraday (~> 2.0)
62
- google-apis-bigquery_v2 (0.84.0)
62
+ google-apis-bigquery_v2 (0.85.0)
63
63
  google-apis-core (>= 0.15.0, < 2.a)
64
64
  google-apis-core (0.16.0)
65
65
  addressable (~> 2.5, >= 2.5.1)
@@ -69,7 +69,7 @@ GEM
69
69
  mutex_m
70
70
  representable (~> 3.0)
71
71
  retriable (>= 2.0, < 4.a)
72
- google-cloud-bigquery (1.51.1)
72
+ google-cloud-bigquery (1.52.0)
73
73
  bigdecimal (~> 3.0)
74
74
  concurrent-ruby (~> 1.0)
75
75
  google-apis-bigquery_v2 (~> 0.71)
@@ -77,14 +77,15 @@ GEM
77
77
  google-cloud-core (~> 1.6)
78
78
  googleauth (~> 1.9)
79
79
  mini_mime (~> 1.0)
80
- google-cloud-core (1.7.1)
80
+ google-cloud-core (1.8.0)
81
81
  google-cloud-env (>= 1.0, < 3.a)
82
82
  google-cloud-errors (~> 1.0)
83
- google-cloud-env (2.2.1)
83
+ google-cloud-env (2.2.2)
84
+ base64 (~> 0.2)
84
85
  faraday (>= 1.0, < 3.a)
85
86
  google-cloud-errors (1.5.0)
86
87
  google-logging-utils (0.1.0)
87
- googleauth (1.13.1)
88
+ googleauth (1.14.0)
88
89
  faraday (>= 1.0, < 3.a)
89
90
  google-cloud-env (~> 2.2)
90
91
  google-logging-utils (~> 0.1)
@@ -95,7 +96,7 @@ GEM
95
96
  httpclient (2.9.0)
96
97
  mutex_m
97
98
  jaro_winkler (1.6.0)
98
- json (2.10.1)
99
+ json (2.10.2)
99
100
  jwt (2.10.1)
100
101
  base64
101
102
  kramdown (2.5.1)
@@ -110,7 +111,7 @@ GEM
110
111
  mutex_m (0.3.0)
111
112
  net-http (0.6.0)
112
113
  uri
113
- nokogiri (1.18.3-x86_64-linux-gnu)
114
+ nokogiri (1.18.4-x86_64-linux-gnu)
114
115
  racc (~> 1.4)
115
116
  observer (0.1.2)
116
117
  os (1.1.4)
@@ -123,7 +124,7 @@ GEM
123
124
  racc (1.8.1)
124
125
  rainbow (3.1.1)
125
126
  rake (12.3.3)
126
- rbs (3.8.1)
127
+ rbs (3.9.0)
127
128
  logger
128
129
  reek (6.4.0)
129
130
  dry-schema (~> 1.13.0)
@@ -140,7 +141,7 @@ GEM
140
141
  reverse_markdown (3.0.0)
141
142
  nokogiri
142
143
  rexml (3.4.1)
143
- rubocop (1.73.2)
144
+ rubocop (1.74.0)
144
145
  json (~> 2.3)
145
146
  language_server-protocol (~> 3.17.0.2)
146
147
  lint_roller (~> 1.1.0)
@@ -151,7 +152,7 @@ GEM
151
152
  rubocop-ast (>= 1.38.0, < 2.0)
152
153
  ruby-progressbar (~> 1.7)
153
154
  unicode-display_width (>= 2.4.0, < 4.0)
154
- rubocop-ast (1.38.1)
155
+ rubocop-ast (1.39.0)
155
156
  parser (>= 3.3.1.0)
156
157
  rubocop-rake (0.7.1)
157
158
  lint_roller (~> 1.1)
@@ -192,7 +193,7 @@ GEM
192
193
  yard (0.9.37)
193
194
  yard-solargraph (0.1.0)
194
195
  yard (~> 0.9)
195
- zeitwerk (2.6.18)
196
+ zeitwerk (2.7.2)
196
197
 
197
198
  PLATFORMS
198
199
  x86_64-linux
@@ -208,4 +209,4 @@ DEPENDENCIES
208
209
  yard
209
210
 
210
211
  BUNDLED WITH
211
- 2.6.3
212
+ 2.5.3
data/lib/cns/bigquery.rb CHANGED
@@ -51,7 +51,7 @@ module Cns
51
51
  # @return [Google::Cloud::Bigquery::QueryJob] job bigquery
52
52
  # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
53
53
  # @return (see sql)
54
- attr_reader :api, :job, :ops, :sqr
54
+ attr_reader :api, :job, :ops
55
55
 
56
56
  # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
57
57
  # @option pop [Hash] :h ({}) configuracao ajuste reposicionamento temporal
@@ -113,54 +113,27 @@ module Cns
113
113
 
114
114
  # @return [String] linhas & tabelas afetadas
115
115
  def peth
116
- dml_out(apies, %w[ETH], %i[netht nethi nethp nethw nethk])
116
+ dmo(apies, %w[ETH], %i[netht nethi nethp nethw nethk])
117
117
  end
118
118
 
119
119
  # @return [String] linhas & tabelas afetadas
120
120
  def pethc
121
- dml_out(apiesc, %w[ETH], %i[netht nethi nethp nethw nethk])
121
+ dmo(apiesc, %w[ETH], %i[netht nethi nethp nethw nethk])
122
122
  end
123
123
 
124
124
  # @return [String] linhas & tabelas afetadas
125
125
  def pus
126
- dml_out(apius, %w[KRAKEN], %i[cust cusl])
126
+ dmo(apius, %w[KRAKEN], %i[cust cusl])
127
127
  end
128
128
 
129
129
  # @return [String] linhas & tabelas afetadas
130
130
  def pde
131
- dml_out(apide, %w[BITCOINDE], %i[cdet cdel])
131
+ dmo(apide, %w[BITCOINDE], %i[cdet cdel])
132
132
  end
133
133
 
134
134
  # @return [String] linhas & tabelas afetadas
135
135
  def peos
136
- dml_out(apigm, %w[EOS], %i[neost])
137
- end
138
-
139
- # cria job bigquery & verifica execucao
140
- # @param cmd (see sql)
141
- # @return [Boolean] job ok?
142
- def job?(cmd)
143
- @job = api.query_job(cmd, priority: 'BATCH')
144
- job.wait_until_done!
145
- return true unless job.failed?
146
-
147
- puts("BigQuery Error: #{job.error['message']}")
148
- false
149
- end
150
-
151
- # cria Structured Query Language (SQL) job bigquery
152
- # @param [String] cmd comando SQL a executar
153
- # @param [String] res resultado quando SQL tem erro
154
- # @return [Google::Cloud::Bigquery::Data] resultado do SQL
155
- def sql(cmd, res = [])
156
- @sqr = job?(cmd) ? job.data : res
157
- end
158
-
159
- # cria Data Manipulation Language (DML) job bigquery
160
- # @param cmd (see sql)
161
- # @return [Integer] numero linhas afetadas
162
- def dml(cmd)
163
- job?(cmd) ? job.num_dml_affected_rows : 0
136
+ dmo(apigm, %w[EOS], %i[neost])
164
137
  end
165
138
 
166
139
  # @return [Etherscan] API blockchain ETH
@@ -203,6 +176,50 @@ module Cns
203
176
  @apide ||= Bitcoinde.new({sl: sql("select * from #{BD}.cdes").first, nt: sql("select * from #{BD}.cdet#{TL[:det]}"), nl: sql("select * from #{BD}.cdel#{TL[:del]}")}, ops)
204
177
  end
205
178
 
179
+ # cria job bigquery & verifica execucao
180
+ # @param cmd (see sql)
181
+ # @param [Hash] prm parâmetros para a query
182
+ # @return [Boolean] job ok?
183
+ def job?(cmd, prm = {})
184
+ @job = api.query_job(cmd, params: prm, priority: 'BATCH')
185
+ job.wait_until_done!
186
+ return true unless job.failed?
187
+
188
+ puts("BigQuery: #{job.error['message']}\n#{cmd}")
189
+ false
190
+ end
191
+
192
+ # cria Structured Query Language (SQL) job bigquery
193
+ # @param [String] cmd comando SQL a executar
194
+ # @param [String] res resultado quando SQL tem erro
195
+ # @return [Google::Cloud::Bigquery::Data] resultado do SQL
196
+ def sql(cmd, prm = {})
197
+ job?(cmd, prm) ? job.data : []
198
+ end
199
+
200
+ # cria Data Manipulation Language (DML) job bigquery
201
+ # @param cmd (see sql)
202
+ # @return [Integer] numero linhas afetadas
203
+ def dml(cmd, prm = {})
204
+ job?(cmd, prm) ? job.num_dml_affected_rows : 0
205
+ end
206
+
207
+ # junta resultados inserts no bigquery
208
+ # @param [API] api blockchains/exchanges
209
+ # @param [String] ini comando SQL a executar
210
+ # @return [String] relatorio execucao dmls
211
+ def dmo(api, ini, ltb)
212
+ ini.concat(
213
+ ltb.filter_map do |i|
214
+ n = api.send("nov#{i}")
215
+ next if n.empty?
216
+
217
+ format(' %<n>i %<t>s', n: dml(ins_sql(i, n)), t: "#{i}")
218
+ end
219
+ )
220
+ ini.join
221
+ end
222
+
206
223
  # @return [String] comando insert SQL formatado
207
224
  def ins_sql(tbl, lin)
208
225
  # para testes bigquery
@@ -215,19 +232,6 @@ module Cns
215
232
  "#{TL[:ins]} #{BD}.#{tbl} (#{TB[tbl].join(',')}) VALUES #{lin.map { |i| send("#{tbl}_val", i) }.join(',')}"
216
233
  end
217
234
 
218
- # @return [String] relatorio execucao dml
219
- def dml_out(src, str, ltb)
220
- str.concat(
221
- ltb.filter_map do |i|
222
- novx = src.send("nov#{i}")
223
- next if novx.empty?
224
-
225
- format(' %<n>i %<t>s', n: dml(ins_sql(i, novx)), t: "#{i}")
226
- end
227
- )
228
- str.join
229
- end
230
-
231
235
  # @return [String] escapes SQL user input strings
232
236
  def escape_sql(value)
233
237
  value.gsub("'", "''").gsub('\\', '\\\\')
data/lib/cns/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cns
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.2'
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cns
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-03-08 00:00:00.000000000 Z
11
+ date: 2025-03-18 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bundler
@@ -216,6 +217,7 @@ metadata:
216
217
  homepage_uri: https://github.com/hernanirvaz/cns
217
218
  yard.run: yard
218
219
  rubygems_mfa_required: 'true'
220
+ post_install_message:
219
221
  rdoc_options: []
220
222
  require_paths:
221
223
  - lib
@@ -230,7 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
232
  - !ruby/object:Gem::Version
231
233
  version: '0'
232
234
  requirements: []
233
- rubygems_version: 3.6.3
235
+ rubygems_version: 3.5.3
236
+ signing_key:
234
237
  specification_version: 4
235
238
  summary: Arquiva transactions etherscan/greymass/bitcoinde/kraken/paymium/therock
236
239
  no bigquery.