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 ADDED
@@ -0,0 +1,12 @@
1
+ = DjVu-Tools ChangeLog
2
+
3
+ == 0.1.0
4
+
5
+ === Enhancements
6
+
7
+ * Page numbering can now be specified with a spacing (delta) between numbers.
8
+ * Added changelog.
9
+
10
+ == 0.0.1
11
+
12
+ === Initial release
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
- number = section[:start] + i
21
- number =
22
- case section[:type]
23
- when :arabic
24
- number.to_s
25
- when :upper_roman
26
- RomanNumerals::to_roman(number).upcase
27
- when :lower_roman
28
- RomanNumerals::to_roman(number).downcase
29
- end
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
@@ -1,4 +1,4 @@
1
1
  class DjVuTools
2
2
  # Version number.
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
@@ -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.1
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: &5110660 !ruby/object:Gem::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: *5110660
24
+ version_requirements: *5115460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: which
27
- requirement: &5110100 !ruby/object:Gem::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: *5110100
35
+ version_requirements: *5115000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &6112020 !ruby/object:Gem::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: *6112020
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