alexandria-book-collection-manager 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +45 -27
  4. data/.rubocop_todo.yml +127 -86
  5. data/.simplecov +1 -0
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +5 -0
  8. data/ChangeLog.0 +33 -35
  9. data/Gemfile +2 -2
  10. data/INSTALL.md +152 -0
  11. data/Rakefile +12 -10
  12. data/alexandria-book-collection-manager.gemspec +5 -5
  13. data/bin/alexandria +2 -1
  14. data/doc/AUTHORS +61 -0
  15. data/doc/BUGS +31 -0
  16. data/doc/FAQ +369 -0
  17. data/doc/HACKING +19 -0
  18. data/doc/NEWS +341 -0
  19. data/doc/alexandria.1 +120 -0
  20. data/doc/cuecat_support.rdoc +67 -0
  21. data/doc/dependency_decisions.yml +61 -0
  22. data/lib/alexandria.rb +2 -0
  23. data/lib/alexandria/about.rb +7 -6
  24. data/lib/alexandria/book_providers.rb +6 -6
  25. data/lib/alexandria/book_providers/adlibris.rb +9 -14
  26. data/lib/alexandria/book_providers/amazon_aws.rb +29 -33
  27. data/lib/alexandria/book_providers/amazon_ecs_util.rb +10 -14
  28. data/lib/alexandria/book_providers/barnes_and_noble.rb +9 -11
  29. data/lib/alexandria/book_providers/deastore.rb +12 -20
  30. data/lib/alexandria/book_providers/douban.rb +9 -15
  31. data/lib/alexandria/book_providers/mcu.rb +26 -13
  32. data/lib/alexandria/book_providers/proxis.rb +9 -15
  33. data/lib/alexandria/book_providers/pseudomarc.rb +15 -27
  34. data/lib/alexandria/book_providers/renaud.rb +18 -9
  35. data/lib/alexandria/book_providers/siciliano.rb +8 -9
  36. data/lib/alexandria/book_providers/thalia.rb +6 -6
  37. data/lib/alexandria/book_providers/web.rb +2 -0
  38. data/lib/alexandria/book_providers/worldcat.rb +6 -7
  39. data/lib/alexandria/book_providers/z3950.rb +19 -10
  40. data/lib/alexandria/config.rb +4 -2
  41. data/lib/alexandria/console.rb +2 -0
  42. data/lib/alexandria/execution_queue.rb +2 -2
  43. data/lib/alexandria/export_library.rb +14 -18
  44. data/lib/alexandria/import_library.rb +8 -16
  45. data/lib/alexandria/import_library_csv.rb +5 -52
  46. data/lib/alexandria/logging.rb +4 -6
  47. data/lib/alexandria/models/book.rb +2 -0
  48. data/lib/alexandria/models/library.rb +10 -20
  49. data/lib/alexandria/net.rb +2 -0
  50. data/lib/alexandria/preferences.rb +10 -14
  51. data/lib/alexandria/scanners.rb +2 -0
  52. data/lib/alexandria/scanners/cuecat.rb +4 -2
  53. data/lib/alexandria/scanners/keyboard.rb +2 -0
  54. data/lib/alexandria/smart_library.rb +4 -3
  55. data/lib/alexandria/ui.rb +2 -0
  56. data/lib/alexandria/ui/builder_base.rb +2 -0
  57. data/lib/alexandria/ui/callbacks.rb +8 -12
  58. data/lib/alexandria/ui/columns.rb +2 -0
  59. data/lib/alexandria/ui/completion_models.rb +2 -0
  60. data/lib/alexandria/ui/dialogs/about_dialog.rb +3 -1
  61. data/lib/alexandria/ui/dialogs/acquire_dialog.rb +11 -17
  62. data/lib/alexandria/ui/dialogs/alert_dialog.rb +2 -0
  63. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -2
  64. data/lib/alexandria/ui/dialogs/barcode_animation.rb +2 -0
  65. data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +5 -9
  66. data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +3 -3
  67. data/lib/alexandria/ui/dialogs/export_dialog.rb +3 -3
  68. data/lib/alexandria/ui/dialogs/import_dialog.rb +2 -2
  69. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +6 -4
  70. data/lib/alexandria/ui/dialogs/new_book_dialog.rb +22 -31
  71. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +3 -3
  72. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +3 -3
  73. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +8 -18
  74. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +2 -0
  75. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +4 -6
  76. data/lib/alexandria/ui/dndable.rb +4 -2
  77. data/lib/alexandria/ui/icons.rb +3 -3
  78. data/lib/alexandria/ui/iconview.rb +3 -3
  79. data/lib/alexandria/ui/iconview_tooltips.rb +4 -6
  80. data/lib/alexandria/ui/init.rb +2 -0
  81. data/lib/alexandria/ui/libraries_combo.rb +2 -0
  82. data/lib/alexandria/ui/listview.rb +15 -12
  83. data/lib/alexandria/ui/main_app.rb +2 -0
  84. data/lib/alexandria/ui/multi_drag_treeview.rb +2 -0
  85. data/lib/alexandria/ui/sidepane.rb +8 -6
  86. data/lib/alexandria/ui/sound.rb +2 -0
  87. data/lib/alexandria/ui/ui_manager.rb +37 -43
  88. data/lib/alexandria/undo_manager.rb +2 -0
  89. data/lib/alexandria/version.rb +5 -3
  90. data/lib/alexandria/web_themes.rb +2 -0
  91. data/spec/alexandria/book_providers_spec.rb +12 -49
  92. data/spec/alexandria/book_spec.rb +4 -2
  93. data/spec/alexandria/library_spec.rb +2 -0
  94. data/spec/alexandria/preferences_spec.rb +2 -0
  95. data/spec/alexandria/scanners/cuecat_spec.rb +2 -0
  96. data/spec/alexandria/smart_library_spec.rb +3 -1
  97. data/spec/alexandria/ui/dialogs_spec.rb +2 -0
  98. data/spec/alexandria/ui/iconview_spec.rb +2 -0
  99. data/spec/alexandria/ui/main_app_spec.rb +2 -0
  100. data/spec/alexandria/ui/sidepane_spec.rb +2 -0
  101. data/spec/alexandria/ui/sound_spec.rb +2 -0
  102. data/spec/alexandria/ui/ui_manager_spec.rb +2 -0
  103. data/spec/alexandria/ui/ui_utilities_spec.rb +2 -0
  104. data/spec/alexandria/utilities_spec.rb +2 -0
  105. data/spec/spec_helper.rb +2 -0
  106. data/tasks/dogtail.rake +2 -0
  107. data/tasks/setup.rb +3 -1
  108. data/tasks/spec.rake +2 -0
  109. data/util/rake/fileinstall.rb +6 -12
  110. data/util/rake/gettextgenerate.rb +9 -64
  111. data/util/rake/omfgenerate.rb +3 -3
  112. metadata +21 -37
  113. data/INSTALL.rdoc +0 -148
  114. data/lib/alexandria/book_providers/bol_it.rb +0 -160
  115. data/lib/alexandria/book_providers/ibs_it.rb +0 -147
  116. data/lib/alexandria/book_providers/webster_it.rb +0 -167
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2007 Cathal Mc Ginley
3
5
  # Copyright (C) 2011, 2016 Matijs van Zuijlen
@@ -26,7 +28,6 @@ require 'alexandria/ui/dialogs/barcode_animation'
26
28
 
27
29
  module Alexandria
28
30
  module UI
29
- require 'thread'
30
31
  require 'monitor'
31
32
 
32
33
  # assists in turning on progress bar when searching
@@ -64,9 +65,7 @@ module Alexandria
64
65
  @block = block
65
66
 
66
67
  libraries = Libraries.instance.all_regular_libraries
67
- if selected_library.is_a?(SmartLibrary)
68
- selected_library = libraries.first
69
- end
68
+ selected_library = libraries.first if selected_library.is_a?(SmartLibrary)
70
69
  @combo_libraries.populate_with_libraries(libraries,
71
70
  selected_library)
72
71
 
@@ -208,9 +207,7 @@ module Alexandria
208
207
  book = result[0]
209
208
  cover_uri = result[1]
210
209
 
211
- unless cover_uri.nil?
212
- library.save_cover(book, cover_uri)
213
- end
210
+ library.save_cover(book, cover_uri) unless cover_uri.nil?
214
211
  books << book
215
212
  library << book
216
213
  library.save(book)
@@ -320,8 +317,11 @@ module Alexandria
320
317
 
321
318
  def start_search
322
319
  @search_thread_counter.synchronize do
323
- if @search_thread_counter.count.zero?
324
- @search_thread_counter.new_search
320
+ first_search = @search_thread_counter.count.zero?
321
+
322
+ @search_thread_counter.new_search
323
+
324
+ if first_search
325
325
  @progress_bar_thread = Thread.new do
326
326
  notify_start_add_by_isbn
327
327
  Alexandria::BookProviders.instance.add_observer(self)
@@ -333,8 +333,6 @@ module Alexandria
333
333
  notify_end_add_by_isbn
334
334
  Alexandria::BookProviders.instance.add_observer(self)
335
335
  end
336
- else
337
- @search_thread_counter.new_search
338
336
  end
339
337
  end
340
338
  end
@@ -403,13 +401,11 @@ module Alexandria
403
401
  end
404
402
  end
405
403
  end
406
-
407
404
  rescue StandardError => err
408
405
  log.error {
409
406
  "Failed to load cover image icon: #{err.message}"
410
407
  }
411
408
  log << err if log.error?
412
-
413
409
  end
414
410
  end
415
411
  end
@@ -443,7 +439,7 @@ module Alexandria
443
439
  @scan_area.grab_focus
444
440
  end
445
441
  @scan_area.signal_connect('focus-in-event') do |_widget, _event|
446
- @barcode_label.label = _('%s _Barcode Scanner Ready' % _(@scanner.display_name))
442
+ @barcode_label.label = _(format('%s _Barcode Scanner Ready', _(@scanner.display_name)))
447
443
  @scanner_buffer = ''
448
444
  begin
449
445
  @animation.set_active
@@ -601,9 +597,7 @@ module Alexandria
601
597
  @barcodes_treeview.append_column(col)
602
598
 
603
599
  @barcodes_treeview.model.signal_connect('row-deleted') do |model, _path|
604
- unless model.iter_first
605
- @add_button.sensitive = false
606
- end
600
+ @add_button.sensitive = false unless model.iter_first
607
601
  end
608
602
  end
609
603
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  #
3
5
  # Alexandria is free software; you can redistribute it and/or
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2007 Joseph Method
2
4
  #
3
5
  # Alexandria is free software; you can redistribute it and/or
@@ -21,8 +23,14 @@ module Alexandria
21
23
  # be used for on_load library conversions.
22
24
  class BadIsbnsDialog < Gtk::MessageDialog
23
25
  def initialize(parent, message = nil, list = nil)
24
- message = _("There's a problem") unless message
25
- super(parent, Gtk::Dialog::MODAL, Gtk::MessageDialog::WARNING, Gtk::MessageDialog::BUTTONS_CLOSE, message)
26
+ message ||= _("There's a problem")
27
+
28
+ super(parent,
29
+ Gtk::Dialog::MODAL,
30
+ Gtk::MessageDialog::WARNING,
31
+ Gtk::MessageDialog::BUTTONS_CLOSE,
32
+ message)
33
+
26
34
  isbn_container = Gtk::Box.new :horizontal
27
35
  the_vbox = children.first
28
36
  the_vbox.pack_start(isbn_container)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- ruby -*-
2
4
  #--
3
5
  # Copyright (C) 2011 Cathal Mc Ginley
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2016 Matijs van Zuijlen
3
5
  #
@@ -106,9 +108,7 @@ module Alexandria
106
108
  end
107
109
  @checkbutton_want.active = book.want?
108
110
 
109
- if (@checkbutton_own.active = book.own?)
110
- @checkbutton_want.inconsistent = true
111
- end
111
+ @checkbutton_want.inconsistent = true if (@checkbutton_own.active = book.own?)
112
112
  end
113
113
 
114
114
  private
@@ -178,9 +178,7 @@ module Alexandria
178
178
 
179
179
  FileUtils.rm_f(@cover_file) if @delete_cover_file
180
180
 
181
- if @original_cover_file
182
- FileUtils.rm_f(@original_cover_file)
183
- end
181
+ FileUtils.rm_f(@original_cover_file) if @original_cover_file
184
182
 
185
183
  @library.save(@book)
186
184
  # @on_close_cb.call(@book)
@@ -188,9 +186,7 @@ module Alexandria
188
186
  end
189
187
 
190
188
  def on_cancel
191
- if @original_cover_file
192
- FileUtils.mv(@original_cover_file, @cover_file)
193
- end
189
+ FileUtils.mv(@original_cover_file, @cover_file) if @original_cover_file
194
190
  @book_properties_dialog.destroy
195
191
  end
196
192
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2011, 2014, 2016 Matijs van Zuijlen
3
5
  #
@@ -360,9 +362,7 @@ module Alexandria
360
362
  @redd_date.sensitive = redd_yes
361
363
  if @setup_finished
362
364
  # don't do this when popping up the dialog for the first time
363
- if redd_yes && @redd_date.text.strip.empty?
364
- display_calendar_popup(@redd_date)
365
- end
365
+ display_calendar_popup(@redd_date) if redd_yes && @redd_date.text.strip.empty?
366
366
  end
367
367
  end
368
368
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2014, 2016 Matijs van Zuijlen
3
5
  #
@@ -136,9 +138,7 @@ module Alexandria
136
138
  private
137
139
 
138
140
  def on_export(format, theme)
139
- unless @library.respond_to?(format.message)
140
- raise NotImplementedError
141
- end
141
+ raise NotImplementedError unless @library.respond_to?(format.message)
142
142
  filename = self.filename
143
143
  if format.ext
144
144
  filename += '.' + format.ext if File.extname(filename).empty?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
5
  #
@@ -16,8 +18,6 @@
16
18
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
17
19
  # Fifth Floor, Boston, MA 02110-1301 USA.
18
20
 
19
- require 'thread'
20
-
21
21
  class Alexandria::ImportFilter
22
22
  def to_filefilter
23
23
  filefilter = Gtk::FileFilter.new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2007 Joseph Method
2
4
  #
3
5
  # Alexandria is free software; you can redistribute it and/or
@@ -23,8 +25,8 @@ module Alexandria
23
25
 
24
26
  def initialize(parent, library, book)
25
27
  super(parent,
26
- _("The book '%s' already exists in '%s'. Would you like " \
27
- 'to replace it?') % [book.title, library.name],
28
+ format(_("The book '%s' already exists in '%s'. Would you like " \
29
+ 'to replace it?'), book.title, library.name),
28
30
  Gtk::Stock::DIALOG_QUESTION,
29
31
  [[_('_Skip'), :cancel],
30
32
  [_('_Replace'), :ok]],
@@ -58,8 +60,8 @@ module Alexandria
58
60
  # Deleting books.
59
61
  else
60
62
  message = if books.length == 1
61
- _("Are you sure you want to delete '%s' " \
62
- "from '%s'?") % [books.first.title, library.name]
63
+ format(_("Are you sure you want to delete '%s' " \
64
+ "from '%s'?"), books.first.title, library.name)
63
65
  else
64
66
  _('Are you sure you want to delete the ' \
65
67
  "selected books from '%s'?") % library.name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2011, 2015, 2016 Matijs van Zuijlen
3
5
  #
@@ -76,9 +78,7 @@ module Alexandria
76
78
 
77
79
  def setup_dialog_gui
78
80
  libraries = Libraries.instance.all_regular_libraries
79
- if @selected_library.is_a?(SmartLibrary)
80
- @selected_library = libraries.first
81
- end
81
+ @selected_library = libraries.first if @selected_library.is_a?(SmartLibrary)
82
82
  @combo_libraries.populate_with_libraries(libraries,
83
83
  @selected_library)
84
84
 
@@ -223,7 +223,7 @@ module Alexandria
223
223
  if pixbuf.width > 1
224
224
  iter = @treeview_results.model.get_iter(key.to_s)
225
225
  unless @treeview_results.model.iter_is_valid?(iter)
226
- raise 'Iter is invalid! %s' % iter
226
+ raise format('Iter is invalid! %s', iter)
227
227
  end
228
228
  iter[2] = pixbuf # I bet you this is it!
229
229
  end
@@ -270,15 +270,16 @@ module Alexandria
270
270
  criterion = @entry_search.text.strip
271
271
  @treeview_results.model.clear
272
272
  log.info {
273
- 'TreeStore Model: %s columns; ref_counts: %s' %
274
- [@treeview_results.model.n_columns, @treeview_results.model.ref_count]
273
+ format('TreeStore Model: %s columns; ref_counts: %s',
274
+ @treeview_results.model.n_columns,
275
+ @treeview_results.model.ref_count)
275
276
  }
276
277
 
277
278
  @find_error = nil
278
279
  @results = nil
279
280
 
280
- @find_thread.kill if @find_thread
281
- @image_thread.kill if @image_thread
281
+ @find_thread&.kill
282
+ @image_thread&.kill
282
283
 
283
284
  notify_start_add_by_isbn
284
285
  GLib::Idle.add do
@@ -311,17 +312,14 @@ module Alexandria
311
312
  false
312
313
  elsif @results
313
314
  log.info { "Got results: #{@results[0]}..." }
314
- @results.each do |book, _cover|
315
- s = _('%s, by %s') % [book.title,
316
- book.authors.join(', ')]
315
+ @results.each_key do |book|
316
+ s = format(_('%s, by %s'), book.title, book.authors.join(', '))
317
317
  similar_books = @results.find { |book2, _cover2|
318
318
  (book.title == book2.title) &&
319
319
  (book.authors == book2.authors)
320
320
  }
321
- if similar_books.length > 1
322
- s += " (#{book.edition}, #{book.publisher})"
323
- end
324
- log.info { 'Copying %s into tree view.' % book.title }
321
+ s += " (#{book.edition}, #{book.publisher})" if similar_books.length > 1
322
+ log.info { format('Copying %s into tree view.', book.title) }
325
323
  iter = @treeview_results.model.append
326
324
  iter[0] = s
327
325
  iter[1] = book.ident
@@ -366,17 +364,13 @@ module Alexandria
366
364
  tmp = ((32 + tmp.length * 3 / 4).to_i.chr << tmp).unpack('u')[0]
367
365
  tmp.chomp!("\000")
368
366
  entry.text = tmp.gsub!(/./) { |c| (c[0] ^ 67).chr }
369
- if entry.text.count('^ -~') > 0
370
- entry.text = 'Bad scan result'
371
- end
367
+ entry.text = 'Bad scan result' if entry.text.count('^ -~') > 0
372
368
  end
373
369
  end
374
370
 
375
371
  def on_results_button_press_event(_widget, event)
376
372
  # double left click
377
- if (event.event_type == :'2button_press') && (event.button == 1)
378
- on_add
379
- end
373
+ on_add if (event.event_type == :'2button_press') && (event.button == 1)
380
374
  end
381
375
 
382
376
  def add_single_book_by_isbn(library, is_new)
@@ -456,9 +450,7 @@ module Alexandria
456
450
  end
457
451
 
458
452
  def add_book_to_library(library, book, cover_uri)
459
- unless cover_uri.nil?
460
- library.save_cover(book, cover_uri)
461
- end
453
+ library.save_cover(book, cover_uri) unless cover_uri.nil?
462
454
  library << book
463
455
  library.save(book)
464
456
  end
@@ -491,8 +483,8 @@ module Alexandria
491
483
 
492
484
  def on_add
493
485
  return unless @button_add.sensitive?
494
- @find_thread.kill if @find_thread
495
- @image_thread.kill if @image_thread
486
+ @find_thread&.kill
487
+ @image_thread&.kill
496
488
 
497
489
  begin
498
490
  libraries = Libraries.instance.all_libraries
@@ -510,7 +502,6 @@ module Alexandria
510
502
 
511
503
  # Do not destroy if there is no addition.
512
504
  # return unless book_was_added
513
-
514
505
  rescue => e
515
506
  ErrorDialog.new(@parent, _("Couldn't add the book"), e.message)
516
507
  end
@@ -518,8 +509,8 @@ module Alexandria
518
509
  end
519
510
 
520
511
  def on_cancel
521
- @find_thread.kill if @find_thread
522
- @image_thread.kill if @image_thread
512
+ @find_thread&.kill
513
+ @image_thread&.kill
523
514
  @new_book_dialog.destroy
524
515
  end
525
516
 
@@ -614,8 +605,8 @@ module Alexandria
614
605
  isbn13 = Library.canonicalise_ean(isbn)
615
606
  puts isbn13
616
607
  if (book = library.find { |bk| bk.isbn == isbn13 })
617
- raise DuplicateBookException, _("'%s' already exists in '%s' (titled '%s').") % \
618
- [isbn, library.name, book.title.sub('&', '&amp;')]
608
+ raise DuplicateBookException, format(_("'%s' already exists in '%s' (titled '%s')."),
609
+ isbn, library.name, book.title.sub('&', '&amp;'))
619
610
  end
620
611
  true
621
612
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2011, 2014 Matijs van Zuijlen
3
5
  #
@@ -84,9 +86,7 @@ module Alexandria
84
86
  ary = @library.select { |book|
85
87
  book.ident == @entry_isbn.text
86
88
  }
87
- unless ary.empty?
88
- raise AddError, _('The EAN/ISBN you provided is already used in this library.')
89
- end
89
+ raise AddError, _('The EAN/ISBN you provided is already used in this library.') unless ary.empty?
90
90
  isbn = begin
91
91
  Library.canonicalise_isbn(@entry_isbn.text)
92
92
  rescue Alexandria::Library::InvalidISBNError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2015, 2016 Matijs van Zuijlen
3
5
  #
@@ -64,9 +66,7 @@ module Alexandria
64
66
  def smart_library_base_name(rules)
65
67
  if rules.length == 1
66
68
  value = rules.first.value
67
- if value.is_a?(String) && !value.strip.empty?
68
- return value
69
- end
69
+ return value if value.is_a?(String) && !value.strip.empty?
70
70
  end
71
71
  end
72
72
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
5
  #
@@ -296,9 +298,7 @@ module Alexandria
296
298
  @checkbutton_prov_advanced.sensitive = false
297
299
  else
298
300
  view_advanced = Preferences.instance.view_advanced_settings
299
- if view_advanced
300
- @checkbutton_prov_advanced.active = true
301
- end
301
+ @checkbutton_prov_advanced.active = true if view_advanced
302
302
  end
303
303
 
304
304
  setup_enable_disable_popup
@@ -332,9 +332,7 @@ module Alexandria
332
332
  iter = @scanner_device_model.append
333
333
  iter[0] = scanner.display_name
334
334
  iter[1] = scanner.name
335
- if chosen_scanner_name == scanner.name
336
- @scanner_device_type.active = index
337
- end
335
+ @scanner_device_type.active = index if chosen_scanner_name == scanner.name
338
336
  index += 1
339
337
  end
340
338
 
@@ -409,9 +407,7 @@ module Alexandria
409
407
 
410
408
  def on_provider_setup
411
409
  provider = selected_provider
412
- unless prefs_empty(provider.prefs)
413
- ProviderPreferencesDialog.new(@preferences_dialog, provider)
414
- end
410
+ ProviderPreferencesDialog.new(@preferences_dialog, provider) unless prefs_empty(provider.prefs)
415
411
  end
416
412
 
417
413
  def on_provider_up
@@ -449,9 +445,7 @@ module Alexandria
449
445
 
450
446
  def on_scanner_device_type(_combo)
451
447
  iter = @scanner_device_type.active_iter
452
- if iter && iter[1]
453
- Preferences.instance.barcode_scanner = iter[1]
454
- end
448
+ Preferences.instance.barcode_scanner = iter[1] if iter && iter[1]
455
449
  end
456
450
 
457
451
  def on_use_scanning_sound(checkbox)
@@ -496,9 +490,7 @@ module Alexandria
496
490
 
497
491
  def on_providers_button_press_event(_widget, event)
498
492
  # double left click
499
- if (event.event_type == :'2button_press') && (event.button == 1)
500
- on_provider_setup
501
- end
493
+ on_provider_setup if (event.event_type == :'2button_press') && (event.button == 1)
502
494
  end
503
495
 
504
496
  def on_close
@@ -531,9 +523,7 @@ module Alexandria
531
523
 
532
524
  def selected_provider
533
525
  iter = @treeview_providers.selection.selected
534
- unless iter.nil?
535
- BookProviders.find { |x| x.name == iter[1] }
536
- end
526
+ BookProviders.find { |x| x.name == iter[1] } unless iter.nil?
537
527
  end
538
528
 
539
529
  def adjust_selected_provider(prov)