sq 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sq.rb +4 -0
- data/lib/version.rb +1 -1
- data/tests/format_tests.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c519a54a2ee72ba956685aa2e5452f03bfce0e3
|
4
|
+
data.tar.gz: 3c8b4709d73733bfc658ddde85a3ac79f76d59fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]
|
data/lib/version.rb
CHANGED
data/tests/format_tests.rb
CHANGED
@@ -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
|