epuber 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bcf06496b9fa4f3dc3e979ff764a8ef40dcd2c925a8f6100d96b07d785d86b2
4
- data.tar.gz: 7b92cc896492d689f5b69095ab608098e91dd9595e7ae1993327907a4bd925d5
3
+ metadata.gz: 36b3de5a7595e7eb07e7604f51fe0e57f2610c9d4e65bd4efed8bf34a3f5d79a
4
+ data.tar.gz: 7b3413db0823660dee8cd28ac1e820c8cfd10b557e5be1e2c82afce72335a194
5
5
  SHA512:
6
- metadata.gz: b805dabd18ad6c8bf2f2f3a44b391726bf3a9766abb7668dd8fd7fb83b0173b076a04f765b041e8d405cf13ffba8e88a043c8ef39ee30e2b65197d8671f7eba2
7
- data.tar.gz: 14cd6edfca175231d53f3883bd5dc18e178e02a1703907897492c9918b305e7826cb7a8b35fabb4d3b05aa943ab44b1370dfa837d97ee171c261bc23f2751d29
6
+ metadata.gz: 0df514b965ad7e809d7c447556bd256f4d4329914b871d165f975ebb1673fda40f95c5957ba4867855b959e529269859cfc30e6b9ff62b86770c2432351b8e1d
7
+ data.tar.gz: 7d4e411ce744dfb5e61bc43c9a77e3b00866756f9a6dfd625cdf5adec2163d76b73ff9bd58453b3f3e737dc2e40b2eac192334efd4bf69244ab173f40697ca30
@@ -44,6 +44,8 @@ module Epuber
44
44
  super
45
45
  verify_one_bookspec_exists!
46
46
  verify_all_targets_exists!
47
+
48
+ Config.instance.warn_for_outdated_versions!
47
49
  end
48
50
 
49
51
  def run
@@ -29,6 +29,8 @@ module Epuber
29
29
  def validate!
30
30
  super
31
31
  verify_one_bookspec_exists!
32
+
33
+ Config.instance.warn_for_outdated_versions!
32
34
  end
33
35
 
34
36
  def run
@@ -34,7 +34,7 @@ module Epuber
34
34
  end
35
35
 
36
36
  doctypes = []
37
- while /(\n|\?>|\A)?(<![^>]*>\n*)/ =~ text
37
+ while /(\n|\?>|\A)?(<!DOCTYPE [^>]*>\n*)/ =~ text
38
38
  doctypes << $2.strip
39
39
 
40
40
  match = Regexp.last_match
@@ -103,6 +103,12 @@ module Epuber
103
103
 
104
104
  html.children.first.before(head)
105
105
  end
106
+
107
+ # https://github.com/IDPF/epubcheck/issues/631
108
+ if epub_version < 3.0
109
+ xhtml_doc.internal_subset.remove unless xhtml_doc.internal_subset.nil?
110
+ xhtml_doc.create_internal_subset('html', "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd")
111
+ end
106
112
  end
107
113
 
108
114
  # Method for adding style sheets with links, method will not add duplicate items
data/lib/epuber/config.rb CHANGED
@@ -67,16 +67,15 @@ module Epuber
67
67
  # @return [Epuber::Lockfile]
68
68
  #
69
69
  def bookspec_lockfile
70
- @bookspec_lockfile ||= (
71
- lockfile = Lockfile.from_file(bookspec_lockfile_path)
72
- lockfile.version = Epuber::VERSION
73
- lockfile
74
- )
70
+ @bookspec_lockfile ||= Lockfile.from_file(bookspec_lockfile_path)
75
71
  end
76
72
 
77
73
  # @return nil
78
74
  #
79
75
  def save_lockfile
76
+ bookspec_lockfile.epuber_version = Epuber::VERSION
77
+ bookspec_lockfile.bade_version = Bade::VERSION
78
+
80
79
  bookspec_lockfile.write_to_file
81
80
  end
82
81
 
@@ -118,6 +117,16 @@ module Epuber
118
117
  File.join(working_path, 'metadata', 'target_stats', target.name.to_s, 'file_stats.yml')
119
118
  end
120
119
 
120
+ def warn_for_outdated_versions!
121
+ if bookspec_lockfile.epuber_version > Epuber::VERSION
122
+ UI.warning('Warning: the running version of Epuber is older than the version that created the lockfile. We suggest you upgrade to the latest version of Epuber by running `gem install epuber`')
123
+ end
124
+
125
+ if bookspec_lockfile.bade_version && bookspec_lockfile.bade_version > Bade::VERSION
126
+ UI.warning('Warning: the running version of Bade is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bade by running `gem install bade`')
127
+ end
128
+ end
129
+
121
130
  # ---------------------------------------------------------------------------------------------------------------- #
122
131
 
123
132
  class << self
@@ -17,11 +17,16 @@ module Epuber
17
17
  #
18
18
  def self.from_file(file_path)
19
19
  if File.exists?(file_path)
20
- hash = YAML.load(File.read(file_path))
20
+ hash = YAML.safe_load(File.read(file_path))
21
21
  else
22
22
  hash = {}
23
23
  end
24
24
 
25
+ # backward compatibility for version 0.5 and older
26
+ if hash.include?('version')
27
+ hash['epuber_version'] = hash.delete('version')
28
+ end
29
+
25
30
  inst = self.new(hash)
26
31
  inst.defined_from_file = file_path
27
32
  inst
@@ -32,24 +37,33 @@ module Epuber
32
37
  def write_to_file
33
38
  return if defined_from_file.nil?
34
39
 
35
- File.open(defined_from_file, 'w') do |f|
36
- f.write(YAML.dump(@internal_data))
37
- end
40
+ File.write(defined_from_file, @internal_data.to_yaml)
38
41
  end
39
42
 
40
-
41
43
  # @return [Epuber::Version]
42
44
  #
43
- def version
44
- @internal_data['version']
45
+ def epuber_version
46
+ Version.new(@internal_data['epuber_version'])
45
47
  end
46
48
 
47
49
  # @param [Epuber::Version] new_version
48
50
  #
51
+ def epuber_version=(new_version)
52
+ @internal_data['epuber_version'] = new_version.to_s
53
+ end
54
+
49
55
  # @return [Epuber::Version]
50
56
  #
51
- def version=(new_version)
52
- @internal_data['version'] = new_version
57
+ def bade_version
58
+ value = @internal_data['bade_version']
59
+ value = Version.new(value) unless value.nil?
60
+ value
61
+ end
62
+
63
+ # @param [Epuber::Version] new_version
64
+ #
65
+ def bade_version=(new_version)
66
+ @internal_data['bade_version'] = new_version
53
67
  end
54
68
  end
55
69
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Epuber
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
 
5
5
  HOME_URL = 'https://github.com/epuber-io/epuber'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Kříž
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-09 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport