alexandria-book-collection-manager 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -25
  3. data/.rubocop_todo.yml +87 -67
  4. data/CHANGELOG.md +12 -1
  5. data/Gemfile +4 -3
  6. data/README.md +16 -6
  7. data/Rakefile +71 -72
  8. data/alexandria-book-collection-manager.gemspec +44 -44
  9. data/bin/alexandria +12 -12
  10. data/lib/alexandria.rb +22 -22
  11. data/lib/alexandria/about.rb +50 -50
  12. data/lib/alexandria/book_providers.rb +50 -50
  13. data/lib/alexandria/book_providers/adlibris.rb +28 -44
  14. data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
  15. data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
  16. data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
  17. data/lib/alexandria/book_providers/douban.rb +21 -37
  18. data/lib/alexandria/book_providers/proxis.rb +24 -24
  19. data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
  20. data/lib/alexandria/book_providers/renaud.rb +44 -57
  21. data/lib/alexandria/book_providers/siciliano.rb +39 -39
  22. data/lib/alexandria/book_providers/thalia.rb +33 -33
  23. data/lib/alexandria/book_providers/web.rb +5 -5
  24. data/lib/alexandria/book_providers/worldcat.rb +44 -69
  25. data/lib/alexandria/book_providers/z3950.rb +94 -109
  26. data/lib/alexandria/config.rb +1 -1
  27. data/lib/alexandria/console.rb +3 -3
  28. data/lib/alexandria/export_format.rb +8 -8
  29. data/lib/alexandria/export_library.rb +112 -113
  30. data/lib/alexandria/import_library.rb +45 -45
  31. data/lib/alexandria/import_library_csv.rb +30 -30
  32. data/lib/alexandria/library_collection.rb +4 -4
  33. data/lib/alexandria/library_sort_order.rb +1 -1
  34. data/lib/alexandria/library_store.rb +14 -14
  35. data/lib/alexandria/logging.rb +5 -5
  36. data/lib/alexandria/models/book.rb +1 -1
  37. data/lib/alexandria/models/library.rb +36 -36
  38. data/lib/alexandria/net.rb +5 -5
  39. data/lib/alexandria/preferences.rb +32 -32
  40. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
  41. data/lib/alexandria/scanners/keyboard.rb +5 -5
  42. data/lib/alexandria/smart_library.rb +53 -53
  43. data/lib/alexandria/ui.rb +15 -15
  44. data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
  45. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
  46. data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
  47. data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
  48. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
  49. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
  50. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
  51. data/lib/alexandria/ui/builder_base.rb +1 -1
  52. data/lib/alexandria/ui/callbacks.rb +95 -91
  53. data/lib/alexandria/ui/completion_models.rb +7 -21
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  56. data/lib/alexandria/ui/dndable.rb +7 -7
  57. data/lib/alexandria/ui/error_dialog.rb +25 -0
  58. data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
  59. data/lib/alexandria/ui/icons.rb +6 -6
  60. data/lib/alexandria/ui/iconview.rb +7 -7
  61. data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
  62. data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
  63. data/lib/alexandria/ui/init.rb +16 -29
  64. data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
  65. data/lib/alexandria/ui/libraries_combo.rb +7 -7
  66. data/lib/alexandria/ui/listview.rb +40 -40
  67. data/lib/alexandria/ui/main_app.rb +22 -24
  68. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  69. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
  70. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
  71. data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
  72. data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
  73. data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
  74. data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
  75. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
  76. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  77. data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
  78. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
  79. data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
  80. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
  81. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
  82. data/lib/alexandria/ui/sound.rb +8 -8
  83. data/lib/alexandria/ui/ui_manager.rb +136 -135
  84. data/lib/alexandria/version.rb +4 -19
  85. data/lib/alexandria/web_themes.rb +8 -8
  86. data/po/cs.po +97 -97
  87. data/po/cy.po +97 -97
  88. data/po/de.po +97 -97
  89. data/po/el.po +97 -97
  90. data/po/es.po +97 -97
  91. data/po/fr.po +97 -97
  92. data/po/ga.po +97 -97
  93. data/po/gl.po +97 -97
  94. data/po/it.po +97 -97
  95. data/po/ja.po +97 -97
  96. data/po/mk.po +97 -97
  97. data/po/nb.po +97 -97
  98. data/po/nl.po +97 -97
  99. data/po/pl.po +97 -97
  100. data/po/pt.po +97 -97
  101. data/po/pt_BR.po +97 -97
  102. data/po/ru.po +97 -97
  103. data/po/sk.po +97 -97
  104. data/po/sv.po +97 -97
  105. data/po/uk.po +97 -97
  106. data/po/zh_TW.po +97 -97
  107. data/schemas/alexandria.schemas +24 -2
  108. data/spec/alexandria/book_providers_spec.rb +65 -82
  109. data/spec/alexandria/book_spec.rb +12 -10
  110. data/spec/alexandria/console_spec.rb +9 -9
  111. data/spec/alexandria/export_library_spec.rb +31 -31
  112. data/spec/alexandria/library_spec.rb +86 -86
  113. data/spec/alexandria/library_store_spec.rb +8 -8
  114. data/spec/alexandria/preferences_spec.rb +18 -17
  115. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  116. data/spec/alexandria/smart_library_spec.rb +15 -15
  117. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  118. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  119. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  120. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  121. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  122. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  123. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  124. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  125. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  126. data/spec/alexandria/ui/iconview_spec.rb +7 -21
  127. data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
  128. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  129. data/spec/alexandria/ui/main_app_spec.rb +6 -6
  130. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  131. data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
  132. data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
  133. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
  134. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  135. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
  136. data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
  137. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  138. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  139. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
  140. data/spec/alexandria/ui/sound_spec.rb +2 -2
  141. data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
  142. data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
  143. data/spec/alexandria/utilities_spec.rb +6 -6
  144. data/spec/end_to_end/basic_run_spec.rb +24 -36
  145. data/spec/spec_helper.rb +9 -9
  146. data/tasks/dogtail.rake +1 -1
  147. data/tasks/setup.rb +2 -2
  148. data/tasks/spec.rake +11 -11
  149. data/util/rake/fileinstall.rb +25 -25
  150. data/util/rake/gettextgenerate.rb +7 -7
  151. data/util/rake/omfgenerate.rb +7 -7
  152. metadata +59 -33
  153. data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
  154. data/spec/alexandria/ui/dialogs_spec.rb +0 -162
  155. data/spec/alexandria/ui/sidepane_spec.rb +0 -29
@@ -20,64 +20,64 @@
20
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
21
21
 
22
22
  module Alexandria
23
- TITLE = 'Alexandria'
24
- TEXTDOMAIN = 'alexandria'
23
+ TITLE = "Alexandria"
24
+ TEXTDOMAIN = "alexandria"
25
25
  extend GetText
26
- bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
27
- DESCRIPTION = _('A program to help you manage your book collection.')
26
+ bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
27
+ DESCRIPTION = _("A program to help you manage your book collection.")
28
28
  COPYRIGHT = "Copyright (C) 2004-2006 Laurent Sansonetti\n" \
29
- 'Copyright (C) 2007-2010,2014,2015 Alexandria Contributors'
29
+ "Copyright (C) 2007-2010,2014,2015 Alexandria Contributors"
30
30
  AUTHORS = [
31
- 'Alexander McCormmach <alexander@tunicate.org>',
32
- 'Aymeric Nys <aymeric@nnx.com>',
33
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org>',
34
- 'Claudio Belotti <bel8@lilik.it>',
35
- 'Constantine Evans <cevans@costinet.org>',
36
- 'Dafydd Harries <daf@muse.19inch.net>',
37
- 'Javier Fernandez-Sanguino Pena <jfs@debian.org>',
38
- 'Joseph Method <tristil@gmail.com>',
39
- 'Kevin Schultz <schultkl@ieee.org>',
40
- 'Laurent Sansonetti <lrz@gnome.org>',
41
- 'Marco Costantini <costanti@science.unitn.it>',
42
- 'Mathieu Leduc-Hamel <arrak@arrak.org>',
43
- 'Matijs van Zuijlen <matijs@matijs.net>',
44
- 'Owain Evans <o.evans@gmail.com>',
45
- 'Pascal Terjan <pterjan@linuxfr.org>',
46
- 'Rene Samselnig <sandman@sdm-net.org>',
47
- 'Robby Stephenson <robby@periapsis.org>',
48
- 'Sun Ning <classicning@gmail.com>',
49
- 'Takayuki Kusano <AE5T-KSN@asahi-net.or.jp>',
50
- 'Timothy Malone <timothy.malone@gmail.com>',
51
- 'Zachary P. Landau <kapheine@hypa.net>'
31
+ "Alexander McCormmach <alexander@tunicate.org>",
32
+ "Aymeric Nys <aymeric@nnx.com>",
33
+ "Cathal Mc Ginley <cathal.alexandria@gnostai.org>",
34
+ "Claudio Belotti <bel8@lilik.it>",
35
+ "Constantine Evans <cevans@costinet.org>",
36
+ "Dafydd Harries <daf@muse.19inch.net>",
37
+ "Javier Fernandez-Sanguino Pena <jfs@debian.org>",
38
+ "Joseph Method <tristil@gmail.com>",
39
+ "Kevin Schultz <schultkl@ieee.org>",
40
+ "Laurent Sansonetti <lrz@gnome.org>",
41
+ "Marco Costantini <costanti@science.unitn.it>",
42
+ "Mathieu Leduc-Hamel <arrak@arrak.org>",
43
+ "Matijs van Zuijlen <matijs@matijs.net>",
44
+ "Owain Evans <o.evans@gmail.com>",
45
+ "Pascal Terjan <pterjan@linuxfr.org>",
46
+ "Rene Samselnig <sandman@sdm-net.org>",
47
+ "Robby Stephenson <robby@periapsis.org>",
48
+ "Sun Ning <classicning@gmail.com>",
49
+ "Takayuki Kusano <AE5T-KSN@asahi-net.or.jp>",
50
+ "Timothy Malone <timothy.malone@gmail.com>",
51
+ "Zachary P. Landau <kapheine@hypa.net>"
52
52
  ].freeze
53
53
  DOCUMENTERS = [
54
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org>',
55
- 'Liam Davison <registrations@liamjdavison.info>'
54
+ "Cathal Mc Ginley <cathal.alexandria@gnostai.org>",
55
+ "Liam Davison <registrations@liamjdavison.info>"
56
56
  ].freeze
57
57
  TRANSLATORS = [
58
- 'Adrián Chaves Fernández <adriyetichaves@gmail.com> (gl)',
59
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org> (ga)',
60
- 'CHIKAMA Masaki <masaki.chikama@gmail.com> (ja)',
61
- 'Dafydd Harries <daf@muse.19inch.net> (cy)',
62
- 'Damjan Dimitrioski <damjandimitrioski@gmail.com> (mk)',
63
- 'Giacomo Margarito <giacomomargarito@gmail.com> (it)',
64
- 'Jack Myrseh <jack@enkom.no> (nb)',
65
- 'Joachim Breitner <mail@joachim-breitner.de> (de)',
66
- 'José Ling <jlgdot369@gmail.com> (zh_TW)',
67
- 'Lennart Karssen <lennart@karssen.org> (nl)',
68
- 'Lígia Moreira <ligia.moreira@netvisao.pt> (fr, pt, pt_BR)',
69
- 'Martin Karlsson <martinkarlsson81@hotmail.com> (sv)',
70
- 'Michael Kotsarinis <mkotsari1@pre.forthnet.gr> (el)',
71
- 'Miguel Ángel García <magmax@ieee.org> (es)',
72
- 'Peter Kováč <kovac.peter@fotopriestor.sk> (sk)',
73
- 'Petr Vanek <vanous@penguin.cz> (cs)',
74
- 'Piotr Drąg <piotrdrag@gmail.com> (pl)',
75
- 'Serhij Dubyk <dubyk@library.lviv.ua> (uk)'
58
+ "Adrián Chaves Fernández <adriyetichaves@gmail.com> (gl)",
59
+ "Cathal Mc Ginley <cathal.alexandria@gnostai.org> (ga)",
60
+ "CHIKAMA Masaki <masaki.chikama@gmail.com> (ja)",
61
+ "Dafydd Harries <daf@muse.19inch.net> (cy)",
62
+ "Damjan Dimitrioski <damjandimitrioski@gmail.com> (mk)",
63
+ "Giacomo Margarito <giacomomargarito@gmail.com> (it)",
64
+ "Jack Myrseh <jack@enkom.no> (nb)",
65
+ "Joachim Breitner <mail@joachim-breitner.de> (de)",
66
+ "José Ling <jlgdot369@gmail.com> (zh_TW)",
67
+ "Lennart Karssen <lennart@karssen.org> (nl)",
68
+ "Lígia Moreira <ligia.moreira@netvisao.pt> (fr, pt, pt_BR)",
69
+ "Martin Karlsson <martinkarlsson81@hotmail.com> (sv)",
70
+ "Michael Kotsarinis <mkotsari1@pre.forthnet.gr> (el)",
71
+ "Miguel Ángel García <magmax@ieee.org> (es)",
72
+ "Peter Kováč <kovac.peter@fotopriestor.sk> (sk)",
73
+ "Petr Vanek <vanous@penguin.cz> (cs)",
74
+ "Piotr Drąg <piotrdrag@gmail.com> (pl)",
75
+ "Serhij Dubyk <dubyk@library.lviv.ua> (uk)"
76
76
  ].freeze
77
77
  ARTISTS = [
78
- 'Andreas Nilsson <nisses.mail@home.se>',
79
- 'Stefanie Dijoux <stefanie.dijoux@gmail.com>'
78
+ "Andreas Nilsson <nisses.mail@home.se>",
79
+ "Stefanie Dijoux <stefanie.dijoux@gmail.com>"
80
80
  ].freeze
81
- BUGREPORT_URL = 'http://www.github.com/mvz/alexandria-book-collection-manager/issues'
82
- WEBSITE_URL = 'http://www.github.com/mvz/alexandria-book-collection-manager'
81
+ BUGREPORT_URL = "http://www.github.com/mvz/alexandria-book-collection-manager/issues"
82
+ WEBSITE_URL = "http://www.github.com/mvz/alexandria-book-collection-manager"
83
83
  end
@@ -19,8 +19,8 @@
19
19
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
20
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
21
21
 
22
- require 'singleton'
23
- require 'observer'
22
+ require "singleton"
23
+ require "observer"
24
24
 
25
25
  module Alexandria
26
26
  # FIXME: Use delegation instead of inheritance.
@@ -29,7 +29,7 @@ module Alexandria
29
29
  include Singleton
30
30
  include Observable
31
31
  include GetText
32
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
32
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
33
33
 
34
34
  SEARCH_BY_ISBN, SEARCH_BY_TITLE, SEARCH_BY_AUTHORS,
35
35
  SEARCH_BY_KEYWORD = (0..3).to_a
@@ -47,9 +47,9 @@ module Alexandria
47
47
 
48
48
  begin
49
49
  factory = instance[factory_n]
50
- puts factory.fullname + ' lookup' if $DEBUG
50
+ puts factory.fullname + " lookup" if $DEBUG
51
51
  unless factory.enabled
52
- puts factory.fullname + ' disabled!, skipping...' if $DEBUG
52
+ puts factory.fullname + " disabled!, skipping..." if $DEBUG
53
53
  raise ProviderSkippedError
54
54
  end
55
55
  instance.changed
@@ -64,14 +64,14 @@ module Alexandria
64
64
  instance.notify_observers(:not_found, factory.fullname) # new
65
65
  raise NoResultsError
66
66
  else
67
- log.info { 'found at ' + factory.fullname }
67
+ log.info { "found at " + factory.fullname }
68
68
  instance.changed
69
69
  instance.notify_observers(:found, factory.fullname) # new
70
70
  return results
71
71
  end
72
- rescue StandardError => boom
73
- if boom.is_a? NoResultsError
74
- unless boom.instance_of? ProviderSkippedError
72
+ rescue StandardError => ex
73
+ if ex.is_a? NoResultsError
74
+ unless ex.instance_of? ProviderSkippedError
75
75
  instance.changed
76
76
  instance.notify_observers(:not_found, factory.fullname) # new
77
77
  Thread.new { sleep(0.5) }.join
@@ -80,38 +80,38 @@ module Alexandria
80
80
  instance.changed
81
81
  instance.notify_observers(:error, factory.fullname) # new
82
82
  Thread.new { sleep(0.5) }.join # hrmmmm, to make readable...
83
- trace = boom.backtrace.join("\n >")
84
- log.warn { "Provider #{factory.name} encountered error: #{boom.message} #{trace}" }
83
+ trace = ex.backtrace.join("\n >")
84
+ log.warn { "Provider #{factory.name} encountered error: #{ex.message} #{trace}" }
85
85
  end
86
86
  if last == factory
87
87
  log.warn { "Error while searching #{criterion}" }
88
- message = case boom
88
+ message = case ex
89
89
  when Timeout::Error
90
90
  _("Couldn't reach the provider '%s': timeout " \
91
- 'expired.') % factory.name
91
+ "expired.") % factory.name
92
92
 
93
93
  when SocketError
94
94
  format(_("Couldn't reach the provider '%s': socket " \
95
- 'error (%s).'), factory.name, boom.message)
95
+ "error (%s)."), factory.name, ex.message)
96
96
 
97
97
  when NoResultsError
98
- _('No results were found. Make sure your ' \
99
- 'search criterion is spelled correctly, and ' \
100
- 'try again.')
98
+ _("No results were found. Make sure your " \
99
+ "search criterion is spelled correctly, and " \
100
+ "try again.")
101
101
 
102
102
  when ProviderSkippedError
103
- _('No results were found. Make sure your ' \
104
- 'search criterion is spelled correctly, and ' \
105
- 'try again.')
103
+ _("No results were found. Make sure your " \
104
+ "search criterion is spelled correctly, and " \
105
+ "try again.")
106
106
 
107
107
  when TooManyResultsError
108
- _('Too many results for that search.')
108
+ _("Too many results for that search.")
109
109
 
110
110
  when InvalidSearchTypeError
111
- _('Invalid search type.')
111
+ _("Invalid search type.")
112
112
 
113
113
  else
114
- boom.message
114
+ ex.message
115
115
  end
116
116
  puts "raising empty error #{message}"
117
117
  raise SearchEmptyError, message
@@ -152,7 +152,7 @@ module Alexandria
152
152
  end
153
153
 
154
154
  def new_value=(new_value)
155
- message = @provider.variable_name(self) + '='
155
+ message = @provider.variable_name(self) + "="
156
156
  Alexandria::Preferences.instance.send(message,
157
157
  new_value)
158
158
  self.value = new_value
@@ -189,7 +189,7 @@ module Alexandria
189
189
  each do |var|
190
190
  message = @provider.variable_name(var)
191
191
  val = Alexandria::Preferences.instance.send(message)
192
- var.value = val unless val.nil? || ((val == '') && var.mandatory?)
192
+ var.value = val unless val.nil? || ((val == "") && var.mandatory?)
193
193
  end
194
194
  end
195
195
  end
@@ -203,27 +203,27 @@ module Alexandria
203
203
  @name = name
204
204
  @fullname = (fullname || name)
