epuber 0.7.4 → 0.8.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/README.md +2 -1
  4. data/epuber.gemspec +10 -12
  5. data/lib/epuber/book/contributor.rb +0 -1
  6. data/lib/epuber/book/file_request.rb +1 -1
  7. data/lib/epuber/book/target.rb +20 -23
  8. data/lib/epuber/book/toc_item.rb +2 -4
  9. data/lib/epuber/book.rb +19 -19
  10. data/lib/epuber/checker/bookspec_checker.rb +26 -0
  11. data/lib/epuber/checker/text_checker.rb +2 -1
  12. data/lib/epuber/checker.rb +16 -2
  13. data/lib/epuber/checker_transformer_base.rb +2 -5
  14. data/lib/epuber/command/build.rb +34 -24
  15. data/lib/epuber/command/init.rb +23 -23
  16. data/lib/epuber/command/server.rb +2 -2
  17. data/lib/epuber/command.rb +17 -20
  18. data/lib/epuber/compiler/compilation_context.rb +10 -8
  19. data/lib/epuber/compiler/file_database.rb +0 -2
  20. data/lib/epuber/compiler/file_finders/abstract.rb +33 -23
  21. data/lib/epuber/compiler/file_finders/imaginary.rb +40 -35
  22. data/lib/epuber/compiler/file_resolver.rb +77 -88
  23. data/lib/epuber/compiler/file_stat.rb +4 -4
  24. data/lib/epuber/compiler/file_types/abstract_file.rb +3 -4
  25. data/lib/epuber/compiler/file_types/bade_file.rb +12 -7
  26. data/lib/epuber/compiler/file_types/coffee_script_file.rb +1 -1
  27. data/lib/epuber/compiler/file_types/generated_file.rb +1 -1
  28. data/lib/epuber/compiler/file_types/image_file.rb +4 -2
  29. data/lib/epuber/compiler/file_types/nav_file.rb +0 -1
  30. data/lib/epuber/compiler/file_types/opf_file.rb +0 -1
  31. data/lib/epuber/compiler/file_types/source_file.rb +8 -3
  32. data/lib/epuber/compiler/file_types/xhtml_file.rb +67 -13
  33. data/lib/epuber/compiler/generator.rb +1 -2
  34. data/lib/epuber/compiler/meta_inf_generator.rb +1 -1
  35. data/lib/epuber/compiler/nav_generator.rb +5 -6
  36. data/lib/epuber/compiler/opf_generator.rb +22 -23
  37. data/lib/epuber/compiler/problem.rb +12 -21
  38. data/lib/epuber/compiler/xhtml_processor.rb +61 -31
  39. data/lib/epuber/compiler.rb +66 -19
  40. data/lib/epuber/config.rb +13 -7
  41. data/lib/epuber/dsl/attribute.rb +16 -17
  42. data/lib/epuber/dsl/attribute_support.rb +3 -3
  43. data/lib/epuber/dsl/object.rb +17 -15
  44. data/lib/epuber/dsl/tree_object.rb +2 -3
  45. data/lib/epuber/epubcheck.rb +15 -0
  46. data/lib/epuber/helper.rb +0 -1
  47. data/lib/epuber/lockfile.rb +7 -9
  48. data/lib/epuber/plugin.rb +1 -2
  49. data/lib/epuber/ruby_extensions/match_data.rb +1 -1
  50. data/lib/epuber/ruby_extensions/thread.rb +1 -0
  51. data/lib/epuber/server/base.styl +0 -1
  52. data/lib/epuber/server/basic.styl +1 -30
  53. data/lib/epuber/server/handlers.rb +1 -1
  54. data/lib/epuber/server.rb +67 -66
  55. data/lib/epuber/third_party/bower.rb +5 -5
  56. data/lib/epuber/transformer/text_transformer.rb +4 -2
  57. data/lib/epuber/transformer.rb +2 -2
  58. data/lib/epuber/user_interface.rb +49 -38
  59. data/lib/epuber/vendor/hash_binding.rb +9 -2
  60. data/lib/epuber/vendor/ruby_templater.rb +1 -5
  61. data/lib/epuber/vendor/version.rb +10 -10
  62. data/lib/epuber/version.rb +1 -1
  63. metadata +67 -69
  64. data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Bold.ttf +0 -0
  65. data/lib/epuber/server/fonts/AvenirNext/AvenirNext-BoldItalic.ttf +0 -0
  66. data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Italic.ttf +0 -0
  67. data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Regular.ttf +0 -0
