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 +4 -4
- data/lib/EPUBChop/chop.rb +14 -3
- data/lib/EPUBChop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af66209bba7f425f7e95980d708fb2c04925d081
|
4
|
+
data.tar.gz: 5c62f5ca92e06e1e6b6d3f5bb6448e5194325825
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
159
|
-
|
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
|
-
|
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
|
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.1.
|
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-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|