205
205
  @prefs = Preferences.new(self)
206
- @prefs.add('enabled', _('Enabled'), true, [true, false])
206
+ @prefs.add("enabled", _("Enabled"), true, [true, false])
207
207
  end
208
208
 
209
209
  def enabled
210
- @prefs['enabled']
210
+ @prefs["enabled"]
211
211
  end
212
212
 
213
213
  def toggle_enabled
214
214
  old_value = enabled
215
- @prefs.variable_named('enabled').new_value = !old_value
215
+ @prefs.variable_named("enabled").new_value = !old_value
216
216
  end
217
217
 
218
218
  def reinitialize(fullname)
219
- @name << '_' << fullname.hash.to_s
219
+ @name << "_" << fullname.hash.to_s
220
220
  @fullname = fullname
221
221
  prefs = Alexandria::Preferences.instance
222
222
  ary = prefs.abstract_providers
223
223
  ary ||= []
224
224
  ary << @name
225
225
  prefs.abstract_providers = ary
226
- message = variable_name('name') + '='
226
+ message = variable_name("name") + "="
227
227
  prefs.send(message, @fullname)
228
228
  end
229
229
 
@@ -241,7 +241,7 @@ module Alexandria
241
241
  name = variable_name(variable)
242
242
  prefs.remove_preference(name)
243
243
  end
244
- name = variable_name('name')
244
+ name = variable_name("name")
245
245
  prefs.remove_preference(name)
246
246
  prefs.save!
247
247
  end
@@ -255,7 +255,7 @@ module Alexandria
255
255
  else
256
256
  raise
257
257
  end
258
- @name.downcase + '_' + s
258
+ @name.downcase + "_" + s
259
259
  end
260
260
 
261
261
  def transport
@@ -289,24 +289,24 @@ module Alexandria
289
289
  unabstract
290
290
  end
291
291
 
292
- require 'alexandria/book_providers/douban' # only requires YAML
292
+ require "alexandria/book_providers/douban" # only requires YAML
293
293
 
294
294
  # require 'alexandria/book_providers/renaud'
295
- log.info { 'Not loading Renaud (provider not functional)' }
295
+ log.info { "Not loading Renaud (provider not functional)" }
296
296
 
297
297
  # Amazon AWS (Amazon Associates Web Services) provider, needs hpricot
298
- require 'alexandria/book_providers/amazon_aws'
298
+ require "alexandria/book_providers/amazon_aws"
299
299
 
300
300
  # Website based providers
301
- require 'alexandria/book_providers/adlibris'
302
- require 'alexandria/book_providers/barnes_and_noble'
303
- require 'alexandria/book_providers/proxis'
304
- require 'alexandria/book_providers/siciliano'
305
- require 'alexandria/book_providers/thalia'
306
- require 'alexandria/book_providers/worldcat'
301
+ require "alexandria/book_providers/adlibris"
302
+ require "alexandria/book_providers/barnes_and_noble"
303
+ require "alexandria/book_providers/proxis"
304
+ require "alexandria/book_providers/siciliano"
305
+ require "alexandria/book_providers/thalia"
306
+ require "alexandria/book_providers/worldcat"
307
307
 
308
308
  # Z39.50 based providers
309
- require 'alexandria/book_providers/z3950'
309
+ require "alexandria/book_providers/z3950"
310
310
 
311
311
  attr_reader :abstract_classes
312
312
 
@@ -345,11 +345,11 @@ module Alexandria
345
345
  md = /^(.+)_/.match(name)
346
346
  next unless md
347
347
 
348
- klass_name = md[1] + 'Provider'
348
+ klass_name = md[1] + "Provider"
349
349
  klass = @abstract_classes.find { |x| x.name.include?(klass_name) }
350
350
  next unless klass
351
351
 
352
- fullname = @prefs.send(name.downcase + '_name')
352
+ fullname = @prefs.send(name.downcase + "_name")
353
353
  next unless fullname
354
354
 
355
355
  instance = klass.new