@@ -49,11 +49,10 @@ module Epuber
49
49
 
50
50
  next unless attr.required? && value.nil?
51
51
 
52
- if attr.singularize?
53
- raise ValidationError, "missing required attribute `#{key.to_s.singularize}|#{key}`"
54
- else
55
- raise ValidationError, "missing required attribute `#{key}`"
56
- end
52
+ raise ValidationError, "missing required attribute `#{key.to_s.singularize}|#{key}`" if attr.singularize?
53
+
54
+
55
+ raise ValidationError, "missing required attribute `#{key}`"
57
56
  end
58
57
  end
59
58
 
@@ -74,21 +73,16 @@ module Epuber
74
73
  # @return [Self]
75
74
  #
76
75
  def self.from_string(string, file_path = nil)
77
- # rubocop:disable Lint/Eval
78
76
  obj = if file_path
79
- eval(string, nil, file_path)
77
+ eval(string, nil, file_path) # rubocop:disable Security/Eval
80
78
  else
81
- eval(string)
79
+ eval(string) # rubocop:disable Security/Eval
82
80
  end
83
- # rubocop:enable Lint/Eval
84
81
 
85
82
  unless obj.is_a?(self)
86
83
  msg = "Invalid object #{obj.class}, expected object of class #{self}"
87
84
 
88
- if file_path
89
- msg += ", loaded from file #{file_path}"
90
-
91
- end
85
+ msg += ", loaded from file #{file_path}" if file_path
92
86
 
93
87
  raise StandardError, msg
94
88
  end
@@ -121,6 +115,10 @@ module Epuber
121
115
  #
122
116
  attr_accessor :attributes_values
123
117
 
118
+ def respond_to_missing?(name, include_private = false)
119
+ @attributes_values.key?(name) || super
120
+ end
121
+
124
122
  # Raise exception when there is used some unknown method or attribute
125
123
  #
126
124
  # This is just for creating better message in raised exception
@@ -129,9 +127,13 @@ module Epuber
129
127
  #
130
128
  def method_missing(name, *args)
131
129
  if /([^=]+)=?/ =~ name
132
- attr_name = $1
130
+ attr_name = ::Regexp.last_match(1)
133
131
  location = caller_locations.first
134
- raise NameError, "Unknown attribute or method `#{attr_name}` for class `#{self.class}` in file `#{location.path}:#{location.lineno}`"
132
+ message = <<~MSG
133
+ Unknown attribute or method `#{attr_name}` for class `#{self.class}` in file `#{location.path}:#{location.lineno}`
134
+ MSG
135
+
136
+ raise NameError, message
135
137
  else
136
138
  super
137
139
  end
@@ -10,7 +10,7 @@ module Epuber
10
10
  def initialize(parent = nil)
11
11
  super()
12
12
 
13
- @parent = parent
13
+ @parent = parent
14
14
  @sub_items = []
15
15
 
16
16
  parent.sub_items << self unless parent.nil?
@@ -94,8 +94,7 @@ module Epuber
94
94
 
95
95
  protected
96
96
 
97
- attr_writer :parent
98
- attr_writer :sub_items
97
+ attr_writer :parent, :sub_items
99
98
  end
100
99
  end
101
100
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Epuber
4
+ class Epubcheck
5
+ class << self
6
+ # @param [String] path path to file
7
+ #
8
+ def check(path)
9
+ res = system('epubcheck', path)
10
+
11
+ UI.error!('Epubcheck failed') unless res
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/epuber/helper.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Epuber
4
4
  module Helper
5
-
6
5
  # @param [Book::TocItem] toc_item
7
6
  # @param [Compiler::FileResolver] file_resolver
8
7
  # @param [String] context_path
@@ -18,18 +18,16 @@ module Epuber
18
18
  # @return [self]
19
19
  #
20
20
  def self.from_file(file_path)
21
- if File.exist?(file_path)
22
- hash = YAML.safe_load(File.read(file_path))
23
- else
24
- hash = {}
25
- end
21
+ hash = if File.exist?(file_path)
22
+ YAML.safe_load(File.read(file_path))
23
+ else
24
+ {}
25
+ end
26
26
 
27
27
  # backward compatibility for version 0.5 and older
28
- if hash.include?('version')
29
- hash['epuber_version'] = hash.delete('version')
30
- end
28
+ hash['epuber_version'] = hash.delete('version') if hash.include?('version')
31
29
 
32
- inst = self.new(hash)
30
+ inst = new(hash)
33
31
  inst.defined_from_file = file_path
34
32
  yield inst if hash.empty? && block_given?
35
33
  inst
data/lib/epuber/plugin.rb CHANGED
@@ -18,7 +18,7 @@ module Epuber
18
18
  super(file_path)
19
19
  @instances = []
20
20
 
21
- eval(::File.read(file_path), binding, file_path)
21
+ eval(::File.read(file_path), binding, file_path) # rubocop:disable Security/Eval
22
22
  end
23
23
 
24
24
  # @param [Symbol] name name of the plugin function
@@ -97,7 +97,6 @@ module Epuber
97
97
  end.flatten
98
98
  end
99
99
 
100
-
101
100
  # @return [Array<Checker>]
102
101
  #
103
102
  def checkers
@@ -17,7 +17,7 @@ class MatchData
17
17
  #
18
18
  def line_number
19
19
  n = pre_match_lines.length
20
- n += 1 if n == 0 # it can't be zero, this happens only when the match is at the beginning of file or string
20
+ n += 1 if n.zero? # it can't be zero, this happens only when the match is at the beginning of file or string
21
21
  n
22
22
  end
23
23
 
@@ -6,6 +6,7 @@ class Thread
6
6
  def hash
7
7
  to_s.hash
8
8
  end
9
+
9
10
  def ==(other)
10
11
  to_s == other.to_s
11
12
  end
@@ -1,3 +1,2 @@
1
1
 
2
- main_font_family = AvenirNext
3
2
  text_color = #B87B4A
@@ -9,7 +9,7 @@ body, div, html, p
9
9
 
10
10
 
11
11
  body
12
- font-family main_font_family
12
+ font-family system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
13
13
  font-weight normal
14
14
  font-size 20px
15
15
 
@@ -184,32 +184,3 @@ p.file
184
184
  span.arrow
185
185
  font-family monospace
186
186
  color text_color
187
-
188
-
189
-
190
-
191
-
192
-
193
- @font-face
194
- font-family AvenirNext
195
- font-style normal
196
- font-weight bold
197
- src url(fonts/AvenirNext/AvenirNext-Bold.ttf)
198
-
199
- @font-face
200
- font-family AvenirNext
201
- font-style italic
202
- font-weight bold
203
- src url(fonts/AvenirNext/AvenirNext-BoldItalic.ttf)
204
-
205
- @font-face
206
- font-family AvenirNext
207
- font-style italic
208
- font-weight normal
209
- src url(fonts/AvenirNext/AvenirNext-Italic.ttf)
210
-
211
- @font-face
212
- font-family AvenirNext
213
- font-style normal
214
- font-weight normal
215
- src url(fonts/AvenirNext/AvenirNext-Regular.ttf)
@@ -49,7 +49,7 @@ module Epuber
49
49
  #
50
50
  def handle_bade(file_path)
51
51
  [200, self.class.render_bade(file_path)]
52
- rescue => e
52
+ rescue StandardError => e
53
53
  env['sinatra.error'] = e
54
54
  ShowExceptions.new(self).call(env)
55
55
  end
data/lib/epuber/server.rb CHANGED
@@ -23,9 +23,9 @@ require_relative 'third_party/bower'
23
23
 
24
24
 
25
25
  module Epuber
26
-
27
26
  # API:
28
- # [LATER] /file/<path-or-pattern> -- displays pretty file (image, text file) (for example: /file/text/s01.xhtml or /file/text/s01.bade)
27
+ # [LATER] /file/<path-or-pattern> -- displays pretty file (image, text file) (for example: /file/text/s01.xhtml or
28
+ # /file/text/s01.bade)
29
29
  #
30
30
  class Server < Sinatra::Base
31
31
  require_relative 'server/handlers'
@@ -42,11 +42,9 @@ module Epuber
42
42
  body = pretty(env, e)
43
43
  end
44
44
 
45
- unless body.is_a?(Array)
46
- body = [body]
47
- end
45
+ body = [body] unless body.is_a?(Array)
48
46
 
49
- [500, { 'Content-Type' => content_type,
47
+ [500, { 'Content-Type' => content_type,
50
48
  'Content-Length' => Rack::Utils.bytesize(body.join).to_s },
51
49
  body]
52
50
  end
@@ -118,7 +116,7 @@ module Epuber
118
116
 
119
117
  super() do |server|
120
118
  $stderr = old_stderr
121
- puts "Started development server on #{server.host}:#{server.port}"
119
+ UI.puts "Started development server on #{server.host}:#{server.port}"
122
120
 
123
121
  host = if server.host == '0.0.0.0'
124
122
  'localhost'
@@ -134,11 +132,11 @@ module Epuber
134
132
  @verbose = verbose
135
133
  @default_thin_logger ||= Thin::Logging.logger
136
134
 
137
- unless verbose
135
+ if verbose
136
+ Thin::Logging.logger = @default_thin_logger
137
+ else
138
138
  Thin::Logging.logger = Logger.new(nil)
139
139
  Thin::Logging.logger.level = :fatal
140
- else
141
- Thin::Logging.logger = @default_thin_logger
142
140
  end
143
141
 
144
142
  set :logging, verbose
@@ -152,20 +150,18 @@ module Epuber
152
150
  end
153
151
 
154
152
  def self.start_listening_if_needed
155
- return unless self.listener.nil?
153
+ return unless listener.nil?
156
154
 
157
155
  self.listener = Listen.to(Config.instance.project_path, debug: true) do |modified, added, removed|
158
- begin
159
- changes_detected(modified, added, removed)
160
- rescue => e
161
- # print error, do not send error further, listener will die otherwise
162
- $stderr.puts e
163
- $stderr.puts e.backtrace
164
- end
156
+ changes_detected(modified, added, removed)
157
+ rescue StandardError => e
158
+ # print error, do not send error further, listener will die otherwise
159
+ warn e
160
+ warn e.backtrace
165
161
  end
166
162
 
167
- listener.ignore(%r{\.idea})
168
- listener.ignore(%r{#{Config.instance.working_path}})
163
+ listener.ignore(/\.idea/)
164
+ listener.ignore(/#{Config.instance.working_path}/)
169
165
  listener.ignore(%r{#{Config::WORKING_PATH}/})
170
166
 
171
167
  listener.start
@@ -183,7 +179,6 @@ module Epuber
183
179
  self.class.build_path
184
180
  end
185
181
 
186
-
187
182
  # @param level [Symbol]
188
183
  # @param message [String]
189
184
  #
@@ -192,13 +187,13 @@ module Epuber
192
187
  def self._log(level, message)
193
188
  case level
194
189
  when :ui
195
- puts message
190
+ UI.puts message
196
191
  when :info
197
- puts "INFO: #{message}" if verbose
192
+ UI.puts "INFO: #{message}" if verbose
198
193
  when :get
199
- puts " GET: #{message}" if verbose
194
+ UI.puts " GET: #{message}" if verbose
200
195
  when :ws
201
- puts " WS: #{message}" if verbose
196
+ UI.puts " WS: #{message}" if verbose
202
197
  else
203
198
  raise "Unknown log level #{level}"
204
199
  end
@@ -226,9 +221,9 @@ module Epuber
226
221
  # @return [Epuber::Book::File, nil]
227
222
  #
228
223
  def spine_file_at(index)
229
- if !file_resolver.nil? && index >= 0 && index < file_resolver.spine_files.count
230
- file_resolver.spine_files[index]
231
- end
224
+ return unless !file_resolver.nil? && index >= 0 && index < file_resolver.spine_files.count
225
+
226
+ file_resolver.spine_files[index]
232
227
  end
233
228
 
234
229
  # @param [String] path
@@ -238,15 +233,14 @@ module Epuber
238
233
  def self.relative_path_to_book_file(path)
239
234
  file = file_resolver.file_with_source_path(path)
240
235
  return if file.nil?
236
+
241
237
  file.pkg_destination_path
242
238
  end
243
239
 
244
240
  def add_script_file_to_head(html_doc, file_name, *args)
245
241
  source = File.read(File.expand_path("server/#{file_name}", File.dirname(__FILE__)))
246
242
 
247
- if File.extname(file_name) == '.coffee'
248
- source = CoffeeScript.compile(source)
249
- end
243
+ source = CoffeeScript.compile(source) if File.extname(file_name) == '.coffee'
250
244
 
251
245
  args.each do |hash|
252
246
  hash.each do |key, value|
@@ -302,14 +296,16 @@ module Epuber
302
296
  head = html_doc.at_css('head')
303
297
  node = case type
304
298
  when :style
305
- html_doc.create_element('link', href: "/server/raw/#{file_path}" ,rel: 'stylesheet', type: 'text/css')
299
+ html_doc.create_element('link', href: "/server/raw/#{file_path}", rel: 'stylesheet', type: 'text/css')
306
300
  when :js
307
301
  html_doc.create_element('script', src: "/server/raw/#{file_path}", type: 'text/javascript')
308
302
  else
309
303
  raise "Unknown file type `#{type}`"
310
304
  end
311
305
 
312
- return if head.css('script, link').any? { |n| (!n['href'].nil? && n['href'] == node['href']) || (!n['src'].nil? && n['src'] == node['src']) }
306
+ return if head.css('script, link').any? do |n|
307
+ (!n['href'].nil? && n['href'] == node['href']) || (!n['src'].nil? && n['src'] == node['src'])
308
+ end
313
309
 
314
310
  head.add_child(node)
315
311
  end
@@ -338,24 +334,22 @@ module Epuber
338
334
  self.target = new_target
339
335
  else
340
336
  self.target = book.targets.first
341
- _log :ui, "[!] Not found previous target after reloading bookspec file, jumping to first #{self.target.name}"
337
+ _log :ui, "[!] Not found previous target after reloading bookspec file, jumping to first #{target.name}"
342
338
  end
343
339
  end
344
340
 
345
341
  def self._compile_book
346
- begin
347
- compiler = Epuber::Compiler.new(book, target)
348
- compiler.compile(build_path)
349
- self.file_resolver = compiler.file_resolver
342
+ compiler = Epuber::Compiler.new(book, target)
343
+ compiler.compile(build_path)
344
+ self.file_resolver = compiler.file_resolver
350
345
 
351
- true
352
- rescue => e
353
- self.file_resolver = compiler.file_resolver
346
+ true
347
+ rescue StandardError => e
348
+ self.file_resolver = compiler.file_resolver
354
349
 
355
- Epuber::UI.error("Compile error: #{e}", location: e)
350
+ Epuber::UI.error("Compile error: #{e}", location: e)
356
351
 
357
- false
358
- end
352
+ false
359
353
  end
360
354
 
361
355
  def self.compile_book(&completion)
@@ -366,12 +360,12 @@ module Epuber
366
360
 
367
361
  @compilation_thread = Thread.new do
368
362
  result = _compile_book
369
- completion.call(result) unless completion.nil?
363
+ completion&.call(result)
370
364
  end
371
365
 
372
- if completion.nil?
373
- @compilation_thread.join
374
- end
366
+ return unless completion.nil?
367
+
368
+ @compilation_thread.join
375
369
  end
376
370
 
377
371
  # @param message [String]
@@ -387,7 +381,8 @@ module Epuber
387
381
  # @param type [Symbol]
388
382
  def self.notify_clients(type, data = nil)
389
383
  _log :info, "Notifying clients with type #{type.inspect}"
390
- raise "Not known type `#{type}`" unless [:styles, :reload, :compile_start, :compile_end].include?(type)
384
+ raise "Not known type `#{type}`" unless %i[styles reload compile_start compile_end].include?(type)
385
+
391
386
  message = {
392
387
  name: type,
393
388
  }
@@ -406,17 +401,17 @@ module Epuber
406
401
  files_paths.select { |file| file_resolver.file_with_source_path(file) || book.file_path == file }
407
402
  end
408
403
 
409
- # @param _modified [Array<String>]
410
- # @param _added [Array<String>]
411
- # @param _removed [Array<String>]
404
+ # @param modified [Array<String>]
405
+ # @param added [Array<String>]
406
+ # @param removed [Array<String>]
412
407
  #
413
- def self.changes_detected(_modified, _added, _removed)
414
- all_changed = (_modified + _added + _removed).uniq.map { |path| path.unicode_normalize }
408
+ def self.changes_detected(modified, added, removed)
409
+ all_changed = (modified + added + removed).uniq.map(&:unicode_normalize)
415
410
 
416
411
  reload_bookspec if all_changed.any? { |file| file == book.file_path }
417
412
 
418
413
  changed = filter_not_project_files(all_changed) || []
419
- return if changed.count == 0
414
+ return if changed.count.zero?
420
415
 
421
416
  notify_clients(:compile_start)
422
417
 
@@ -440,11 +435,15 @@ module Epuber
440
435
  # remove nil paths (for example bookspec can't be found so the relative path is nil)
441
436
  changed.compact!
442
437
 
443
- # if changed.size > 0 && changed.all? { |file| file.end_with?(*Epuber::Compiler::FileFinders::GROUP_EXTENSIONS[:style]) }
444
- # notify_clients(:styles, changed)
445
- # else
438
+ changed_only_styles = changed.all? do |file|
439
+ file.end_with?(*Epuber::Compiler::FileFinders::GROUP_EXTENSIONS[:style])
440
+ end
441
+
442
+ if changed.size.positive? && changed_only_styles
443
+ notify_clients(:styles, changed)
444
+ else
446
445
  notify_clients(:reload, changed)
447
- # end
446
+ end
448
447
  end
449
448
  end
450
449
 
@@ -460,12 +459,12 @@ module Epuber
460
459
  ws.onopen do
461
460
  sockets << ws
462
461
 
463
- ws.send({name: :hello}.to_json)
462
+ ws.send({ name: :hello }.to_json)
464
463
 
465
464
  thread = Thread.new do
466
465
  loop do
467
466
  sleep(10)
468
- ws.send({name: :heartbeat}.to_json)
467
+ ws.send({ name: :heartbeat }.to_json)
469
468
  end
470
469
  end
471
470
  end
@@ -490,6 +489,7 @@ module Epuber
490
489
  mtime = File.mtime(file_path)
491
490
  last_modified(mtime)
492
491
  etag(mtime.to_s)
492
+ cache_control :public, :must_revalidate
493
493
 
494
494
  case File.extname(file_path)
495
495
  when '.styl'
@@ -571,11 +571,11 @@ module Epuber
571
571
  full_path = File.expand_path(path, build_path)
572
572
 
573
573
  case File.extname(full_path)
574
- when '.xhtml'
575
- content_type :xhtml
576
- handle_xhtml_file(full_path)
577
- else
578
- handle_file(full_path)
574
+ when '.xhtml'
575
+ content_type :xhtml
576
+ handle_xhtml_file(full_path)
577
+ else
578
+ handle_file(full_path)
579
579
  end
580
580
  end
581
581
  end
@@ -621,6 +621,7 @@ module Epuber
621
621
  get '/raw/*' do
622
622
  path = find_file
623
623
  next not_found if path.nil?
624
+
624
625
  handle_file(File.expand_path(path, build_path))
625
626
  end
626
627
 
@@ -5,12 +5,12 @@ module Epuber
5
5
  class Bower
6
6
  class << self
7
7
  JS_COMPONENTS = {
8
- jquery: 'jquery/dist/',
9
- cookies: 'cookies-js/dist/',
10
- uri: 'uri.js/src/',
11
- spin: 'spin.js/',
8
+ jquery: 'jquery/dist/',
9
+ cookies: 'cookies-js/dist/',
10
+ uri: 'uri.js/src/',
11
+ spin: 'spin.js/',
12
12
  keymaster: 'keymaster/',
13
- }
13
+ }.freeze
14
14
 
15
15
  def path_to_js(component)
16
16
  path = JS_COMPONENTS[component]
@@ -5,7 +5,6 @@ require_relative '../transformer'
5
5
  module Epuber
6
6
  class Transformer
7
7
  class TextTransformer < Transformer
8
-
9
8
  # @return [String]
10
9
  #
11
10
  attr_accessor :text
@@ -51,7 +50,10 @@ module Epuber
51
50
  @text.gsub!(pattern, replacement, &block)
52
51
  end
53
52
 
54
- result = replace_all(pattern, replacement, multiple_times: multiple_times, &block) if multiple_times && !result.nil?
53
+ if multiple_times && !result.nil?
54
+ result = replace_all(pattern, replacement, multiple_times: multiple_times,
55
+ &block)
56
+ end
55
57
  result
56
58
  end
57
59
  end
@@ -10,8 +10,8 @@ module Epuber
10
10
  #
11
11
  def self.map_source_type__class
12
12
  {
13
- :result_text_xhtml_string => TextTransformer,
14
- :source_text_file => TextTransformer,
13
+ result_text_xhtml_string: TextTransformer,
14
+ source_text_file: TextTransformer,
15
15
  }.merge(super)
16
16
  end
17
17
  end