epubforge 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/action/run_description.rb +7 -4
- data/lib/core_extensions/string.rb +17 -1
- data/lib/epub/assets/page.rb +9 -1
- data/lib/epubforge.rb +1 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -23,10 +23,9 @@ module EpubForge
|
|
23
23
|
handle_errors do
|
24
24
|
@execution_returned = self.klass.new.do( self.project, *(self.args) )
|
25
25
|
end
|
26
|
-
else
|
27
|
-
puts "Error(s) trying to complete the requested action:"
|
28
|
-
puts self.errors.join("\n")
|
29
26
|
end
|
27
|
+
|
28
|
+
report_errors if errors?
|
30
29
|
|
31
30
|
self.finish
|
32
31
|
self
|
@@ -38,7 +37,11 @@ module EpubForge
|
|
38
37
|
@errors << "#{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
|
39
38
|
self
|
40
39
|
end
|
41
|
-
|
40
|
+
|
41
|
+
def report_errors
|
42
|
+
puts @errors.join("\n\n------------------------------------------------------------------\n\n")
|
43
|
+
puts "Error(s) trying to complete the requested action:"
|
44
|
+
end
|
42
45
|
|
43
46
|
def runnable?
|
44
47
|
! errors?
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class String
|
2
|
-
TITLE_WORDS_NOT_CAPITALIZED = %W(a an in the for and nor but or yet so also)
|
3
2
|
def epf_blank?
|
4
3
|
self.strip.length == 0
|
5
4
|
end
|
@@ -13,6 +12,23 @@ class String
|
|
13
12
|
self.gsub(" ", "\\ ")
|
14
13
|
end
|
15
14
|
|
15
|
+
def epf_titlecap_words
|
16
|
+
nocaps = %w(a and at be but in is nor of or so teh the to with)
|
17
|
+
upcase = %w(Ii Ii: Iii M.d.) # TODO: ick
|
18
|
+
debugger if self.match( /ii/i )
|
19
|
+
|
20
|
+
words = self.downcase.gsub(/\u00a0/, ' ').split(/(\s|\n)+/).map(&:strip).delete_if(&:epf_blank?)
|
21
|
+
first_word = true
|
22
|
+
|
23
|
+
for word in words
|
24
|
+
word.capitalize! unless nocaps.include?(word) && first_word == false # note: if the word is all caps, will downcase # TODO: What about M.D., state abbreviations, etc.? This is far from perfect.
|
25
|
+
word.upcase! if upcase.include?(word)
|
26
|
+
first_word = false
|
27
|
+
end
|
28
|
+
|
29
|
+
words.join(" ")
|
30
|
+
end
|
31
|
+
|
16
32
|
def epf_underscorize
|
17
33
|
self.downcase.gsub(/\s+/,"_").gsub(/[\W]/,"")
|
18
34
|
end
|
data/lib/epub/assets/page.rb
CHANGED
@@ -29,7 +29,15 @@ module EpubForge
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def get_title
|
32
|
-
|
32
|
+
html_doc = Nokogiri::HTML( @html )
|
33
|
+
h1 = html_doc.xpath("//h1").first
|
34
|
+
|
35
|
+
if h1.nil?
|
36
|
+
@title = @original_file.basename.to_s.split(".")[0..-2].map(&:capitalize).join(" : ")
|
37
|
+
else
|
38
|
+
title = h1.content
|
39
|
+
@title = title.gsub(/\s*\/+\s*/, "").epf_titlecap_words
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
def link
|
data/lib/epubforge.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
# require 'builder'
|
6
6
|
require 'thor'
|
7
7
|
require 'optparse'
|
8
|
+
require 'nokogiri'
|
8
9
|
require 'xdg' # keep configuration files in sane places
|
9
10
|
require 'debugger'
|
10
11
|
require 'erb'
|
@@ -19,8 +20,6 @@ require 'rbconfig'
|
|
19
20
|
require 'fun_with_files'
|
20
21
|
require 'fun_with_configurations'
|
21
22
|
|
22
|
-
|
23
|
-
|
24
23
|
EpubForge = Module.new
|
25
24
|
EpubForge::DEBUG = false
|
26
25
|
# EpubForge.root responds with the gem directory
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epubforge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xdg
|
@@ -316,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: '0'
|
317
317
|
segments:
|
318
318
|
- 0
|
319
|
-
hash:
|
319
|
+
hash: 2723822957058462033
|
320
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
321
321
|
none: false
|
322
322
|
requirements:
|