sq 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: 8dc704917f0cdb8d045e5307a0962f84e5e4d8e8
4
- data.tar.gz: 7cd4146a0f2216b369c463f871c842689f0cdcb5
3
+ metadata.gz: 3c519a54a2ee72ba956685aa2e5452f03bfce0e3
4
+ data.tar.gz: 3c8b4709d73733bfc658ddde85a3ac79f76d59fc
5
5
  SHA512:
6
- metadata.gz: 595313fac368b5b7dd90dfd490e71b308f6e923086383e250b5d46b580cc52a20a02c1ebaf4dcb0f438f7582409fff7ea9a2e672ecd6ae03c78a72ed881701c6
7
- data.tar.gz: 8f7d036a2b02df7931543eef834e2f340672b12905b3d4cefd555e2ac67d8448e7fc32464b77bc0cc77d92d2e256494ef4ab4fc829ca222167591f3c66c9a7be
6
+ metadata.gz: b663c35c8905121c5e424b2bff1f1f2687a2afb256a1c424e06e3321f9afd711139614ae49e8f4b61c36c1dff776a4f68b0557c19438f9038d4f9c08f61604a4
7
+ data.tar.gz: e0206d2b13ce469f6410f02b64ef6523f58148985ec5e6cba96d0a93fcc2de6f5dc013e2327f221fde18df09ef5da21b55682b6fe7ba553c0193222d52574541
data/lib/sq.rb CHANGED
@@ -45,10 +45,14 @@ module SQ
45
45
  opts[:number] ||= 0
46
46
  opts[:count] ||= 0
47
47
 
48
+ padded_fmt = "%0#{Math.log(opts[:count], 10).ceil}d"
49
+
48
50
  fmt.gsub(/%./) do |f|
49
51
  case f
50
52
  when '%n' then opts[:number]
51
53
  when '%N' then opts[:number]+1
54
+ when '%z' then padded_fmt % opts[:number]
55
+ when '%Z' then padded_fmt % (opts[:number]+1)
52
56
  when '%c' then opts[:count]
53
57
  when '%s' then doc[:name].sub(/\.pdf$/i, '')
54
58
  when '%S' then doc[:text]
@@ -3,7 +3,7 @@
3
3
  module SQ
4
4
  class << self
5
5
  def version
6
- '0.1.1'
6
+ '0.1.2'
7
7
  end
8
8
  end
9
9
  end
@@ -28,6 +28,14 @@ class SQ_format_test < Test::Unit::TestCase
28
28
  assert_equal('1', SQ.format(@foo, '%N', @opts))
29
29
  end
30
30
 
31
+ def test_format_pdf_padded_number0
32
+ assert_equal('00', SQ.format(@foo, '%z', @opts))
33
+ end
34
+
35
+ def test_format_pdf_padded_number1
36
+ assert_equal('01', SQ.format(@foo, '%Z', @opts))
37
+ end
38
+
31
39
  def test_format_pdf_count
32
40
  assert_equal('42', SQ.format(@foo, '%c', @opts))
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Baptiste Fontaine