pais_legacy 0.9.5 → 1.0.0

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: f3f76918370bfcdf2ae567c9f47dc0f6816216f7906ac0f6e788937e5001b8e5
4
- data.tar.gz: b34ed237ed5ebc27fcc1366813a5ae089c08782b3e07640bfe0c7bcd3328eac5
3
+ metadata.gz: 7781a195d6ca0b1a5646d9b54f94dfb6e5c191e6faae253583edce96d91c3abd
4
+ data.tar.gz: 23f333dfbc02f52d9dc37479513a4803b0bfabae087445dcb96b62b29327f282
5
5
  SHA512:
6
- metadata.gz: e2f74f0890077c08d15fd0b990b776a5bccb9df031473181137683397107e94d41055036ecc3dfe912323aaf8ed06ec558edb055b5a92a78ed29ab594111a53f
7
- data.tar.gz: 55625546e68ad97b1ed763bedda2388f444fc35237c7709940ca80ff11e2a3ff739e6619265b10625bb43d902e8816e0ac84dff5f7112aac2d4cd2c7e22674d2
6
+ metadata.gz: ca824af258bda5c602d6cd8b2e6c4da5415aae44ea2f01386351adf785401d43411642e4dac15687a180ecd852c237ee1dc647bd8ed31e291d713121ec67b4df
7
+ data.tar.gz: fcf6d12e7d531e14487675c7214ebecb51522350b355e6f5e214a1b19540679d67a759bfc6c6a40a9bfe3cf75bfe108a4a5d560d69fe892ade9a13ac8b0a9a53
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pais_legacy (0.7.3)
4
+ pais_legacy (0.9.5)
5
5
  byebug (~> 11.0)
6
6
  minitest (~> 5.0)
7
7
  mocha (~> 1.0)
@@ -14,30 +14,32 @@ GEM
14
14
  ast (2.4.2)
15
15
  byebug (11.1.3)
16
16
  json (2.6.3)
17
- minitest (5.17.0)
17
+ minitest (5.18.0)
18
18
  mocha (1.16.1)
19
- parallel (1.22.1)
20
- parser (3.2.0.0)
19
+ parallel (1.23.0)
20
+ parser (3.2.2.3)
21
21
  ast (~> 2.4.1)
22
+ racc
22
23
  pastel (0.8.0)
23
24
  tty-color (~> 0.5)
25
+ racc (1.7.0)
24
26
  rainbow (3.1.1)
25
27
  rake (13.0.6)
26
- regexp_parser (2.6.1)
28
+ regexp_parser (2.8.1)
27
29
  rexml (3.2.5)
28
- rubocop (1.43.0)
30
+ rubocop (1.52.1)
29
31
  json (~> 2.3)
30
32
  parallel (~> 1.10)
31
- parser (>= 3.2.0.0)
33
+ parser (>= 3.2.2.3)
32
34
  rainbow (>= 2.2.2, < 4.0)
33
35
  regexp_parser (>= 1.8, < 3.0)
34
36
  rexml (>= 3.2.5, < 4.0)
35
- rubocop-ast (>= 1.24.1, < 2.0)
37
+ rubocop-ast (>= 1.28.0, < 2.0)
36
38
  ruby-progressbar (~> 1.7)
37
39
  unicode-display_width (>= 2.4.0, < 3.0)
38
- rubocop-ast (1.24.1)
39
- parser (>= 3.1.1.0)
40
- ruby-progressbar (1.11.0)
40
+ rubocop-ast (1.29.0)
41
+ parser (>= 3.2.1.0)
42
+ ruby-progressbar (1.13.0)
41
43
  timecop (0.9.6)
42
44
  tty-color (0.6.0)
43
45
  unicode-display_width (2.4.2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaisLegacy
4
- VERSION = "0.9.5"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/pais_legacy.rb CHANGED
@@ -40,12 +40,12 @@ module PaisLegacy
40
40
  end
41
41
 
42
42
  def self.glch_read(ledger)
43
- out,_,_=Open3.capture2(glch_read_cmd(ledger.to_s))
44
-
45
- out.
46
- split("\n").
47
- map{|line| line.split(",")}.
48
- map{|line| {value: line[0], text: "#{line[0]}-#{line[1]}"}}
43
+ # out,_,_=Open3.capture2(glch_read_cmd(ledger.to_s))
44
+ # out.
45
+ # split("\n").
46
+ # map{|line| line.split(",")}.
47
+ # map{|line| {value: line[0], text: "#{line[0]}-#{line[1]}"}}
48
+ glch_read_all(ledger)["accounts"].map {|h| {value: h["code"], text: "#{h['code']}-#{h['description']}"}}
49
49
  end
50
50
 
51
51
  def self.glch_read_all(ledger)
@@ -122,7 +122,7 @@ module PaisLegacy
122
122
  # end
123
123
  # end
124
124
 
125
- [out]
125
+ out.split("\n")
126
126
  end
127
127
 
128
128
  # Get the accounts using the trial balance
@@ -268,6 +268,50 @@ module PaisLegacy
268
268
  end
269
269
  end
270
270
 
271
+ # --------------------------------------------------------------------------------
272
+ # DB related
273
+ # --------------------------------------------------------------------------------
274
+ def self.table_schema_cmd(table)
275
+ ssh + ' "bash -l -c \"' + fglgo("db") + ' schema {{table}}\""'
276
+ .gsub("{{table}}",table)
277
+ end
278
+
279
+ def self.table_schema_raw(table)
280
+ out,_,_=Open3.capture2(table_schema_cmd(table))
281
+ out.split("\n")
282
+ end
283
+
284
+ def self.table_schema(table)
285
+ table_schema_raw(table).map {|line|
286
+ array=line.split("|")
287
+ {name: array[0].strip, type_id: array[1].strip, type_name: array[2].strip}
288
+ }
289
+ end
290
+
291
+ def self.table_data_cmd(table)
292
+ ssh_with_tty + ' "bash -l -c \"' + fglgo("db") + ' data {{table}}\""'
293
+ .gsub("{{table}}",table)
294
+ end
295
+
296
+ def self.table_data_raw(table)
297
+ out,_,_=Open3.capture2(table_data_cmd(table))
298
+ out.split("\n")
299
+ end
300
+
301
+ def self.table_data(table)
302
+ columns=table_schema(table)
303
+
304
+ table_data_raw(table).map {|line|
305
+ array=line.split("|")
306
+ hash = Hash.new
307
+
308
+ columns.each_with_index do |col,i|
309
+ hash[col[:name].to_sym] = array[i].strip
310
+ end
311
+ hash
312
+ }
313
+ end
314
+
271
315
  private
272
316
  def self.accounts(account)
273
317
  account = account.split("/")
@@ -294,6 +338,10 @@ module PaisLegacy
294
338
  "ssh -oHostKeyAlgorithms=+ssh-dss #{PAISTRAM} -T"
295
339
  end
296
340
 
341
+ def self.ssh_with_tty
342
+ "ssh -oHostKeyAlgorithms=+ssh-dss #{PAISTRAM} -tt"
343
+ end
344
+
297
345
  def self.fglgo(file)
298
346
  "fglgo /hd0a/u/pais/live/prod/#{file}"
299
347
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pais_legacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pope
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug