sc2epub 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/README +15 -4
- data/lib/sc2epub/converter.rb +12 -10
- data/lib/sc2epub/main.rb +1 -1
- data/lib/sc2epub.rb +1 -1
- data/sc2epub.gemspec +1 -2
- data/test/sc2epubspec.rb +12 -6
- metadata +4 -4
data/CHANGES
CHANGED
data/README
CHANGED
@@ -5,11 +5,22 @@ convert sourcecode to epub
|
|
5
5
|
$ gem install sc2epub
|
6
6
|
|
7
7
|
== usage
|
8
|
-
$ sc2epub
|
9
|
-
$ cd
|
8
|
+
$ sc2epub SOURCECODE_DIRECTORY OUTPUT_DIRECTORY PROJECT_NAME
|
9
|
+
$ cd OUTPUT_DIRECTORY
|
10
10
|
$ make
|
11
|
+
# it generates PROJECT_NAME.epub
|
11
12
|
$ make kindle # if you need mobi file
|
13
|
+
# it generates PROJECT_NAME.mobi
|
14
|
+
|
15
|
+
== example
|
16
|
+
$ sc2epub ~/src/readline-5.2 ~/src/readline-epub readline
|
17
|
+
$ cd ~/src/readline-epub
|
18
|
+
$ make
|
19
|
+
$ make kindle
|
20
|
+
$ cp readline.mobi ~/
|
12
21
|
|
13
22
|
== notice
|
14
|
-
sc2epub
|
15
|
-
And if you want to generate mobi file, you need kindlegen command.
|
23
|
+
sc2epub generates xhtml, xml, and Makefile. You need `make' command for compilation of epub.
|
24
|
+
And if you want to generate mobi file, you need `kindlegen' command.
|
25
|
+
About kindlegen see below.
|
26
|
+
http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000234621
|
data/lib/sc2epub/converter.rb
CHANGED
@@ -73,11 +73,11 @@ class Sc2epub::Converter
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
def dofile path
|
76
|
-
ext = File::extname(path)
|
77
|
-
if ext == '.html' or ext == '.xhtml' or ext == '.jpg' or ext == '.gif' or ext == '.png'
|
78
|
-
|
79
|
-
|
80
|
-
end
|
76
|
+
#ext = File::extname(path)
|
77
|
+
#if ext == '.html' or ext == '.xhtml' or ext == '.jpg' or ext == '.gif' or ext == '.png'
|
78
|
+
# FileUtils::cp(path, @output)
|
79
|
+
# return
|
80
|
+
#end
|
81
81
|
output = @output
|
82
82
|
s = open(path){|io|io.read}
|
83
83
|
enc = NKF::guess(s)
|
@@ -107,24 +107,26 @@ class Sc2epub::Converter
|
|
107
107
|
cache = {}
|
108
108
|
until(@dirstack.empty?)
|
109
109
|
dir = @dirstack.last[:path]
|
110
|
-
|
110
|
+
subdir = nil
|
111
111
|
Dir::foreach(dir) do |i|
|
112
112
|
next if i=="."||i==".."
|
113
113
|
path = File::join(dir, i)
|
114
114
|
next if cache[path]
|
115
115
|
if FileTest::directory? path
|
116
|
-
|
117
|
-
:type => :dir, :level => @dirstack.size})
|
118
|
-
flag = true
|
116
|
+
subdir = path
|
119
117
|
break
|
120
118
|
elsif FileTest::file? path
|
121
119
|
dofile(path)
|
122
120
|
cache[path] = true
|
123
121
|
end
|
124
122
|
end
|
125
|
-
|
123
|
+
if !subdir
|
126
124
|
done = @dirstack.pop
|
127
125
|
cache[done[:path]] = true
|
126
|
+
else
|
127
|
+
path = subdir
|
128
|
+
@dirstack.push({:name =>local(path), :src =>nil, :path => path,
|
129
|
+
:type => :dir, :level => @dirstack.size})
|
128
130
|
end
|
129
131
|
end
|
130
132
|
end
|
data/lib/sc2epub/main.rb
CHANGED
@@ -3,7 +3,7 @@ class Sc2epub::Main
|
|
3
3
|
def main
|
4
4
|
input = ARGV[0]
|
5
5
|
output = ARGV[1]
|
6
|
-
opts = OptionParser.new("Usage: #{File::basename($0)}
|
6
|
+
opts = OptionParser.new("Usage: #{File::basename($0)} SOURCE_DIR OUTPUT_DIR PROJECT_NAME")
|
7
7
|
opts.on("-v", "--version", "show version") do
|
8
8
|
puts "%s %s" %[File.basename($0), Sc2epub::VERSION]
|
9
9
|
puts "ruby %s" % RUBY_VERSION
|
data/lib/sc2epub.rb
CHANGED
data/sc2epub.gemspec
CHANGED
@@ -4,8 +4,7 @@ GEMSPEC = Gem::Specification::new do |s|
|
|
4
4
|
s.name = 'sc2epub'
|
5
5
|
s.version = Sc2epub::VERSION
|
6
6
|
s.author = 'takada-at'
|
7
|
-
s.email = 'nightly
|
8
|
-
s.date = '2010-11-21'
|
7
|
+
s.email = 'nightly at at-akada dot org'
|
9
8
|
s.summary = 'sourcecode to epub'
|
10
9
|
s.platform = Gem::Platform::RUBY
|
11
10
|
s.required_ruby_version = '>= 1.8.6'
|
data/test/sc2epubspec.rb
CHANGED
@@ -19,15 +19,15 @@ describe Sc2epub::Converter, 'when on html' do
|
|
19
19
|
@converter.doroot(@in)
|
20
20
|
@converter.dogenerate('test')
|
21
21
|
end
|
22
|
-
it 'should copy html' do
|
23
|
-
|
24
|
-
end
|
22
|
+
#it 'should copy html' do
|
23
|
+
# FileTest.should be_exists(File::join(@out, 'some.html'))
|
24
|
+
#end
|
25
25
|
it 'should rewrite source code' do
|
26
26
|
FileTest.should be_exists(File::join(@out, 'some_rb.html'))
|
27
27
|
end
|
28
|
-
it 'should not rewrite html' do
|
29
|
-
|
30
|
-
end
|
28
|
+
#it 'should not rewrite html' do
|
29
|
+
# FileTest.should_not be_exists(File::join(@out, 'some_html.html'))
|
30
|
+
#end
|
31
31
|
after(:all) do
|
32
32
|
`rm -r #{@in}` if FileTest::exists? @in
|
33
33
|
`rm -r #{@out}` if FileTest::exists? @out
|
@@ -92,6 +92,12 @@ describe Sc2epub::Converter, 'when on sc2epub/lib'do
|
|
92
92
|
/<dc:Creator>(.*)<\/dc:Creator>/.match(s).should_not be(nil)
|
93
93
|
Regexp::last_match[1].should == 'test'
|
94
94
|
end
|
95
|
+
it 'should place sc2epub.rb before sc2epub/converter.rb in index.html' do
|
96
|
+
s = open(File::join(@out, 'index.html')){|io|io.read}
|
97
|
+
p0 = s.index('sc2epub.rb')
|
98
|
+
p1 = s.index('sc2epub/converter.rb')
|
99
|
+
p0.should < p1
|
100
|
+
end
|
95
101
|
after(:all) do
|
96
102
|
if FileTest::exists? @out
|
97
103
|
`rm -r #{@out}`
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- takada-at
|
@@ -14,14 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-22 00:00:00 +09:00
|
18
18
|
default_executable: sc2epub
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: |
|
22
22
|
convert sourcecode to epub
|
23
23
|
|
24
|
-
email: nightly
|
24
|
+
email: nightly at at-akada dot org
|
25
25
|
executables:
|
26
26
|
- sc2epub
|
27
27
|
extensions: []
|