eeepub 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/eeepub/maker.rb +15 -2
- data/spec/eeepub/maker_spec.rb +49 -0
- metadata +10 -7
- data/TODO +0 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/eeepub/maker.rb
CHANGED
@@ -75,7 +75,13 @@ module EeePub
|
|
75
75
|
def save(filename)
|
76
76
|
Dir.mktmpdir do |dir|
|
77
77
|
@files.each do |file|
|
78
|
-
|
78
|
+
case file
|
79
|
+
when String
|
80
|
+
FileUtils.cp(file, dir)
|
81
|
+
when Hash
|
82
|
+
FileUtils.mkdir_p(File.join(dir, file[:dir])) if file[:dir]
|
83
|
+
FileUtils.cp(file[:path], File.join(dir, (file[:dir] || '')))
|
84
|
+
end
|
79
85
|
end
|
80
86
|
|
81
87
|
NCX.new(
|
@@ -95,7 +101,14 @@ module EeePub
|
|
95
101
|
:description => @descriptions,
|
96
102
|
:rights => @rightss,
|
97
103
|
:relation => @relations,
|
98
|
-
:manifest => @files.map{|
|
104
|
+
:manifest => @files.map{|file|
|
105
|
+
case file
|
106
|
+
when String
|
107
|
+
File.basename(file)
|
108
|
+
when Hash
|
109
|
+
file[:dir] ? File.join(file[:dir], File.basename(file[:path])) : File.basename(file[:path])
|
110
|
+
end
|
111
|
+
},
|
99
112
|
:ncx => @ncx_file
|
100
113
|
).save(File.join(dir, @opf_file))
|
101
114
|
|
data/spec/eeepub/maker_spec.rb
CHANGED
@@ -72,4 +72,53 @@ describe "EeePub::Maker" do
|
|
72
72
|
|
73
73
|
@maker.save('test.epub')
|
74
74
|
end
|
75
|
+
|
76
|
+
describe "files as hash" do
|
77
|
+
before do
|
78
|
+
@maker = EeePub::Maker.new do
|
79
|
+
title 'sample'
|
80
|
+
creator 'jugyo'
|
81
|
+
publisher 'jugyo.org'
|
82
|
+
date "2010-05-06"
|
83
|
+
language 'en'
|
84
|
+
subject 'epub sample'
|
85
|
+
description 'this is epub sample'
|
86
|
+
rights 'xxx'
|
87
|
+
relation 'xxx'
|
88
|
+
identifier 'http://example.com/book/foo', :scheme => 'URL'
|
89
|
+
uid 'http://example.com/book/foo'
|
90
|
+
ncx_file 'toc.ncx'
|
91
|
+
opf_file 'content.opf'
|
92
|
+
files [{:dir => 'foo', :path => 'foo.html'}, {:dir => 'bar', :path => 'bar.html'}]
|
93
|
+
nav [
|
94
|
+
{:label => '1. foo', :content => 'foo.html'},
|
95
|
+
{:label => '1. bar', :content => 'bar.html'}
|
96
|
+
]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should save' do
|
101
|
+
stub(FileUtils).cp.with_any_args
|
102
|
+
stub(FileUtils).mkdir_p.with_any_args
|
103
|
+
mock(Dir).mktmpdir {|i| i.call('/tmp')}
|
104
|
+
mock(EeePub::NCX).new.with_any_args { stub!.save }
|
105
|
+
mock(EeePub::OPF).new(
|
106
|
+
:title => ["sample"],
|
107
|
+
:creator => ["jugyo"],
|
108
|
+
:date => ["2010-05-06"],
|
109
|
+
:language => ['en'],
|
110
|
+
:subject => ['epub sample'],
|
111
|
+
:description => ['this is epub sample'],
|
112
|
+
:rights => ['xxx'],
|
113
|
+
:relation => ['xxx'],
|
114
|
+
:ncx => "toc.ncx",
|
115
|
+
:publisher => ["jugyo.org"],
|
116
|
+
:identifier => [{:value => "http://example.com/book/foo", :scheme => "URL"}],
|
117
|
+
:manifest => ["foo/foo.html", "bar/bar.html"]
|
118
|
+
) { stub!.save }
|
119
|
+
mock(EeePub::OCF).new.with_any_args { stub!.save }
|
120
|
+
|
121
|
+
@maker.save('test.epub')
|
122
|
+
end
|
123
|
+
end
|
75
124
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- jugyo
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-23 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: builder
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -33,6 +34,7 @@ dependencies:
|
|
33
34
|
name: rspec
|
34
35
|
prerelease: false
|
35
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
36
38
|
requirements:
|
37
39
|
- - ">="
|
38
40
|
- !ruby/object:Gem::Version
|
@@ -45,6 +47,7 @@ dependencies:
|
|
45
47
|
name: rr
|
46
48
|
prerelease: false
|
47
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
48
51
|
requirements:
|
49
52
|
- - ">="
|
50
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +65,6 @@ extensions: []
|
|
62
65
|
extra_rdoc_files:
|
63
66
|
- LICENSE
|
64
67
|
- README.md
|
65
|
-
- TODO
|
66
68
|
files:
|
67
69
|
- .gitignore
|
68
70
|
- LICENSE
|
@@ -86,7 +88,6 @@ files:
|
|
86
88
|
- spec/eeepub/opf_spec.rb
|
87
89
|
- spec/eeepub_spec.rb
|
88
90
|
- spec/spec_helper.rb
|
89
|
-
- TODO
|
90
91
|
has_rdoc: true
|
91
92
|
homepage: http://github.com/jugyo/eeepub
|
92
93
|
licenses: []
|
@@ -97,6 +98,7 @@ rdoc_options:
|
|
97
98
|
require_paths:
|
98
99
|
- lib
|
99
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
100
102
|
requirements:
|
101
103
|
- - ">="
|
102
104
|
- !ruby/object:Gem::Version
|
@@ -104,6 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
106
|
- 0
|
105
107
|
version: "0"
|
106
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
107
110
|
requirements:
|
108
111
|
- - ">="
|
109
112
|
- !ruby/object:Gem::Version
|
@@ -113,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
116
|
requirements: []
|
114
117
|
|
115
118
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.3.
|
119
|
+
rubygems_version: 1.3.7
|
117
120
|
signing_key:
|
118
121
|
specification_version: 3
|
119
122
|
summary: ePub generator
|