invisiblellama-repub 0.2.1

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.
File without changes
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ require 'repub/epub'
5
+
6
+ class TestContainer < Test::Unit::TestCase
7
+ def test_container_create
8
+ c = Repub::Epub::Container.new
9
+ s = c.to_xml
10
+ doc = Hpricot(s)
11
+ #puts s
12
+
13
+ assert_not_nil(doc.search('rootfile'))
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ require 'repub/epub'
5
+
6
+ class TestContent < Test::Unit::TestCase
7
+ def test_manifest_create
8
+ x = Repub::Epub::Content.new('some-name')
9
+ s = x.to_xml
10
+ #puts s
11
+ doc = Hpricot(s)
12
+
13
+ # manifest was created
14
+ assert_not_nil(doc.search('manifest'))
15
+ # has exactly one item
16
+ assert_equal(1, doc.search('manifest/item').size)
17
+ # and item is ncx
18
+ assert_equal('ncx', doc.search('manifest/item')[0][:id])
19
+ # spine was created
20
+ assert_not_nil(doc.search('spine'))
21
+ # and is empty
22
+ assert_equal(0, doc.search('spine/item').size)
23
+ end
24
+
25
+ def test_manifest
26
+ x = Repub::Epub::Content.new('some-name')
27
+ x.add_page_template
28
+ x.add_stylesheet 'style.css'
29
+ x.add_stylesheet 'more-style.css'
30
+ x.add_image ' logo.jpg '
31
+ x.add_image ' image.png'
32
+ x.add_image 'picture.jpeg '
33
+ x.add_document 'intro.html', 'intro'
34
+ x.add_document 'chapter-1.html'
35
+ x.add_document 'glossary.html', 'glossary'
36
+ s = x.to_xml
37
+ #puts s
38
+ doc = Hpricot(s)
39
+
40
+ # manifest was created
41
+ assert_not_nil(doc.search('manifest'))
42
+ # has 2 stylesheets
43
+ assert_equal(2, doc.search('manifest/item[@media-type = "text/css"]').size)
44
+ # and 2 jpegs
45
+ assert_equal(2, doc.search('manifest/item[@media-type = "image/jpeg"]').size)
46
+ # and 1 png
47
+ assert_equal(1, doc.search('manifest/item[@media-type = "image/png"]').size)
48
+ # spine was created
49
+ assert_not_nil(doc.search('spine'))
50
+ # and has 3 html items
51
+ assert_equal(3, doc.search('spine/itemref').size)
52
+ # check that order is as inserted and ids are correct
53
+ assert_equal('intro', doc.search('spine/itemref')[0]['idref'])
54
+ assert_equal('glossary', doc.search('spine/itemref')[2]['idref'])
55
+ end
56
+ end
@@ -0,0 +1,29 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ require 'repub/epub'
5
+
6
+ class TestToc < Test::Unit::TestCase
7
+ def test_toc_create
8
+ x = Repub::Epub::Toc.new('some-name')
9
+ s = x.to_xml
10
+ #puts s
11
+ doc = Hpricot(s)
12
+ # TODO
13
+ end
14
+
15
+ def test_toc
16
+ x = Repub::Epub::Toc.new('some-name')
17
+ p0 = x.nav_map.add_nav_point('Intro', 'intro.html')
18
+ p1 = x.nav_map.add_nav_point('Chapter 1', 'chapter-1.html')
19
+ p2 = x.nav_map.add_nav_point('Chapter 2', 'chapter-2.html')
20
+ p21 = p2.add_nav_point('Chapter 2-1', 'chapter-2-1.html')
21
+ pg = x.nav_map.add_nav_point('Glossary', 'glossary.html')
22
+ p11 = p1.add_nav_point('Chapter 1-1', 'chapter-1-1.html')
23
+ p12 = p1.add_nav_point('Chapter 1-2', 'chapter-1-2.html')
24
+ s = x.to_xml
25
+ #puts s
26
+ doc = Hpricot(s)
27
+ # TODO
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+ require 'repub'
3
+
4
+ class TestBuilder < Test::Unit::TestCase
5
+ def test_builder
6
+ flunk("todo")
7
+ end
8
+ end
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ require 'repub'
3
+ require 'repub/app'
4
+
5
+ class TestFetcher < Test::Unit::TestCase
6
+
7
+ include Repub::App::Fetcher
8
+ attr_reader :options
9
+
10
+ def test_fetcher
11
+ @options = {
12
+ :url => 'http://www.berzinarchives.com/web/x/prn/p.html_1614431902.html',
13
+ :helper => 'wget'
14
+ }
15
+ assert_nothing_raised do
16
+ cache = fetch
17
+ #p cache
18
+ assert_equal('http://www.berzinarchives.com/web/x/prn/p.html_1614431902.html', cache.url)
19
+ assert(cache.path.include?('.repub/cache/f963050ead9ee7775a4155e13743d47bc851d5d8'))
20
+ assert_equal('f963050ead9ee7775a4155e13743d47bc851d5d8', cache.name)
21
+ # assert(File.exist?(File.join(f.asset_root, f.asset_name)), "Fetch failed.")
22
+ end
23
+ end
24
+
25
+ def test_fetcher_fail
26
+ @options = {
27
+ :url => 'not-existing',
28
+ :helper => 'wget'
29
+ }
30
+ assert_raise(Repub::App::FetcherException) do
31
+ cache = fetch
32
+ #p cache
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,76 @@
1
+ require 'delegate'
2
+ require 'test/unit'
3
+ require 'repub'
4
+ require 'repub/app'
5
+
6
+ class TestRepub < Test::Unit::TestCase
7
+ include Repub::App::Logger
8
+
9
+ class FakeStringStream < DelegateClass(String)
10
+ def initialize
11
+ @str = String.new
12
+ super(@str)
13
+ end
14
+ def puts(value)
15
+ @str << value.to_s
16
+ end
17
+ def changed
18
+ klone = self.clone
19
+ yield
20
+ klone.to_s != self.to_s
21
+ end
22
+ end
23
+
24
+ def setup
25
+ log.level = LOGGER_NORMAL
26
+ log.stdout = @out = FakeStringStream.new
27
+ log.stderr = @err = FakeStringStream.new
28
+ end
29
+
30
+ def assert_out(&blk); assert @out.changed(&blk); end
31
+ def assert_no_out(&blk); assert !@out.changed(&blk); end
32
+ def assert_err(&blk); assert @err.changed(&blk); end
33
+ def assert_no_err(&blk); assert !@err.changed(&blk); end
34
+
35
+ def test_create
36
+ assert_not_nil(log)
37
+ end
38
+
39
+ def test_streams
40
+ log.info "info"
41
+ log.info "more info"
42
+ assert_equal('infomore info', @out)
43
+ log.error "error message"
44
+ assert_equal('error message', @err)
45
+ end
46
+
47
+ def test_verbose_level
48
+ log.level = LOGGER_VERBOSE
49
+ assert_out { log.debug "debug" }
50
+ assert_out { log.info "info" }
51
+ assert_err { log.error "error" }
52
+ end
53
+
54
+ def test_normal_level
55
+ log.level = LOGGER_NORMAL
56
+ assert_no_out { log.debug "debug" }
57
+ assert_out { log.info "info" }
58
+ assert_err { log.error "error" }
59
+ end
60
+
61
+ def test_quiet_level
62
+ log.level = LOGGER_QUIET
63
+ assert_no_out { log.debug "debug" }
64
+ assert_no_out { log.info "info" }
65
+ assert_err { log.error "error" }
66
+ end
67
+
68
+ def test_fatal
69
+ log.level = LOGGER_QUIET
70
+ assert_raise(SystemExit) { log.fatal "fatal" }
71
+ begin
72
+ assert_err { log.fatal "bye" }
73
+ rescue SystemExit
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,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 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
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: invisiblellama-repub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Dmitri Goutnik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-26 00:00:00 -07:00
13
+ default_executable: repub
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: builder
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hpricot
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: chardet
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: launchy
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.3
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: bones
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.5.1
64
+ version:
65
+ description: RePub is a simple HTML to ePub converter.
66
+ email: dg@invisiblellama.net
67
+ executables:
68
+ - repub
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - History.txt
73
+ - README.txt
74
+ - TODO.txt
75
+ - bin/repub
76
+ - lib/repub/mobi/.githidden
77
+ files:
78
+ - .gitignore
79
+ - History.txt
80
+ - README.txt
81
+ - Rakefile
82
+ - TODO.txt
83
+ - bin/repub
84
+ - lib/repub.rb
85
+ - lib/repub/app.rb
86
+ - lib/repub/app/builder.rb
87
+ - lib/repub/app/fetcher.rb
88
+ - lib/repub/app/logger.rb
89
+ - lib/repub/app/options.rb
90
+ - lib/repub/app/parser.rb
91
+ - lib/repub/app/profile.rb
92
+ - lib/repub/app/utility.rb
93
+ - lib/repub/epub.rb
94
+ - lib/repub/epub/container.rb
95
+ - lib/repub/epub/content.rb
96
+ - lib/repub/epub/toc.rb
97
+ - lib/repub/mobi/.githidden
98
+ - test/epub/test_container.rb
99
+ - test/epub/test_content.rb
100
+ - test/epub/test_toc.rb
101
+ - test/test_builder.rb
102
+ - test/test_fetcher.rb
103
+ - test/test_logger.rb
104
+ - test/test_parser.rb
105
+ has_rdoc: false
106
+ homepage: http://github.com/invisiblellama/repub/tree/master
107
+ post_install_message:
108
+ rdoc_options:
109
+ - --main
110
+ - README.txt
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ version:
125
+ requirements: []
126
+
127
+ rubyforge_project: repub
128
+ rubygems_version: 1.2.0
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: RePub is a simple HTML to ePub converter
132
+ test_files:
133
+ - test/epub/test_container.rb
134
+ - test/epub/test_content.rb
135
+ - test/epub/test_toc.rb
136
+ - test/test_builder.rb
137
+ - test/test_fetcher.rb
138
+ - test/test_logger.rb
139
+ - test/test_parser.rb