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 CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.0.5
2
+ Fix bug in generating index.html.
3
+ Stop copy html files.
4
+
1
5
  = 0.0.4
2
6
  Rewrite directory recursion to loop. for performance.
3
7
  Fix bug in Makefile
data/README CHANGED
@@ -5,11 +5,22 @@ convert sourcecode to epub
5
5
  $ gem install sc2epub
6
6
 
7
7
  == usage
8
- $ sc2epub some_directory output_directory project_name
9
- $ cd output_directory
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 generate xhtml, xml, and Makefile. You need make for compilation of epub.
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
@@ -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
- FileUtils::cp(path, @output)
79
- return
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
- flag = false
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
- @dirstack.push({:name =>local(path), :src =>nil, :path => path,
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
- unless flag
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)} SOME_DIR OUTPUT_DIR PROJECT_NAME")
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
@@ -2,5 +2,5 @@ module Sc2epub
2
2
  require 'sc2epub/converter'
3
3
  require 'sc2epub/template'
4
4
  require 'sc2epub/main'
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
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@at-akada.org'
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
- FileTest.should be_exists(File::join(@out, 'some.html'))
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
- FileTest.should_not be_exists(File::join(@out, 'some_html.html'))
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
- - 4
9
- version: 0.0.4
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-21 00:00:00 +09:00
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@at-akada.org
24
+ email: nightly at at-akada dot org
25
25
  executables:
26
26
  - sc2epub
27
27
  extensions: []