kindlegen 2.9.7 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -8
- data/.travis.yml +3 -2
- data/Gemfile +0 -4
- data/exe/kindlegen +3 -0
- data/ext/Rakefile +93 -0
- data/kindlegen.gemspec +6 -2
- data/lib/kindlegen.rb +9 -3
- data/lib/kindlegen/version.rb +1 -1
- data/test/test_kindlegen.rb +2 -2
- metadata +37 -7
- data/ext/kindlegen/extconf.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707247f6d1da7fa52714d305fd849a225bdc92cf
|
4
|
+
data.tar.gz: 220020653144f8108fa9e058d1ea5cf1bdff6348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b9a3f0705c9610f45e80a9dfdb15064c8770e54ed90af6bc3d207710629ddae4e860d44b765dce28112acedee5924cc1edb9819fc55ab831f7431865490f13
|
7
|
+
data.tar.gz: e6058f96cce126fb65c3378e899bb5ffc0269a5a4ddea4e11c22e184bb38c77f819303b7f698a1b0e7e8d41ee74449f6c09c4bb97d801fe8806f16b27c69f190
|
data/.gitignore
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
*.gem
|
2
2
|
*.swp
|
3
|
-
/pkg
|
3
|
+
/pkg
|
4
4
|
/.bundle
|
5
5
|
/vendor/bundle
|
6
6
|
/Gemfile.lock
|
7
7
|
/.ruby-version
|
8
8
|
/.ruby-gemset
|
9
|
+
ext/*
|
10
|
+
!ext/Rakefile
|
11
|
+
bin/
|
9
12
|
*.tar.gz
|
10
|
-
|
11
|
-
ext/kindlegen/Kindle*
|
12
|
-
ext/kindlegen/Sample*
|
13
|
-
ext/kindlegen/Multimedia*
|
14
|
-
ext/kindlegen/Readme*
|
15
|
-
ext/kindlegen/Release*
|
16
|
-
ext/kindlegen/kindlegen
|
13
|
+
*.zip
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/exe/kindlegen
ADDED
data/ext/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Rakefile to install kindlegen
|
3
|
+
# (c) Copryright Toshihiko Ichida 2016
|
4
|
+
#
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
AMAZON = 'http://kindlegen.s3.amazonaws.com'
|
9
|
+
BINDIR = '../bin'
|
10
|
+
|
11
|
+
def create_default_task(target)
|
12
|
+
task :default => :install
|
13
|
+
|
14
|
+
task :install => target do |t|
|
15
|
+
mkdir BINDIR unless File.exist?(BINDIR)
|
16
|
+
cp t.source, BINDIR
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_task_for_unix(config)
|
21
|
+
tarball = config[:tarball]
|
22
|
+
unzip = config[:unzip]
|
23
|
+
target = config[:target]
|
24
|
+
url = "#{AMAZON}/#{tarball}"
|
25
|
+
|
26
|
+
create_default_task(target)
|
27
|
+
|
28
|
+
file target => tarball do
|
29
|
+
sh "#{unzip} #{tarball}"
|
30
|
+
sh "chmod +x #{target}"
|
31
|
+
end
|
32
|
+
|
33
|
+
file tarball do
|
34
|
+
sh "curl #{url} -o #{tarball}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# curl for windows
|
39
|
+
def curl(url, tarball)
|
40
|
+
puts "open(#{url})"
|
41
|
+
puts "save to #{tarball}"
|
42
|
+
data = open(url, 'rb').read
|
43
|
+
open(tarball, 'wb').write(data)
|
44
|
+
end
|
45
|
+
|
46
|
+
# unzip for windows
|
47
|
+
def unzip(tarball)
|
48
|
+
puts "win-unzip #{tarball}"
|
49
|
+
Zip::File.open(tarball).each do |entry|
|
50
|
+
dir = File.dirname(entry.name)
|
51
|
+
FileUtils.mkpath(dir) if dir != '.' && !File.exist?(dir)
|
52
|
+
entry.extract unless File.exist?(entry.name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_task_for_windows(config)
|
57
|
+
require 'open-uri'
|
58
|
+
require 'zip'
|
59
|
+
|
60
|
+
tarball = config[:tarball]
|
61
|
+
target = config[:target]
|
62
|
+
url = "#{AMAZON}/#{tarball}"
|
63
|
+
|
64
|
+
create_default_task(target)
|
65
|
+
|
66
|
+
file target => tarball do
|
67
|
+
unzip(tarball)
|
68
|
+
end
|
69
|
+
|
70
|
+
file tarball do
|
71
|
+
curl(url, tarball)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
case RbConfig::CONFIG['host_os']
|
76
|
+
when /mac|darwin/i
|
77
|
+
create_task_for_unix(
|
78
|
+
{ tarball: 'KindleGen_Mac_i386_v2_9.zip',
|
79
|
+
unzip: 'unzip',
|
80
|
+
target: 'kindlgen' })
|
81
|
+
when /linux|cygwin/i
|
82
|
+
create_task_for_unix(
|
83
|
+
{ tarball: 'kindlegen_linux_2.6_i386_v2_9.tar.gz',
|
84
|
+
unzip: 'tar -zx --no-same-owner -f',
|
85
|
+
target: 'kindlegen' })
|
86
|
+
when /mingw32|mswin32/i
|
87
|
+
create_task_for_windows(
|
88
|
+
{ tarball: 'kindlegen_win32_v2_9.zip',
|
89
|
+
target: 'kindlegen.exe' })
|
90
|
+
else
|
91
|
+
STDERR.puts "Host OS unsupported!"
|
92
|
+
exit(1)
|
93
|
+
end
|
data/kindlegen.gemspec
CHANGED
@@ -17,11 +17,15 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
-
s.
|
20
|
+
s.bindir = 'exe'
|
21
|
+
s.executables = s.files.grep(%r{^exe/}){|f| File.basename(f)}
|
21
22
|
s.require_paths = ["lib"]
|
22
|
-
s.extensions
|
23
|
+
s.extensions = ['ext/Rakefile']
|
24
|
+
|
25
|
+
s.add_dependency 'rubyzip'
|
23
26
|
|
24
27
|
# specify any dependencies here; for example:
|
28
|
+
s.add_development_dependency "rake"
|
25
29
|
s.add_development_dependency "pry"
|
26
30
|
s.add_development_dependency "test-unit"
|
27
31
|
end
|
data/lib/kindlegen.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "kindlegen/version"
|
2
2
|
require 'pathname'
|
3
|
+
require 'rbconfig'
|
3
4
|
require 'open3'
|
4
5
|
|
5
6
|
module Kindlegen
|
@@ -19,9 +20,10 @@ module Kindlegen
|
|
19
20
|
# _params_:: array of command parameters.
|
20
21
|
#
|
21
22
|
def self.run( *params )
|
22
|
-
clean_env do
|
23
|
-
|
24
|
-
|
23
|
+
clean_env{Open3.capture3(command.to_s, *params)}.map do |r|
|
24
|
+
r.force_encoding('UTF-8') if windows? && r.respond_to?(:force_encoding)
|
25
|
+
r
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
@@ -32,4 +34,8 @@ private
|
|
32
34
|
ENV.replace(env_backup)
|
33
35
|
return ret
|
34
36
|
end
|
37
|
+
|
38
|
+
def self.windows?
|
39
|
+
RbConfig::CONFIG['host_os'] =~ /mingw32|mswin32/i
|
40
|
+
end
|
35
41
|
end
|
data/lib/kindlegen/version.rb
CHANGED
data/test/test_kindlegen.rb
CHANGED
@@ -9,7 +9,7 @@ class KindlegenTest < Test::Unit::TestCase
|
|
9
9
|
kindlegen_lib_dir = nil
|
10
10
|
gem_version = File.read(File.join(KINDLEGEN_PROJECT_DIR, 'lib/kindlegen/version.rb')).match(/VERSION = ["'](.*?)["']/)[1]
|
11
11
|
gem_file = File.join(KINDLEGEN_PROJECT_DIR, 'pkg', %(kindlegen-#{gem_version}.gem))
|
12
|
-
|
12
|
+
result = Gem::Installer.at(gem_file).install rescue Gem::Installer.new(gem_file).install
|
13
13
|
begin
|
14
14
|
require 'kindlegen'
|
15
15
|
rescue ::LoadError
|
@@ -21,7 +21,7 @@ class KindlegenTest < Test::Unit::TestCase
|
|
21
21
|
output = %x(#{Kindlegen.command})
|
22
22
|
assert output.include?('Amazon')
|
23
23
|
ensure
|
24
|
-
Gem::Uninstaller.new('kindlegen', :
|
24
|
+
Gem::Uninstaller.new('kindlegen', :executables => true).uninstall rescue nil
|
25
25
|
$:.delete kindlegen_lib_dir if kindlegen_lib_dir
|
26
26
|
end
|
27
27
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kindlegen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyzip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: pry
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,9 +70,10 @@ description: Installing kindlegen command, downloading tar.gz file from amazon.c
|
|
42
70
|
and extracting it and copy kindlegen command to bin.
|
43
71
|
email:
|
44
72
|
- t@tdtds.jp
|
45
|
-
executables:
|
73
|
+
executables:
|
74
|
+
- kindlegen
|
46
75
|
extensions:
|
47
|
-
- ext/
|
76
|
+
- ext/Rakefile
|
48
77
|
extra_rdoc_files: []
|
49
78
|
files:
|
50
79
|
- ".gitignore"
|
@@ -54,7 +83,8 @@ files:
|
|
54
83
|
- LICENSE
|
55
84
|
- README.md
|
56
85
|
- Rakefile
|
57
|
-
-
|
86
|
+
- exe/kindlegen
|
87
|
+
- ext/Rakefile
|
58
88
|
- kindlegen.gemspec
|
59
89
|
- lib/kindlegen.rb
|
60
90
|
- lib/kindlegen/version.rb
|
@@ -79,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
109
|
version: '0'
|
80
110
|
requirements: []
|
81
111
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.8
|
83
113
|
signing_key:
|
84
114
|
specification_version: 4
|
85
115
|
summary: Installing kindlegen command.
|
data/ext/kindlegen/extconf.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# making Makefile getting kindlegen from Amazon.com
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'rbconfig'
|
6
|
-
File::open('Makefile', 'w') do |w|
|
7
|
-
case RbConfig::CONFIG['host_os']
|
8
|
-
when /mac|darwin/i
|
9
|
-
unzip = 'unzip'
|
10
|
-
tarball = 'KindleGen_Mac_i386_v2_9.zip'
|
11
|
-
target = 'kindlegen'
|
12
|
-
when /linux|cygwin/i
|
13
|
-
unzip = 'tar -zx --no-same-owner -f'
|
14
|
-
tarball = 'kindlegen_linux_2.6_i386_v2_9.tar.gz'
|
15
|
-
target = 'kindlegen'
|
16
|
-
when /mingw32/i
|
17
|
-
unzip = 'unzip'
|
18
|
-
# Abort if either `unzip' or `curl' if not found
|
19
|
-
`where #{unzip}`
|
20
|
-
unless ($?.success?)
|
21
|
-
STDERR.puts "The program `unzip' not found. Aborting."
|
22
|
-
exit(1)
|
23
|
-
end
|
24
|
-
`where curl`
|
25
|
-
unless ($?.success?)
|
26
|
-
STDERR.puts "The program `curl` not found. Aborting."
|
27
|
-
exit(1)
|
28
|
-
end
|
29
|
-
tarball = 'kindlegen_win32_v2_9.zip'
|
30
|
-
target = 'kindlegen.exe'
|
31
|
-
else
|
32
|
-
STDERR.puts "Host OS unsupported!"
|
33
|
-
exit(1)
|
34
|
-
end
|
35
|
-
|
36
|
-
bindir = File.join(File.expand_path('../../..', __FILE__), "bin")
|
37
|
-
|
38
|
-
config = RbConfig::CONFIG.merge({
|
39
|
-
"unzip" => unzip,
|
40
|
-
"tarball" => tarball,
|
41
|
-
"target" => target,
|
42
|
-
"bindir" => bindir,
|
43
|
-
})
|
44
|
-
|
45
|
-
w.puts RbConfig.expand(DATA.read, config)
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
__END__
|
50
|
-
AMAZON = http://kindlegen.s3.amazonaws.com
|
51
|
-
TARGET = $(target)
|
52
|
-
BINDIR = $(bindir)
|
53
|
-
TARBALL = $(tarball)
|
54
|
-
CURL = curl
|
55
|
-
UNZIP = $(unzip)
|
56
|
-
CP = cp -a
|
57
|
-
MKDIR = mkdir -p
|
58
|
-
|
59
|
-
all:
|
60
|
-
|
61
|
-
$(TARGET): $(TARBALL)
|
62
|
-
$(UNZIP) $(TARBALL)
|
63
|
-
touch $(TARGET)
|
64
|
-
chmod +x $(TARGET)
|
65
|
-
|
66
|
-
$(TARBALL):
|
67
|
-
$(CURL) $(AMAZON)/$(TARBALL) -o $(TARBALL)
|
68
|
-
|
69
|
-
install: $(TARGET)
|
70
|
-
$(MKDIR) $(BINDIR)
|
71
|
-
$(CP) $(TARGET) $(BINDIR)
|