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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmM1ZTY5M2E0NjMwN2ViZDFkYzUzODAyZmZhN2VmOGVkZTkwNTNkYQ==
4
+ ZDdjMWZlMTIyOTJmMjJiN2I0OGQxYTUzMjA5MTlkNzZhZjcwMDQ3MQ==
5
5
  data.tar.gz: !binary |-
6
- N2IwZThjYjA2Yjg3YjRhZDBiOTliMDY5Y2FmMzJmMjc4YTI3NGI3MA==
6
+ ZjdjY2JiNzkwY2RiZTIxMDMyM2M4YTU1MjY0OGMwOTZiYjI4NmY4Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTg1YWMwYmU5NzI1ZTEwZTQxNzJlM2M0YzU3MGY2ZGZjZTE4NDk1ZmJmMDkw
10
- OTRkN2M0OTQ3ZDQxYThhMjRlN2ZhZjA5ZGExODIyNTg1NDczNTQ4MWM0MjU4
11
- MzdmNDMyMWNiMDNhNzQ4ZmQ3NDY3ODgxNzQ2MjQ2ZDI5MmI1MGY=
9
+ ZjJkYTdmNDI4OGFkNWUxZDRlZjlkZWQ1NDZkYTA3MWE2MmQ3YWMwYmZjZjkz
10
+ NDZiZGVjMGEwNWY5ZjgwZjA2ZjQ4OTM4MDBhMGRlNWQ3ODk5Njc1ODhlY2U2
11
+ ZmVjNmEwNGYwYTQ1ZGZiNDc0Nzc4ODliZWI0N2Y1MjcxNDQzMGY=
12
12
  data.tar.gz: !binary |-
13
- NTM0NzdkZDNmY2E3MzkwOGU0ODQxZjA5YmQ4ZWRjNDM1N2JlYzhkY2Q5YTcy
14
- MDZiMjUyZDZmNzY4NDE1YzJhZTA1NzY0MjUzOWQ1ZDc3ZmQ3N2FkMzBjYjZm
15
- NzQ3NGM2ZDUyODU0ZmEwNTA4OTQ4NGUwYTJlNDgzNmJlNDUzYjg=
13
+ ZTNlY2E2OTA4NTNkM2I0YWRjMDc1YTkxMWU5YjgyMDY4YWM0ODE2MGVjZjQ5
14
+ OGI2YmNjNWFmZjA1ZTI1OGViZjI0N2UyNjJiOTQ3MmRhOTUyOTYwZDIwNDc2
15
+ NGQ0ZWU1N2RhZDBmNGMyOGZlZWM1NzIwMDgzMGM3Y2FkZjdhYWI=
@@ -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 :chop_by, "Follow the SPINE or the NCX of the ePub", :type => :string, :default => :spine
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 << options[: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, :chop_by => chop_by})
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
 
@@ -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.store(resource[:uri], size)
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}
@@ -1,3 +1,3 @@
1
1
  module EPUBChop
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
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-01-20 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler