EPUBChop 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/epubchop +4 -4
- data/lib/EPUBChop/chop.rb +2 -1
- data/lib/EPUBChop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDdjMWZlMTIyOTJmMjJiN2I0OGQxYTUzMjA5MTlkNzZhZjcwMDQ3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjdjY2JiNzkwY2RiZTIxMDMyM2M4YTU1MjY0OGMwOTZiYjI4NmY4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjJkYTdmNDI4OGFkNWUxZDRlZjlkZWQ1NDZkYTA3MWE2MmQ3YWMwYmZjZjkz
|
10
|
+
NDZiZGVjMGEwNWY5ZjgwZjA2ZjQ4OTM4MDBhMGRlNWQ3ODk5Njc1ODhlY2U2
|
11
|
+
ZmVjNmEwNGYwYTQ1ZGZiNDc0Nzc4ODliZWI0N2Y1MjcxNDQzMGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTNlY2E2OTA4NTNkM2I0YWRjMDc1YTkxMWU5YjgyMDY4YWM0ODE2MGVjZjQ5
|
14
|
+
OGI2YmNjNWFmZjA1ZTI1OGViZjI0N2UyNjJiOTQ3MmRhOTUyOTYwZDIwNDc2
|
15
|
+
NGQ0ZWU1N2RhZDBmNGMyOGZlZWM1NzIwMDgzMGM3Y2FkZjdhYWI=
|
data/bin/epubchop
CHANGED
@@ -18,7 +18,7 @@ BANNER
|
|
18
18
|
opt :base, "How to interprete the --words options... Possible value: percentage", :type => :string, :default => 'percentage'
|
19
19
|
opt :line1, "Text that is shown on line 1 of the chopped pages", :type => :string, :default => 'Continue reading?'
|
20
20
|
opt :line2, "Text that is shown on line 2 of the chopped pages", :type => :string, :default => 'Go to your local library or buy the book.'
|
21
|
-
opt :
|
21
|
+
opt :chop, "Follow the SPINE or the NCX of the ePub", :type => :string, :default => 'spine'
|
22
22
|
end
|
23
23
|
|
24
24
|
Trollop::die "need an EPUB file name" if ARGV.empty?
|
@@ -31,12 +31,12 @@ begin
|
|
31
31
|
text = []
|
32
32
|
text << options[:line1] if options.has_key?(:line1)
|
33
33
|
text << options[:line2] if options.has_key?(:line2)
|
34
|
-
chop_by
|
34
|
+
chop_by = options[:chop]
|
35
35
|
|
36
36
|
puts 'loading EPUB'
|
37
|
-
b=EPUBChop.get(filename)
|
37
|
+
b=EPUBChop.get(filename, :chop_by => chop_by.to_sym)
|
38
38
|
puts 'chopping EPUB'
|
39
|
-
c=b.chop({:base => base.to_s, :words => words, :text => text
|
39
|
+
c=b.chop({:base => base.to_s, :words => words, :text => text})
|
40
40
|
puts 'rebuilding EPUB'
|
41
41
|
FileUtils.move(c, "chopped_#{File.basename(filename)}")
|
42
42
|
|
data/lib/EPUBChop/chop.rb
CHANGED
@@ -258,6 +258,7 @@ DATA
|
|
258
258
|
@book = EPUBInfo.get(input)
|
259
259
|
resource_word_count = {}
|
260
260
|
if @book
|
261
|
+
resources = @book.table_of_contents.resources.to_a
|
261
262
|
chop_by = @chop_by.eql?(:ncx) ? @book.table_of_contents.resources.ncx : @book.table_of_contents.resources.spine
|
262
263
|
|
263
264
|
chop_by.each do |resource|
|
@@ -268,7 +269,7 @@ DATA
|
|
268
269
|
raw.css('script').remove
|
269
270
|
raw.css('style').remove
|
270
271
|
size = raw.at_css('body').text.split.size
|
271
|
-
resource_word_count
|
272
|
+
resource_word_count[resource[:uri]] = size
|
272
273
|
end
|
273
274
|
end
|
274
275
|
# resource_word_count.values.inject(0){|sum, i| sum + i}
|
data/lib/EPUBChop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: EPUBChop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Celik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|