epzip 0.6.0

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Masayoshi Takahashi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = epzip
2
+
3
+ epzip is EPUB packing tool. It's just only do 'zip.'
4
+
5
+ == usage
6
+
7
+ $ epzip <somedir as EPUB sources>
8
+
9
+ == Note on Patches/Pull Requests
10
+
11
+ * Fork the project.
12
+ * Make your feature addition or bug fix.
13
+ * Add tests for it. This is important so I don't break it in a
14
+ future version unintentionally.
15
+ * Commit, do not mess with rakefile, version, or history.
16
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
17
+ * Send me a pull request. Bonus points for topic branches.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2010 Masayoshi Takahashi. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "epzip"
8
+ gem.summary = %Q{simple EPUB packing tool}
9
+ gem.description = %Q{epzip is EPUB packing tool. It's just only to do 'zip.'}
10
+ gem.email = "takahashimm@gmail.com"
11
+ gem.homepage = "http://github.com/takahashim/epzip"
12
+ gem.authors = ["Masayoshi Takahashi"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "epzip #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.0
data/bin/epzip ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'rubygems'
5
+ require 'epzip'
6
+
7
+ def error_and_exit(msg)
8
+ STDERR.puts msg
9
+ exit
10
+ end
11
+
12
+ def usage()
13
+ error_and_exit "usage: epzip <EPUB source dir>"
14
+ end
15
+
16
+ if !(ARGV.size == 1 or ARGV.size == 2)
17
+ usage
18
+ end
19
+
20
+ dir = ARGV.shift
21
+ if !File.exists? dir
22
+ error "No such directory: #{dir}"
23
+ end
24
+
25
+ file = ARGV.shift
26
+ if file and File.exists? file
27
+ error "File already exists: #{file}"
28
+ end
29
+
30
+ Epzip.zip(dir, file)
data/epzip.gemspec ADDED
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{epzip}
8
+ s.version = "0.6.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Masayoshi Takahashi"]
12
+ s.date = %q{2010-07-16}
13
+ s.default_executable = %q{epzip}
14
+ s.description = %q{epzip is EPUB packing tool. It's just only to do 'zip.'}
15
+ s.email = %q{takahashimm@gmail.com}
16
+ s.executables = ["epzip"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/epzip",
29
+ "epzip.gemspec",
30
+ "lib/epzip.rb",
31
+ "test/helper.rb",
32
+ "test/test_epzip.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/takahashim/epzip}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.6}
38
+ s.summary = %q{simple EPUB packing tool}
39
+ s.test_files = [
40
+ "test/helper.rb",
41
+ "test/test_epzip.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
54
+
data/lib/epzip.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'zip/zip'
3
+
4
+ class Epzip
5
+ MIMETYPE_FILENAME = 'mimetype'
6
+
7
+ def self.zip(epubdir, epubfile = nil)
8
+ if !File.exists? epubdir
9
+ raise ArgumentError, "No such directory -- #{epubdir}"
10
+ end
11
+
12
+ epubfile ||= epubdir+".epub"
13
+
14
+ Zip::ZipOutputStream.open(epubfile) do |f|
15
+
16
+ f.put_next_entry(MIMETYPE_FILENAME, nil, nil, Zip::ZipEntry::STORED)
17
+ f << "application/epub+zip"
18
+ puts MIMETYPE_FILENAME
19
+
20
+ Dir.chdir(epubdir) do
21
+ Dir.glob("**/*") do |dir|
22
+ next if dir == MIMETYPE_FILENAME
23
+ next if !File.file? dir
24
+ puts dir
25
+ f.put_next_entry dir
26
+ f << File.read(dir)
27
+ end
28
+ end
29
+ end
30
+
31
+ epubfile
32
+
33
+ end
34
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require 'epzip'
7
+
8
+ class Test::Unit::TestCase
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ class TestEpzip < Test::Unit::TestCase
4
+ def test_zip_should_use_existed_dir
5
+ assert_raise ArgumentError do
6
+ Epzip.zip("unknown_dir")
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: epzip
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
10
+ platform: ruby
11
+ authors:
12
+ - Masayoshi Takahashi
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-16 00:00:00 +09:00
18
+ default_executable: epzip
19
+ dependencies: []
20
+
21
+ description: epzip is EPUB packing tool. It's just only to do 'zip.'
22
+ email: takahashimm@gmail.com
23
+ executables:
24
+ - epzip
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.rdoc
30
+ files:
31
+ - .document
32
+ - .gitignore
33
+ - LICENSE
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION
37
+ - bin/epzip
38
+ - epzip.gemspec
39
+ - lib/epzip.rb
40
+ - test/helper.rb
41
+ - test/test_epzip.rb
42
+ has_rdoc: true
43
+ homepage: http://github.com/takahashim/epzip
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.6
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: simple EPUB packing tool
72
+ test_files:
73
+ - test/helper.rb
74
+ - test/test_epzip.rb