epub-parser 0.2.3 → 0.2.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: db9a8abb6d8ece39b51e5432c33caffdbd5efc65
4
- data.tar.gz: bd9eb66c3af2ad86c1def37514c60db5d687a26d
3
+ metadata.gz: 397595100e38636588590b7243f631b5d36fa05a
4
+ data.tar.gz: 80c3b9bfd7bf935339c9a7b79e463e334e31cd98
5
5
  SHA512:
6
- metadata.gz: ab94d4c2c5104e966d6f2ed8368491189ca5a215a687bd6fdd2a43424b02935c44c36f8b14f39514858d2ad92c283e6ae7780041339f28f63dc283e1c8f72c30
7
- data.tar.gz: 4d8c2f4f3a8dc584386cf55a4a6be890856c466b9ae1e7c2d6dfbe4cf31362730b1cbadf89c125910f9ab86ee27ccd7776fa099efefbeee4727698e140629cac
6
+ metadata.gz: 8bc7936024db865257350be7d61d3d48677858cbcd3d77c561ee10979671e903d0234398b7b4ef0bc78a137ff7a0589e722d6ffb0638ab290b2a91cab496167b
7
+ data.tar.gz: ae0b06be290df786bf1a7038417cb1dcbc6d51602f68c5afefa8311d856c086b62fcff10a972f5c0b2544980a65ec06f863c83b77f692f941fa0c893f95876ba
@@ -1,6 +1,15 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 0.2.4
5
+ -----
6
+
7
+ * Bug fix for `EPUB::CFI::Location#<=>`
8
+ * Change default physical container adapter from `EPUB::OCF::PhysicalContainer::ZipRuby` to `EPUB::OCF::PhysicalContainer::ArchiveZip`
9
+ * Add `EPUB::CFI::Step#element?` and `#character_data?`
10
+ * Change attribute name: `EPUB::CFI::Step#step` -> `EPUB::CFI::Step#value`, `EPUB::CFI::CharacterOffset#offset` -> `EPUB::CFI::CharacterOffset#value`
11
+ * Show modified on `epubinfo` command
12
+
4
13
  0.2.3
5
14
  -----
6
15
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011, 2012, 2013 KITAITIMAKOTO <KitaitiMakoto@gmail.com>
1
+ Copyright (c) 2011, 2012, 2013, 2014, 2015 KITAITIMAKOTO <KitaitiMakoto@gmail.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
@@ -133,7 +133,7 @@ Then documentation will be available in `doc` directory.
133
133
 
134
134
  REQUIREMENTS
135
135
  ------------
136
- * Ruby 2.0.0 or later
136
+ * Ruby 2.1.0 or later
137
137
  * `patch` command to install Nokogiri
138
138
  * C compiler to compile Zip/Ruby and Nokogiri
139
139
 
@@ -151,6 +151,14 @@ If you find other gems, please tell me or request a pull request.
151
151
  RECENT CHANGES
152
152
  --------------
153
153
 
154
+ ### 0.2.4
155
+
156
+ * Bug fix for `EPUB::CFI::Location#<=>`
157
+ * Change default physical container adapter from `EPUB::OCF::PhysicalContainer::ZipRuby` to `EPUB::OCF::PhysicalContainer::ArchiveZip`
158
+ * Add `EPUB::CFI::Step#element?` and `#character_data?`
159
+ * Change attribute name: `EPUB::CFI::Step#step` -> `EPUB::CFI::Step#value`, `EPUB::CFI::CharacterOffset#offset` -> `EPUB::CFI::CharacterOffset#value`
160
+ * Show modified on `epubinfo` command
161
+
154
162
  ### 0.2.3
155
163
 
156
164
  * Change the name of physical container adapter for file system: :File -> :UnpackedDirectory
@@ -177,10 +185,6 @@ RECENT CHANGES
177
185
 
178
186
  [archive-zip]: https://github.com/javanthropus/archive-zip
179
187
 
180
- ### 0.2.0
181
-
182
- * Make it possible to parse file system directory as an EPUB file. See {file:docs/UnpackedArchive.markdown} for details.
183
-
184
188
  See {file:CHANGELOG.markdown} for older changelogs and details.
185
189
 
186
190
  TODOS
@@ -41,6 +41,7 @@ end
41
41
  book = EPUB::Parser.parse(file)
42
42
  data = {'Title' => [book.title]}
43
43
  data.merge!(book.metadata.to_h)
44
+ data['modified'] = [book.modified]
44
45
  data['Unique identifier'] = [book.metadata.unique_identifier]
45
46
  data['EPUB Version'] = [book.package.version]
46
47
  counts = {:chars => 0, :words => 0}
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.has_rdoc = 'yard'
28
28
 
29
29
  s.add_development_dependency 'rake'
30
- s.add_development_dependency 'archive-zip'
30
+ s.add_development_dependency 'zipruby'
31
31
  s.add_development_dependency 'pry'
32
32
  s.add_development_dependency 'pry-doc'
33
33
  s.add_development_dependency 'test-unit'
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.add_development_dependency 'racc'
42
42
  s.add_development_dependency 'nokogiri-diff'
43
43
 
44
- s.add_runtime_dependency 'zipruby'
44
+ s.add_runtime_dependency 'archive-zip'
45
45
  s.add_runtime_dependency 'nokogiri', '~> 1.6'
46
46
  s.add_runtime_dependency 'addressable', '>= 2.3.5'
47
47
  s.add_runtime_dependency 'rchardet', '>= 1.6.1'
@@ -41,7 +41,7 @@ module EPUB
41
41
  end
42
42
 
43
43
  unless cmp == 0
44
- if cmp == 1 and other_paths[index + 1]
44
+ if cmp == 1 and paths[index].offset and other_paths[index + 1]
45
45
  return nil
46
46
  else
47
47
  return cmp
@@ -182,24 +182,33 @@ module EPUB
182
182
  end
183
183
 
184
184
  class Step
185
- attr_reader :step, :assertion
185
+ attr_reader :value, :assertion
186
+ alias step value
186
187
 
187
- def initialize(step, assertion=nil)
188
- @step, @assertion = step, assertion
188
+ def initialize(value, assertion=nil)
189
+ @value, @assertion = value, assertion
189
190
  @string_cache = nil
190
191
  end
191
192
 
192
193
  def initialize_copy(original)
193
- @step = original.step
194
+ @value = original.value
194
195
  @assertion = original.assertion.dup if original.assertion
195
196
  end
196
197
 
197
198
  def to_s
198
- @string_cache ||= "/#{step}#{assertion}".freeze # need escape?
199
+ @string_cache ||= "/#{value}#{assertion}".freeze # need escape?
199
200
  end
200
201
 
201
202
  def <=>(other)
202
- step <=> other.step
203
+ value <=> other.value
204
+ end
205
+
206
+ def element?
207
+ value.even?
208
+ end
209
+
210
+ def character_data?
211
+ value.odd?
203
212
  end
204
213
  end
205
214
 
@@ -247,19 +256,20 @@ module EPUB
247
256
  end
248
257
 
249
258
  class CharacterOffset
250
- attr_reader :offset, :assertion
259
+ attr_reader :value, :assertion
260
+ alias offset value
251
261
 
252
- def initialize(offset, assertion=nil)
253
- @offset, @assertion = offset, assertion
262
+ def initialize(value, assertion=nil)
263
+ @value, @assertion = value, assertion
254
264
  @string_cache = nil
255
265
  end
256
266
 
257
267
  def to_s
258
- @string_cache ||= ":#{offset}#{assertion}".freeze # need escape?
268
+ @string_cache ||= ":#{value}#{assertion}".freeze # need escape?
259
269
  end
260
270
 
261
271
  def <=>(other)
262
- offset <=> other.offset
272
+ value <=> other.value
263
273
  end
264
274
  end
265
275
 
@@ -1,4 +1,4 @@
1
- require 'epub/ocf/physical_container/zipruby'
1
+ require 'epub/ocf/physical_container/archive_zip'
2
2
  require 'epub/ocf/physical_container/unpacked_directory'
3
3
  require 'epub/ocf/physical_container/unpacked_uri'
4
4
 
@@ -6,7 +6,7 @@ module EPUB
6
6
  class OCF
7
7
  # @todo: Make thread save
8
8
  class PhysicalContainer
9
- @adapter = Zipruby
9
+ @adapter = ArchiveZip
10
10
 
11
11
  class << self
12
12
  def adapter
@@ -1,18 +1,5 @@
1
1
  require 'zipruby'
2
2
 
3
- if $VERBOSE
4
- warn <<EOW
5
- [WARNING]Default OCF physical container adapter will become ArchiveZip, which uses archive-zip gem to extract contents from EPUB package, instead of current default Zipruby, which uses zipruby gem, in the near future.
6
- You can try ArchiveZip adapter by:
7
-
8
- 1. gem install archive-zip
9
- 2. require 'epub/ocf/physical_container/archive_zip'
10
- 3. EPUB::OCF::PhysicalContainer.adapter = :ArchiveZip
11
-
12
- If you find problems, please inform me via GitHub issues: https://github.com/KitaitiMakoto/epub-parser/issues
13
- EOW
14
- end
15
-
16
3
  module EPUB
17
4
  class OCF
18
5
  class PhysicalContainer
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -43,6 +43,7 @@ class TestOCFPhysicalContainer < Test::Unit::TestCase
43
43
  end
44
44
  end
45
45
 
46
+ require 'epub/ocf/physical_container/zipruby'
46
47
  class TestZipruby < self
47
48
  include ConcreteContainer
48
49
 
@@ -71,7 +72,6 @@ class TestOCFPhysicalContainer < Test::Unit::TestCase
71
72
  end
72
73
  end
73
74
 
74
- require 'epub/ocf/physical_container/archive_zip'
75
75
  class TestArchiveZip < self
76
76
  include ConcreteContainer
77
77
 
@@ -44,7 +44,7 @@ class TestParser < Test::Unit::TestCase
44
44
  assert_equal 'Mon premier guide de cuisson, un Mémoire', epub.main_title
45
45
  assert_equal File.read('test/fixtures/book/OPS/nav.xhtml'), epub.nav.read
46
46
  assert_equal EPUB::OCF::PhysicalContainer::UnpackedDirectory, epub.container_adapter
47
- assert_equal EPUB::OCF::PhysicalContainer::Zipruby, EPUB::OCF::PhysicalContainer.adapter
47
+ assert_equal EPUB::OCF::PhysicalContainer::ArchiveZip, EPUB::OCF::PhysicalContainer.adapter
48
48
  end
49
49
 
50
50
  class TestBook < TestParser
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: archive-zip
28
+ name: zipruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -207,7 +207,7 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
- name: zipruby
210
+ name: archive-zip
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - ">="