lucarecord 0.5.5 → 0.5.6

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: 4574038ef165ecd098bd37897f77a16edb5917aa6c157ce45a005598bc540af2
4
- data.tar.gz: a2f22d1d3c9899e3c84c7662cb8859794541e31cbd116eae343deb4d4db3e415
3
+ metadata.gz: a8292ffede60ef44ad0ff29a395e29f957d9c10214b0c3aedbb09dc8079bb502
4
+ data.tar.gz: da00267ca8e4884c5e14ec23923be391043afb1aa169409be1f08009b15cbc7f
5
5
  SHA512:
6
- metadata.gz: 05dccaddb053508040dfab00cd9451b20b10d3a9b78a5317609ab8e71a548109cee9c4ff2579132f2e7380bb470d8639e6ddfb80ffdb23e324c2971e89d596d0
7
- data.tar.gz: e33237c779d1450bd6c1b9a1c208382a8eda87848da74117b36bc973b93c44b965e1970d8eea60eb0d83698361406700c4dbe1480d511bc0130ece78cf7c6cf3
6
+ metadata.gz: 6a08fd4e4a5d009273127e05105dcee05783f1df107c9296cf2ba64146f5ce61952d51817a1fc41c7dd1adab327ca825e3c67471f2f93eb0541c74037fa2269d
7
+ data.tar.gz: 1b26ae61830565c856b2ff41220236caffbefb4015c4a483f77f4c15aaa3ac6caab85ebb3b1c0e0d8f669e92d5ec0c37ffe4bb69f773cc8e4771f8598710589a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## LucaRecord 0.5.6
2
+
3
+ * add Nushell render mode: expand(default) | collapse | explore(`less` like)
4
+ * add `LucaSupport::Code.take_history()`, listing all effective/defunct values.
5
+
1
6
  ## LucaRecord 0.5.5
2
7
 
3
8
  * support JSON for `LucaRecord::Base.load_data()` w/ `@record_type = 'json'`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaRecord
4
- VERSION = '0.5.5'
4
+ VERSION = '0.5.6'
5
5
  end
@@ -180,7 +180,6 @@ module LucaSupport # :nodoc:
180
180
  end
181
181
  end
182
182
 
183
- #
184
183
  # convert effective/defunct data into current hash on @date.
185
184
  # not parse nested children.
186
185
  #
@@ -221,6 +220,18 @@ module LucaSupport # :nodoc:
221
220
  latest&.dig('val') || latest
222
221
  end
223
222
 
223
+ # convert all effective/defunct data into Array
224
+ # not parse nested children.
225
+ #
226
+ def take_history(dat, item)
227
+ target = dat&.dig(item)
228
+ return Array(target) unless target.is_a?(Array)
229
+
230
+ target
231
+ .sort { |a, b| Date.parse(a['effective'].to_s) <=> Date.parse(b['effective'].to_s) }
232
+ .map { |a| a['val'] }
233
+ end
234
+
224
235
  def has_status?(dat, status)
225
236
  return false if dat['status'].nil?
226
237
 
@@ -48,7 +48,10 @@ module LucaSupport
48
48
  nil
49
49
  end
50
50
 
51
- def nushell(records, columns=[])
51
+ # render mode swithes nushell Viewer
52
+ # https://www.nushell.sh/commands/categories/viewers.html
53
+ #
54
+ def nushell(records, mode=:expand, columns=[])
52
55
  return nil if records.is_a?(String)
53
56
 
54
57
  require 'open3'
@@ -57,7 +60,15 @@ module LucaSupport
57
60
  else
58
61
  '| select --ignore-errors ' + columns.map { |col| col.gsub(/[^a-zA-Z0-9_-]/, '') }.join(' ')
59
62
  end
60
- Open3.pipeline_w(%(nu -c 'cat - | from json #{select}')) { |stdin| stdin.puts JSON.dump(records) }
63
+ render = case mode
64
+ when :explore
65
+ 'explore'
66
+ when :collapse
67
+ 'table -c'
68
+ else
69
+ 'table -e'
70
+ end
71
+ Open3.pipeline_w(%(nu -c 'cat - | from json #{select} | #{render}')) { |stdin| stdin.puts JSON.dump(records) }
61
72
  end
62
73
  end
63
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucarecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler