epuber 0.5.4 → 0.5.5

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
  SHA256:
3
- metadata.gz: af52b1d6873c8846c792bbe5efd95396128dd56e843786706d52c5bda38ccf51
4
- data.tar.gz: 209c3daec98a872b4cf91f9b1da2e0ccdf52305e91cb0ecfb3750595567dda42
3
+ metadata.gz: fcab657cbef790188e95b1b238d68438e7f523e78be9c712209803c3808c3ca1
4
+ data.tar.gz: d36fe7e3f63eb459e9036a587adee857a5f9552524c35e8ef63ef0a867302eac
5
5
  SHA512:
6
- metadata.gz: 9f268936a200ed6240cec25aaf0ed2aa5dec6894ce955847f37ad749ec18361edad9fa33d7ec555d07c1ea48c2da014c1860c75f1257609c80d97ea1432a40d1
7
- data.tar.gz: 6e0a3672b32f57dc84b613de1169340fab3c0ac00a0dc6b4dace00785bcca45d93c9cad54abc3bc50dd8d36eccfd237222b3e284d4586dc037b7f0768f72c446
6
+ metadata.gz: 640ffc22f2584d5ce642a7c7e923b13734e66e9db7fed5c2094b874b69ff56e0feabd75951be7886ac05ff94aa661b0a44e047b7cea4358d6f9efce7747b8ae2
7
+ data.tar.gz: eff25321a3950ccfd005fcdc3fa12b2becb8d8f2a6e2f429afdb36569f940a0461ea0165a2436a963da5b7ee88aafb895a0a7d07e7c4d4c5aec56a78be1ef81d
@@ -161,7 +161,6 @@ module Epuber
161
161
  attribute :epub_version,
162
162
  required: true,
163
163
  inherited: true,
164
- types: [Version],
165
164
  auto_convert: { [String, Integer, Float] => Version },
166
165
  default_value: 3.0
167
166
 
@@ -11,7 +11,6 @@ module Epuber
11
11
  # @return [Epuber::Book::FileRequest]
12
12
  #
13
13
  attribute :file_request,
14
- types: [FileRequest],
15
14
  auto_convert: { String => FileRequest },
16
15
  inherited: true
17
16
 
@@ -45,7 +45,7 @@ module Epuber
45
45
  verify_one_bookspec_exists!
46
46
  verify_all_targets_exists!
47
47
 
48
- Config.instance.warn_for_outdated_versions!
48
+ pre_build_checks
49
49
  end
50
50
 
51
51
  def run
@@ -30,7 +30,7 @@ module Epuber
30
30
  super
31
31
  verify_one_bookspec_exists!
32
32
 
33
- Config.instance.warn_for_outdated_versions!
33
+ pre_build_checks
34
34
  end
35
35
 
36
36
  def run
@@ -74,5 +74,14 @@ module Epuber
74
74
  Epuber::Config.instance.save_lockfile
75
75
  end
76
76
  end
77
+
78
+ def pre_build_checks
79
+ Config.instance.warn_for_outdated_versions!
80
+
81
+ if !Config.instance.same_version_as_last_run? && File.exist?(Config.instance.working_path)
82
+ UI.warning('Using different version of Epuber or Bade, removing all build caches')
83
+ Config.instance.remove_build_caches
84
+ end
85
+ end
77
86
  end
78
87
  end
@@ -264,13 +264,23 @@ module Epuber
264
264
 
265
265
  # Creates proper mime-type for file
266
266
  #
267
- # @param file [Epuber::Book::File]
267
+ # @param file [Epuber::Compiler::FileTypes::AbstractFile | String]
268
268
  #
269
269
  # @return [String]
270
270
  #
271
271
  def mime_type_for(file)
272
- filename = file.destination_path
273
- MIME::Types.of(filename).first.content_type
272
+ filename = if file.is_a?(String)
273
+ file
274
+ else
275
+ file.destination_path
276
+ end
277
+
278
+ case File.extname(filename)
279
+ when '.ttf', '.otf'
280
+ 'application/vnd.ms-opentype'
281
+ else
282
+ MIME::Types.of(filename).first.content_type
283
+ end
274
284
  end
275
285
 
276
286
  # Creates hash of namespaces for root package element
data/lib/epuber/config.rb CHANGED
@@ -131,6 +131,18 @@ module Epuber
131
131
  end
132
132
  end
133
133
 
134
+ def same_version_as_last_run?
135
+ !(bookspec_lockfile.epuber_version != Epuber::VERSION ||
136
+ bookspec_lockfile.bade_version.nil? ||
137
+ bookspec_lockfile.bade_version != Bade::VERSION)
138
+ end
139
+
140
+ def remove_build_caches
141
+ FileUtils.rm_rf(File.join(working_path, 'build_cache'))
142
+ FileUtils.rm_rf(File.join(working_path, 'build'))
143
+ FileUtils.rm_rf(File.join(working_path, 'metadata'))
144
+ end
145
+
134
146
  # ---------------------------------------------------------------------------------------------------------------- #
135
147
 
136
148
  class << self
@@ -47,8 +47,10 @@ module Epuber
47
47
  @auto_convert = auto_convert
48
48
  @types = if !types.nil?
49
49
  types
50
- elsif @default_value
50
+ elsif @default_value && @auto_convert.empty?
51
51
  [@default_value.class]
52
+ elsif !@auto_convert.empty?
53
+ [@auto_convert.values.first]
52
54
  else
53
55
  [String]
54
56
  end
@@ -234,6 +236,8 @@ module Epuber
234
236
  return dest_class.call(value)
235
237
  elsif dest_class.respond_to?(:parse)
236
238
  return dest_class.parse(value)
239
+ elsif dest_class <= String
240
+ return value.to_s
237
241
  elsif dest_class.respond_to?(:new)
238
242
  return dest_class.new(value)
239
243
  else
@@ -66,12 +66,8 @@ module Epuber
66
66
  parent.send(key)
67
67
 
68
68
  elsif !attr.default_value.nil?
69
- # write default value on first access to root object
70
- root_obj = self.class.find_root(self) || self
71
- root_obj.send(attr.writer_name, attr.default_value)
72
-
73
- # and return the default value
74
- attr.default_value
69
+ # just return the default value
70
+ attr.converted_value(attr.default_value)
75
71
  end
76
72
  end
77
73
 
@@ -19,11 +19,6 @@ module Epuber
19
19
  super
20
20
  @attributes_values = {}
21
21
  @file_path = nil
22
-
23
- # iterate over all attributes to write default values
24
- self.class.dsl_attributes.each do |key, _attr|
25
- self.send(key)
26
- end
27
22
  end
28
23
 
29
24
  # @return [String]
@@ -71,7 +71,7 @@ mixin iterate_spine(toc_item)
71
71
 
72
72
 
73
73
  +section('Targets')
74
- - book.all_targets.each do |b_target|
74
+ - book.buildable_targets.each do |b_target|
75
75
  p(class: 'target_selected' if target == b_target): a(href: "/change_target/#{b_target.name}")= b_target.name
76
76
  - end
77
77
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Epuber
3
- VERSION = '0.5.4'
3
+ VERSION = '0.5.5'
4
4
 
5
5
  HOME_URL = 'https://github.com/epuber-io/epuber'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Kříž