subunit 0.8.3 → 0.8.4

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: 807d54d4b08e3eedaacc7d9a9970d5cc8ee5c5e18bf75282a49c8ccf9ebcf7f6
4
- data.tar.gz: a5e43fca0a05710ce581a25cceb13da735ad7b9e36102bf162a966ac4fcb9dae
3
+ metadata.gz: 55e24efd3496c6090f8b887857fbefd3dc2a76f4a61fb4a8c3a6f19490bfa153
4
+ data.tar.gz: fd0af0f6e4fd910898141aa6c7bc13049cd2cd728ba4a9e19a5ab5a8cf9bf558
5
5
  SHA512:
6
- metadata.gz: a43cd22965a80bbeda08484b5939c4cea4a96e89940f37b14867f15f4a4370b672593c559d8eb57ba3667da1cf8ca11cbfa110f82cce335cf3c786f0631bb1ca
7
- data.tar.gz: 3b66e9c0bab9872d7738a896df2fbf7fd7492cc45ed0ac76b9cf12f633788fcd87a6fcc541d0b011bec5122a5aed6c3ff10b694168076ba9ac1dcb7d3d395cc9
6
+ metadata.gz: 9c2ff98f077a42af3dffc3788961f99bd98fb6643c5987f472e640094a485c138a8a4065a0832c98f27fd4b578d3e0972f1c5ae44a019014471e5cb2ef8e5bc1
7
+ data.tar.gz: 9ea37778dd9fe8cf32278572a70d4d188ee9b59a460e5e8139bc2e2ff28a13a8055d71d79a7205738c2504fdf595e76ab29c5825f7b749db392a30dedd8a784b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/subunit.rb CHANGED
@@ -63,20 +63,32 @@ class Subunit
63
63
  # .strfunit("%x") #=> 11m 1s
64
64
  #
65
65
  # %x e.g. 11m 1s
66
+ # %xi e.g. 11m
66
67
  # %X e.g. 11 minutes 1 second
68
+ # %Xi e.g. 11 minutes
67
69
  # %c e.g. 00:11:01
68
70
  # %s e.g. 11m # returns the 1st most significant value while
69
71
  # ignoring the remainder
70
72
  #
71
73
  def strfunit(s)
72
74
 
73
- s.sub!('%x') do |x|
74
- to_h.map {|label, val| val.to_s + label[0]}.join(' ')
75
+ # The i switch postfixed to the x or X switch will format the output
76
+ # without seconds unless there are no minutes.
77
+
78
+ s.sub!(/%xi?/) do |x|
79
+
80
+ a = to_h.to_a
81
+ a2 = (a.length > 1 and x[-1][/i$/]) ? a[0..-2] : a
82
+ a2.map {|label, val| val.to_s + label[0]}.join(' ')
83
+
75
84
  end
76
85
 
77
- s.sub!('%X') do |x|
86
+ s.sub!(/%Xi?/) do |x|
87
+
88
+ a = to_h.to_a
89
+ a2 = (a.length > 1 and x[-1][/i$/]) ? a[0..-2] : a
78
90
 
79
- to_h.map do |label, val|
91
+ a2.map do |label, val|
80
92
 
81
93
  next if val == 0
82
94
  label2 = val > 1 ? label.to_s : label.to_s.sub(/s$/,'')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  HowcHg4GymtLLITCF/QtA5tta5SmHAca1POGncsO9QiramFQ9S3Q4O4wcjboVJOp
36
36
  SSxk4InmYoY9Cl2GVQ+d9owo
37
37
  -----END CERTIFICATE-----
38
- date: 2021-02-22 00:00:00.000000000 Z
38
+ date: 2021-04-07 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email: james@jamesrobertson.eu
metadata.gz.sig CHANGED
Binary file