djvu-tools 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +12 -0
- data/README.rdoc +4 -0
- data/lib/djvu-tools/djvu-numberer.rb +12 -10
- data/lib/djvu-tools/version.rb +1 -1
- data/spec/djvu_numberer_spec.rb +8 -0
- metadata +8 -7
data/CHANGELOG.rdoc
ADDED
data/README.rdoc
CHANGED
@@ -48,6 +48,10 @@ Then create sections to title or number:
|
|
48
48
|
|
49
49
|
djvu.add_section( { start: 1, range: (21..500), type: :arabic } )
|
50
50
|
|
51
|
+
* A range of pages with Arabic numerals starting with 1 and spaced 2 apart:
|
52
|
+
|
53
|
+
djvu.add_section( { start: 1, range: (21..500), type: :arabic, delta: 2 } )
|
54
|
+
|
51
55
|
Finally, you must run djvused and write to the file with
|
52
56
|
|
53
57
|
djvu.run
|
@@ -12,21 +12,23 @@ class DjVuNumberer < DjVuTools
|
|
12
12
|
# @see file:README.rdoc The Numberer section in the README
|
13
13
|
def add_section section
|
14
14
|
|
15
|
+
section[:delta] ||= 1
|
16
|
+
|
15
17
|
if section[:start].nil?
|
16
18
|
raise ArgumentError, 'Cannot label a range of pages with the same title' if ( section[:range].max - section[:range].min > 0 )
|
17
19
|
section[:range].each { |n| @djvu.title_page n, section[:title] }
|
18
20
|
else
|
19
21
|
section[:range].each_with_index do |n, i|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
number = section[:start] + i * section[:delta].to_i
|
23
|
+
number =
|
24
|
+
case section[:type]
|
25
|
+
when :arabic
|
26
|
+
number.to_s
|
27
|
+
when :upper_roman
|
28
|
+
RomanNumerals::to_roman(number).upcase
|
29
|
+
when :lower_roman
|
30
|
+
RomanNumerals::to_roman(number).downcase
|
31
|
+
end
|
30
32
|
@djvu.title_page n, "#{number}"
|
31
33
|
end
|
32
34
|
end
|
data/lib/djvu-tools/version.rb
CHANGED
data/spec/djvu_numberer_spec.rb
CHANGED
@@ -29,6 +29,14 @@ describe DjVuNumberer do
|
|
29
29
|
@numberer.add_section section
|
30
30
|
end
|
31
31
|
|
32
|
+
it "titles a range of pages with delta spacing" do
|
33
|
+
section = { start: 42, range: (10..20), type: :arabic, delta: 3 }
|
34
|
+
section[:range].each_with_index do |n, i|
|
35
|
+
@numberer.instance_eval{ @djvu }.should_receive(:title_page).with(n, "#{section[:start] + i * section[:delta]}")
|
36
|
+
end
|
37
|
+
@numberer.add_section section
|
38
|
+
end
|
39
|
+
|
32
40
|
it "titles a range of pages with uppercase roman numerals" do
|
33
41
|
section = { start: 3, range: (10..11), type: :upper_roman }
|
34
42
|
@numberer.instance_eval{ @djvu }.should_receive(:title_page).with(10, "III")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djvu-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: roman-numerals
|
16
|
-
requirement: &
|
16
|
+
requirement: &5115460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *5115460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: which
|
27
|
-
requirement: &
|
27
|
+
requirement: &5115000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *5115000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &5114560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *5114560
|
47
47
|
description: Ruby toolbox for manipulating DjVu files.
|
48
48
|
email:
|
49
49
|
- razorx@evansosenko.com
|
@@ -52,6 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
|
+
- CHANGELOG.rdoc
|
55
56
|
- Gemfile
|
56
57
|
- LICENSE.txt
|
57
58
|
- README.rdoc
|