repub 0.3.2 → 0.3.3
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.
- data/History.txt +25 -9
- data/README.rdoc +46 -40
- data/Rakefile +1 -0
- data/bin/repub +1 -1
- data/lib/repub.rb +1 -1
- data/lib/repub/app.rb +3 -3
- data/lib/repub/app/builder.rb +84 -36
- data/lib/repub/app/fetcher.rb +13 -11
- data/lib/repub/app/options.rb +36 -5
- data/lib/repub/app/parser.rb +1 -1
- data/lib/repub/app/profile.rb +16 -15
- data/lib/repub/epub/container.rb +28 -28
- data/lib/repub/epub/content.rb +59 -34
- data/lib/repub/epub/toc.rb +139 -139
- data/repub.gemspec +3 -3
- data/test/data/custom.css +3 -0
- data/test/data/invisiblellama.png +0 -0
- data/test/data/test.css +5 -0
- data/test/data/test.html +60 -0
- data/test/epub/test_container.rb +4 -4
- data/test/epub/test_content.rb +42 -38
- data/test/epub/test_toc.rb +19 -7
- data/test/test_builder.rb +145 -1
- data/test/test_fetcher.rb +79 -20
- data/test/test_parser.rb +45 -32
- metadata +6 -2
data/test/test_parser.rb
CHANGED
@@ -1,32 +1,45 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'repub'
|
3
|
-
require 'repub/app'
|
4
|
-
|
5
|
-
class TestParser < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include Repub::App::Fetcher
|
8
|
-
include Repub::App::Parser
|
9
|
-
attr_reader :options
|
10
|
-
|
11
|
-
def
|
12
|
-
@
|
13
|
-
|
14
|
-
:
|
15
|
-
# :
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'repub'
|
3
|
+
require 'repub/app'
|
4
|
+
|
5
|
+
class TestParser < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Repub::App::Fetcher
|
8
|
+
include Repub::App::Parser
|
9
|
+
attr_reader :options
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@url = 'file://' + File.expand_path(File.join(File.dirname(__FILE__), 'data/test.html'))
|
13
|
+
@options = {
|
14
|
+
:url => @url,
|
15
|
+
# NOTE: cannot test with wget because it doesn't support file:// schema
|
16
|
+
:helper => 'httrack',
|
17
|
+
:selectors => {
|
18
|
+
:title => '//h1',
|
19
|
+
:toc => '//ul',
|
20
|
+
:toc_item => './li',
|
21
|
+
:toc_section => './ul'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
Cache.cleanup
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
Cache.cleanup
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_parser
|
32
|
+
cache = fetch
|
33
|
+
parser = parse(cache)
|
34
|
+
assert_equal('8b8d358cf1ada41d4fee885a47530296528dc235', parser.uid)
|
35
|
+
assert_equal('Lorem Ipsum', parser.title)
|
36
|
+
assert_equal(3, parser.toc.size)
|
37
|
+
assert_equal('Chapter 1', parser.toc[0].title)
|
38
|
+
assert_equal('Chapter 3', parser.toc[2].title)
|
39
|
+
assert_equal(2, parser.toc[0].subitems.size)
|
40
|
+
assert_equal('Chapter 1.2', parser.toc[0].subitems[1].title)
|
41
|
+
assert_equal(cache.assets[:documents][0], parser.toc[0].subitems[1].uri)
|
42
|
+
assert_equal('c12', parser.toc[0].subitems[1].fragment_id)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitri Goutnik
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-05 00:00:00 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -110,6 +110,10 @@ files:
|
|
110
110
|
- tasks/svn.rake
|
111
111
|
- tasks/test.rake
|
112
112
|
- tasks/zentest.rake
|
113
|
+
- test/data/custom.css
|
114
|
+
- test/data/invisiblellama.png
|
115
|
+
- test/data/test.css
|
116
|
+
- test/data/test.html
|
113
117
|
- test/epub/test_container.rb
|
114
118
|
- test/epub/test_content.rb
|
115
119
|
- test/epub/test_toc.rb
|