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.
@@ -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: 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 +04:00
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