invisiblellama-repub 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
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 test_parser
12
- @options = {
13
- :url => 'http://www.berzinarchives.com/web/x/prn/p.html_1614431902.html',
14
- :helper => 'wget'
15
- # :selectors => {
16
- # :title => '//h1',
17
- # :toc => '//div.toc/ul',
18
- # :toc_item => '/li',
19
- # :toc_section => '/ul'
20
- # }
21
- }
22
- parser = parse(fetch)
23
- assert_equal('f963050ead9ee7775a4155e13743d47bc851d5d8', parser.uid)
24
- puts "UID: #{parser.uid}"
25
- assert_equal('A Survey of Tibetan History', parser.title)
26
- puts "Title: #{parser.title}"
27
- #puts parser.toc
28
- assert_equal(4, parser.toc.size)
29
- puts "TOC: (#{parser.toc.size} items)"
30
- end
31
-
32
- end
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: invisiblellama-repub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
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-06-30 00:00:00 -07:00
12
+ date: 2009-07-05 00:00:00 -07:00
13
13
  default_executable: repub
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,10 @@ files:
92
92
  - lib/repub/epub/content.rb
93
93
  - lib/repub/epub/toc.rb
94
94
  - repub.gemspec
95
+ - test/data/custom.css
96
+ - test/data/invisiblellama.png
97
+ - test/data/test.css
98
+ - test/data/test.html
95
99
  - test/epub/test_container.rb
96
100
  - test/epub/test_content.rb
97
101
  - test/epub/test_toc.rb