@@ -385,17 +385,17 @@ module Alexandria
385
385
  unless priority.empty?
386
386
  changed = false
387
387
 
388
- if (ecs_index = priority.index('AmazonECS'))
389
- priority[ecs_index] = 'Amazon' # replace legacy "AmazonECS" name
388
+ if (ecs_index = priority.index("AmazonECS"))
389
+ priority[ecs_index] = "Amazon" # replace legacy "AmazonECS" name
390
390
  priority.uniq! # remove any other "Amazon" from the list
391
391
  changed = true
392
392
  end
393
- if (worldcat_index = priority.index('Worldcat'))
394
- priority[worldcat_index] = 'WorldCat'
393
+ if (worldcat_index = priority.index("Worldcat"))
394
+ priority[worldcat_index] = "WorldCat"
395
395
  changed = true
396
396
  end
397
- if (adlibris_index = priority.index('Adlibris'))
398
- priority[adlibris_index] = 'AdLibris'
397
+ if (adlibris_index = priority.index("Adlibris"))
398
+ priority[adlibris_index] = "AdLibris"
399
399
  changed = true
400
400
  end
401
401
  @prefs.providers_priority = priority if changed
@@ -1,24 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # -*- ruby -*-
3
+ # This file is part of Alexandria.
4
4
  #
5
- # Copyright (C) 2009 Cathal Mc Ginley
6
- # Copyright (C) 2014 Matijs van Zuijlen
7
- #
8
- # Alexandria is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU General Public License as
10
- # published by the Free Software Foundation; either version 2 of the
11
- # License, or (at your option) any later version.
12
- #
13
- # Alexandria is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- # General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public
19
- # License along with Alexandria; see the file COPYING. If not,
20
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
21
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
22
6
 
23
7
  # AdLibris Bokhandel AB http://www.adlibris.com/se/
24
8
  # Swedish online book store
@@ -27,23 +11,23 @@
27
11
  # modified to fit the structure of Alexandria book providers.
28
12
  # (26 Feb 2009)
29
13
 
30
- require 'cgi'
31
- require 'alexandria/book_providers/web'
14
+ require "cgi"
15
+ require "alexandria/book_providers/web"
32
16
 
33
17
  module Alexandria
34
18
  class BookProviders
35
19
  class AdLibrisProvider < WebsiteBasedProvider
36
20
  include Alexandria::Logging
37
21
 
38
- SITE = 'http://www.adlibris.com/se/'
22
+ SITE = "http://www.adlibris.com/se/"
39
23
 
40
24
  BASE_SEARCH_URL = "#{SITE}searchresult.aspx?search=advanced&%s=%s" \
41
- '&fromproduct=False' # type/term
25
+ "&fromproduct=False" # type/term
42
26
 
43
27
  PRODUCT_URL = "#{SITE}product.aspx?isbn=%s"
44
28
 
45
29
  def initialize
46
- super('AdLibris', 'AdLibris (Sweden)')
30
+ super("AdLibris", "AdLibris (Sweden)")
47
31
  prefs.read
48
32
  # @ent = HTMLEntities.new
49
33
  end
@@ -79,10 +63,10 @@ module Alexandria
79
63
  PRODUCT_URL % Library.canonicalise_isbn(search_term)
80
64
  else
81
65
  (search_type_code = {
82
- SEARCH_BY_AUTHORS => 'author',
83
- SEARCH_BY_TITLE => 'title',
84
- SEARCH_BY_KEYWORD => 'keyword'
85
- }[search_type]) || 'keyword'
66
+ SEARCH_BY_AUTHORS => "author",
67
+ SEARCH_BY_TITLE => "title",
68
+ SEARCH_BY_KEYWORD => "keyword"
69
+ }[search_type]) || "keyword"
86
70
  search_term_encoded = CGI.escape(search_term)
87
71
  format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
88
72
  end
@@ -106,11 +90,11 @@ module Alexandria
106
90
  search_hit = doc.search("div'searchResult")[0]
