EPUBChop 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 310ed2a66e86fba757f244581f9cfbe4cbf69094
4
- data.tar.gz: 4243b1aae661b31a47d3c78d2e027717f1c6d5a6
3
+ metadata.gz: af66209bba7f425f7e95980d708fb2c04925d081
4
+ data.tar.gz: 5c62f5ca92e06e1e6b6d3f5bb6448e5194325825
5
5
  SHA512:
6
- metadata.gz: 4b4afb0cc16991ced9a95117a45d974a1b58797a574eaed765fb17009dbf4b1df725fe4e0d347939fbdf5dec8316d36b03c82471b6af0478993766c7216d5022
7
- data.tar.gz: 63959397ad7d9589e0c0ee4b466ec46360eb9372e43d3fe4068c4515ae56f83ef24ca2175c212a7b66d51b4a8c86251c7b34ae493bb8cdbc23e76feaa56bbc6c
6
+ metadata.gz: a6740ed4f801ec53552869bc2ceb52e5c6ffe73ba16acac548f37778cf15ba6e62ee50be9629e3948e16fb67455d188ce693578a5d91bc33a042879683f9b8a4
7
+ data.tar.gz: fd0e96e1c9468bde9dd8014ebfe6aa71cb0addb8f20903165a24f3a3bca9fda4fff48b95337476841e7354c4a5d18134a9f2c385f6799c06304dce87ac8e568c
data/lib/EPUBChop/chop.rb CHANGED
@@ -155,11 +155,11 @@ module EPUBChop
155
155
  meta['http-equiv'] = "Content-Type"
156
156
  meta['content'] = "text/html; charset=UTF-8"
157
157
 
158
- meta_charset = Nokogiri::XML::Node.new('meta', resource)
159
- meta_charset['charset'] = 'UTF-8'
158
+ # meta_charset = Nokogiri::XML::Node.new('meta', resource)
159
+ # meta_charset['charset'] = 'UTF-8'
160
160
 
161
161
  resource.css('head').first << meta
162
- resource.css('head').first << meta_charset
162
+ # resource.css('head').first << meta_charset
163
163
 
164
164
  resource
165
165
  end
@@ -231,11 +231,22 @@ module EPUBChop
231
231
  end
232
232
  end
233
233
 
234
+ metadata = Nokogiri::XML(File.read("#{extract_dir}/#{@book.table_of_contents.parser.metadata_path}"))
234
235
  to_be_deleted_images = (all_images - not_to_be_deleted_images)
235
236
  to_be_deleted_images.each do |image|
236
237
  next if image.nil?
237
238
  puts "\t\tremoving #{image}" if @verbose
238
239
  File.delete("#{extract_dir}/#{image}") if File.exists?("#{extract_dir}/#{image}")
240
+
241
+
242
+ image_in_metadata = metadata.xpath("//default:item[contains(@href,'#{File.basename(image)}' )]", :default => 'http://www.idpf.org/2007/opf')
243
+ if image_in_metadata.count > 0
244
+ image_in_metadata.remove
245
+ end
246
+ end
247
+
248
+ File.open("#{extract_dir}/#{@book.table_of_contents.parser.metadata_path}", 'wb') do |f|
249
+ f.puts metadata.to_xml(encoding: 'UTF-8')
239
250
  end
240
251
 
241
252
  to_be_deleted_images
@@ -1,3 +1,3 @@
1
1
  module EPUBChop
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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.1.3
4
+ version: 0.1.4
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-04-24 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler