gepub 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/lib/gepub/generator.rb +16 -14
  4. metadata +7 -7
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gem.authors = ["KOJIMA Satoshi"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_dependency('libxml-ruby', ">= 1.1.4")
15
- gem.add_dependency('zipruby', ">= 0.3.6")
15
+ gem.add_dependency('rubyzip', ">= 0.9.4")
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'rubygems'
3
3
  require 'xml/libxml'
4
- require 'zipruby'
4
+ require 'zip/zip'
5
5
  require 'fileutils'
6
6
 
7
7
 
@@ -90,29 +90,31 @@ module GEPUB
90
90
  create_toc(destdir)
91
91
  create_opf(destdir)
92
92
  end
93
-
93
+
94
94
  def create_epub(destdir, targetdir, epubname = @metadata[:title])
95
95
  realtarget = File::expand_path(targetdir)
96
- FileUtils.cd("#{destdir}") {
96
+ FileUtils.cd("#{destdir}") do
97
97
  |dir|
98
98
  epubname = "#{realtarget}/#{epubname}.epub"
99
+ File.delete(epubname) if File.exist?(epubname)
100
+
101
+ Zip::ZipOutputStream::open(epubname) {
102
+ |epub|
103
+ epub.put_next_entry('mimetype', '', '', Zip::ZipEntry::STORED)
104
+ epub << "application/epub+zip"
99
105
 
100
- Zip::Archive.open(epubname, Zip::CREATE | Zip::TRUNC, Zip::NO_COMPRESSION) do
101
- |epubfile|
102
- epubfile.add_buffer("mimetype", "application/epub+zip")
103
- # epubfile.add_file("mimetype")
104
- end
105
-
106
- Zip::Archive.open(epubname, Zip::CREATE, Zip::BEST_COMPRESSION) do
107
- |epubfile|
108
106
  Dir["**/*"].each do
109
107
  |f|
110
108
  if File.basename(f) != 'mimetype' && !File.directory?(f)
111
- epubfile.add_file(f,f)
109
+ File.open(f,'rb') do
110
+ |file|
111
+ epub.put_next_entry(f)
112
+ epub << file.read
113
+ end
112
114
  end
113
115
  end
114
- end
115
- }
116
+ }
117
+ end
116
118
  end
117
119
 
118
120
  def mimetype_contents
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 9
9
- version: 0.0.9
8
+ - 10
9
+ version: 0.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - KOJIMA Satoshi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-15 00:00:00 +09:00
17
+ date: 2010-06-16 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: zipruby
49
+ name: rubyzip
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  requirements:
@@ -54,9 +54,9 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  segments:
56
56
  - 0
57
- - 3
58
- - 6
59
- version: 0.3.6
57
+ - 9
58
+ - 4
59
+ version: 0.9.4
60
60
  type: :runtime
61
61
  version_requirements: *id003
62
62
  description: an easy-to-use (and easy-to-implement) EPUB generator.