107
91
  return [] unless search_hit
108
92
 
109
- (search_hit / 'ul.ulSearch table').each do |t|
93
+ (search_hit / "ul.ulSearch table").each do |t|
110
94
  result = {}
111
- if (title_data = (t % 'div.divTitle'))
95
+ if (title_data = (t % "div.divTitle"))
112
96
  result[:title] = (title_data % :a).inner_text
113
- lookup_url = (title_data % :a)['href']
97
+ lookup_url = (title_data % :a)["href"]
114
98
  end
115
99
  result[:lookup_url] = "#{SITE}#{lookup_url}"
116
100
 
@@ -145,19 +129,19 @@ module Alexandria
145
129
  doc = html_to_doc(html)
146
130
  begin
147
131
  title = nil
148
- if (h1 = doc.at('div.productTitleFormat h1'))
132
+ if (h1 = doc.at("div.productTitleFormat h1"))
149
133
  title = text_of(h1)
150
134
  else
151
- raise NoResultsError, 'title not found on page'
135
+ raise NoResultsError, "title not found on page"
152
136
  end
153
137
 
154
- product = doc.at('div.product')
155
- ul_info = doc.at('ul.info') # NOTE, two of these
138
+ product = doc.at("div.product")
139
+ ul_info = doc.at("ul.info") # NOTE, two of these
156
140
 
157
- author_cells = ul_info.search('li.liAuthor') # css-like search
141
+ author_cells = ul_info.search("li.liAuthor") # css-like search
158
142
  authors = []
159
143
  author_cells.each do |li|
160
- author_name = text_of(li.search('h2 > a')[0])
144
+ author_name = text_of(li.search("h2 > a")[0])
161
145
 
162
146
  authors << author_name
163
147
  end
@@ -168,7 +152,7 @@ module Alexandria
168
152
  end
169
153
 
170
154
  binding = nil
171
- if (format = doc.search('div.productTitleFormat span').first)
155
+ if (format = doc.search("div.productTitleFormat span").first)
172
156
  binding = text_of(format)
173
157
  binding = Regexp.last_match[1] if binding =~ /\(([^\)]+)\)/
174
158
  end
@@ -186,7 +170,7 @@ module Alexandria
186
170
  isbn = isbn_td.inner_text
187
171
  next unless isbn =~ /[0-9x]{10,13}/i
188
172
 
189
- isbn.gsub(/(\n|\r)/, ' ')
173
+ isbn.gsub(/(\n|\r)/, " ")
190
174
  isbn = Regexp.last_match[1] if isbn =~ /:[\s]*([0-9x]+)/i
191
175
  isbns << isbn
192
176
  end
@@ -196,12 +180,12 @@ module Alexandria
196
180
  # cover
197
181
  image_url = nil
198
182
  if (cover_img = doc.search('span.imageWithShadow img[@id$="ProductImageNotLinked"]').first)
199
- image_url = if cover_img['src'] =~ /^http\:\/\//
200
- cover_img['src']
183
+ image_url = if %r{^http\://}.match?(cover_img["src"])
184
+ cover_img["src"]
201
185
  else
202
186
  "#{SITE}/#{cover_img['src']}" # HACK: use html base
203
187
  end
204
- if image_url =~ /noimage.gif$/
188
+ if /noimage.gif$/.match?(image_url)
205
189
  # no point downloading a "no image" graphic
206
190
  # Alexandria has its own generic book icon...
207
191
  image_url = nil
@@ -216,10 +200,10 @@ module Alexandria
216
200
  raise ex if ex.instance_of? NoResultsError
217
201
 
218
202
  trace = ex.backtrace.join("\n> ")
219
- log.warn {
220
- 'Failed parsing search results for AdLibris ' \
203
+ log.warn do
204
+ "Failed parsing search results for AdLibris " \
221
205
  "#{ex.message} #{trace}"
222
- }
206
+ end
223
207
  raise NoResultsError
224
208
  end
225
209
  end