dcm 0.1.27 → 0.1.29

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: 5cb902865c8f528d8d32808549e51ff0e08f0f910ebbc20a7b4fe86b88f757b6
4
- data.tar.gz: 825479e3f3df7d15020313b8a4dc1f2f103d9a84ae389e1307f223c05244610e
3
+ metadata.gz: 3425c7beeb19488c92604b47bb29e2ac96491412ddd296962a06c3bbf4ed0d35
4
+ data.tar.gz: 45bbccca19427da0363a841feca5f70643e2cd79bc6a3ffb728189b5b3102104
5
5
  SHA512:
6
- metadata.gz: 25334697c4789de67dfd522acf054a853614802312849c89711734f7ffdd445b284f010ce720e543500794fe8164d426ef72dcc0ac854d7a93601ad2f57cc6ef
7
- data.tar.gz: 01c20d7e8afafb326a5064bfe45f49b8b095c02372e348ab25f399aa1a1378f1f284b934368c145c2fd1ce7e15f3f16d64f24f46e57dd1e3c1b8945ce797a942
6
+ metadata.gz: d9d7234a981b6a344c637711d1d75998b52d01dd3bdd078fcfc3d32d42104936deb41f198afc4af761a26c2d55eebc2d21c934090995fe5e16ff476c9f17f494
7
+ data.tar.gz: eb2135b645284d146ac305bbc6c00de43f19a3e7c7fe24cfab8a737714798a2238ca73084e45c3a2dbb5d35939cc29ab0da567e0916bb1bbc9972f051642f3b8
data/lib/cli.rb CHANGED
@@ -4,6 +4,7 @@ require "bundler"
4
4
  require "ecu"
5
5
  require "thor"
6
6
  require "filesize"
7
+ require "tmpdir"
7
8
  require "json"
8
9
 
9
10
  require_relative "file_reader"
@@ -14,6 +15,7 @@ require_relative "diff_viewer"
14
15
  require_relative "variant_filter"
15
16
  require_relative "fuzzy_selector"
16
17
  require_relative "list_colorizer"
18
+ require_relative "list_augmenter"
17
19
  require_relative "core_ext"
18
20
  require_relative "version"
19
21
 
@@ -25,6 +27,8 @@ module Dcm
25
27
 
26
28
  class CLI < Thor
27
29
 
30
+ LASTOUTPUTCACHE = File.join(Dir.tmpdir, "lastoutput.dcm")
31
+
28
32
  def help(*cmds)
29
33
  super
30
34
  puts <<~EOS if cmds.any? { _1.match?("creta") }
@@ -37,6 +41,17 @@ module Dcm
37
41
 
38
42
  class_option :nocache, type: :boolean, aliases: ["-n"]
39
43
 
44
+ map _: :lastoutput
45
+
46
+ desc "lastoutput", "Repeat the last output"
47
+ def lastoutput
48
+ if File.exist?(LASTOUTPUTCACHE)
49
+ puts File.read(LASTOUTPUTCACHE)
50
+ else
51
+ fail "No output found - please run dcm cat|select first"
52
+ end
53
+ end
54
+
40
55
  desc "show FILE", "Show all labels in FILE"
41
56
  option :oneline, type: :boolean, aliases: ["-l"]
42
57
  def show(file=nil)
@@ -139,7 +154,7 @@ module Dcm
139
154
  if options[:mfile]
140
155
  puts list.to_mfile
141
156
  else
142
- puts list.to_dcm(options[:indented])
157
+ print_cached list.to_dcm(options[:indented])
143
158
  end
144
159
  end
145
160
 
@@ -147,7 +162,7 @@ module Dcm
147
162
  option :indented, aliases: ["-i"], type: :boolean, default: false
148
163
  def select(file=nil)
149
164
  list = parse_file(file)
150
- puts FuzzySelector.new(list, "dcm cat -f {} #{file} | dcm show")
165
+ print_cached FuzzySelector.new(list, "dcm cat -f {} #{file} | dcm show")
151
166
  .then { _1.select_by(&:name) }
152
167
  .tap { exit if _1.empty? }
153
168
  .then { _1.to_dcm(options[:indented]) }
@@ -316,6 +331,7 @@ module Dcm
316
331
  in :tty
317
332
  puts list
318
333
  .map { _1.to_s(detail: detail) }
334
+ .map { ListAugmenter.call(_1) }
319
335
  .map { ListColorizer.call(_1) }
320
336
  .join("\n")
321
337
  in :lab
@@ -325,6 +341,11 @@ module Dcm
325
341
  end
326
342
  end
327
343
 
344
+ def print_cached(str)
345
+ File.write(LASTOUTPUTCACHE, str)
346
+ puts str
347
+ end
348
+
328
349
  def render_comparison(file1, file2, precision:)
329
350
  lists = [file1, file2]
330
351
  .map { FileReader.read(_1) }
@@ -0,0 +1,32 @@
1
+ class Array
2
+ def padd_to_fours!(fill = "0")
3
+ while (self.length % 4) != 0
4
+ self.unshift(fill)
5
+ end
6
+ self
7
+ end
8
+ end
9
+
10
+ class Integer
11
+ def to_bin
12
+ "0b" + to_s(2)
13
+ .chars
14
+ .padd_to_fours!
15
+ .each_slice(4)
16
+ .map(&:join)
17
+ .join(" ")
18
+ end
19
+ end
20
+
21
+ class ListAugmenter
22
+ def self.call(str)
23
+ return str unless str.include?("_cw_")
24
+
25
+ str.lines.map do |line|
26
+ next line unless line.strip.start_with?("Value:")
27
+
28
+ value = line[/Value: (\d+)/, 1].to_i
29
+ line.chomp + " (#{value.to_bin})\n"
30
+ end.join
31
+ end
32
+ end
@@ -9,4 +9,3 @@ class TempfileHandler
9
9
  file.close
10
10
  end
11
11
  end
12
-
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dcm
2
- VERSION = "0.1.27"
2
+ VERSION = "0.1.29"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Mueller
@@ -179,6 +179,7 @@ files:
179
179
  - lib/file_cache.rb
180
180
  - lib/file_reader.rb
181
181
  - lib/fuzzy_selector.rb
182
+ - lib/list_augmenter.rb
182
183
  - lib/list_colorizer.rb
183
184
  - lib/tempfile_handler.rb
184
185
  - lib/variant_filter.rb