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
  #--
2
4
  # Copyright (c) 2006 Herryanto Siatono, Pluit Solutions
3
5
  #
@@ -151,9 +153,7 @@ module Amazon
151
153
 
152
154
  # Return an array of Amazon::Element item objects.
153
155
  def items
154
- unless @items
155
- @items = (@doc / 'item').map { |item| Element.new(item) }
156
- end
156
+ @items ||= (@doc / 'item').map { |item| Element.new(item) }
157
157
  @items
158
158
  end
159
159
 
@@ -164,25 +164,19 @@ module Amazon
164
164
 
165
165
  # Return current page no if :item_page option is when initiating the request.
166
166
  def item_page
167
- unless @item_page
168
- @item_page = (@doc / 'itemsearchrequest/itempage').inner_html.to_i
169
- end
167
+ @item_page ||= (@doc / 'itemsearchrequest/itempage').inner_html.to_i
170
168
  @item_page
171
169
  end
172
170
 
173
171
  # Return total results.
174
172
  def total_results
175
- unless @total_results
176
- @total_results = (@doc / 'totalresults').inner_html.to_i
177
- end
173
+ @total_results ||= (@doc / 'totalresults').inner_html.to_i
178
174
  @total_results
179
175
  end
180
176
 
181
177
  # Return total pages.
182
178
  def total_pages
183
- unless @total_pages
184
- @total_pages = (@doc / 'totalpages').inner_html.to_i
185
- end
179
+ @total_pages ||= (@doc / 'totalpages').inner_html.to_i
186
180
  @total_pages
187
181
  end
188
182
  end
@@ -219,7 +213,9 @@ module Amazon
219
213
  end
220
214
 
221
215
  def self.camelize(s)
222
- s.to_s.gsub(/\/(.?)/) { '::' + Regexp.last_match[1].upcase }.gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
216
+ s.to_s.
217
+ gsub(/\/(.?)/) { '::' + Regexp.last_match[1].upcase }.
218
+ gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
223
219
  end
224
220
 
225
221
  def self.hmac_sha256(message, key)
@@ -398,7 +394,7 @@ module Amazon
398
394
  end
399
395
 
400
396
  def to_s
401
- elem.to_s if elem
397
+ elem&.to_s
402
398
  end
403
399
  end
404
400
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- ruby -*-
2
4
  #
3
5
  # Copyright (C) 2009 Cathal Mc Ginley
@@ -35,12 +37,12 @@ module Alexandria
35
37
  class BarnesAndNobleProvider < WebsiteBasedProvider
36
38
  include Alexandria::Logging
37
39
 
38
- SITE = 'http://www.barnesandnoble.com'.freeze
40
+ SITE = 'http://www.barnesandnoble.com'
39
41
 
40
- BASE_ISBN_SEARCH_URL = 'http://www.barnesandnoble.com/s/%s'.freeze
42
+ BASE_ISBN_SEARCH_URL = 'http://www.barnesandnoble.com/s/%s'
41
43
 
42
44
  BASE_SEARCH_URL = 'http://search.barnesandnoble.com/booksearch' \
43
- '/results.asp?%s=%s'.freeze # type, term
45
+ '/results.asp?%s=%s' # type, term
44
46
 
45
47
  def initialize
46
48
  super('BarnesAndNoble', 'BarnesAndNoble')
@@ -49,7 +51,7 @@ module Alexandria
49
51
  end
50
52
 
51
53
  def agent
52
- @agent = Alexandria::WWWAgent.new unless @agent
54
+ @agent ||= Alexandria::WWWAgent.new
53
55
  @agent
54
56
  end
55
57
 
@@ -67,9 +69,7 @@ module Alexandria
67
69
  when Net::HTTPSuccess then response
68
70
  when Net::HTTPRedirection then
69
71
  redirect = URI.parse response['Location']
70
- if redirect.relative?
71
- redirect = URI.parse(uri_str) + redirect
72
- end
72
+ redirect = URI.parse(uri_str) + redirect if redirect.relative?
73
73
  fetch_redirectly(redirect.to_s, (limit - 1))
74
74
  else
75
75
  response.error!
@@ -108,7 +108,7 @@ module Alexandria
108
108
  BASE_ISBN_SEARCH_URL % Library.canonicalise_ean(search_term) # isbn-13
109
109
  else
110
110
  search_term_encoded = CGI.escape(search_term)
111
- BASE_SEARCH_URL % [search_type_code, search_term_encoded]
111
+ format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
112
112
  end
113
113
  end
114
114
 
@@ -184,9 +184,7 @@ module Alexandria
184
184
 
185
185
  book_data[:binding] = ''
186
186
  selected_format = (doc / '#availableFormats li.selected a.tabTitle').first
187
- if selected_format
188
- book_data[:binding] = selected_format.inner_text
189
- end
187
+ book_data[:binding] = selected_format.inner_text if selected_format
190
188
 
191
189
  book = Book.new(book_data[:title], book_data[:authors],
192
190
  book_data[:isbn], book_data[:publisher],
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- ruby -*-
2
4
  #
3
5
  # Copyright (C) 2009 Cathal Mc Ginley
@@ -31,8 +33,8 @@ module Alexandria
31
33
  class DeaStoreProvider < WebsiteBasedProvider
32
34
  include Alexandria::Logging
33
35
 
34
- SITE = 'http://www.deastore.com'.freeze
35
- BASE_SEARCH_URL = "#{SITE}/search/italian_books/0/%s/%s".freeze # type/term
36
+ SITE = 'http://www.deastore.com'
37
+ BASE_SEARCH_URL = "#{SITE}/search/italian_books/0/%s/%s" # type/term
36
38
 
37
39
  def initialize
38
40
  super('DeaStore', 'DeaStore (Italy)')
@@ -98,7 +100,7 @@ module Alexandria
98
100
  CGI.escape(search_term)
99
101
  end
100
102
 
101
- uri = BASE_SEARCH_URL % [search_type_code, search_term_encoded]
103
+ uri = format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
102
104
  log.debug { uri }
103
105
  uri
104
106
  end
@@ -153,9 +155,7 @@ module Alexandria
153
155
  result[:url] = lookup_url
154
156
 
155
157
  publishers = (content / 'p.editore')
156
- unless publishers.empty?
157
- result[:publisher] = normalize(publishers.first.inner_text)
158
- end
158
+ result[:publisher] = normalize(publishers.first.inner_text) unless publishers.empty?
159
159
 
160
160
  book_search_results << result
161
161
  rescue => ex
@@ -176,15 +176,11 @@ module Alexandria
176
176
  # cover
177
177
  cover_link = nil
178
178
  cover_img = data / 'a/img'
179
- unless cover_img.empty?
180
- cover_link = cover_img.first['src']
181
- end
179
+ cover_link = cover_img.first['src'] unless cover_img.empty?
182
180
  # author(s)
183
181
  authors = []
184
182
  author_span = data % 'span.int_scheda[text()*=Autore]'
185
- unless author_span
186
- author_span = data % 'span.int_scheda[text()*=cura]' # editor
187
- end
183
+ author_span ||= data % 'span.int_scheda[text()*=cura]'
188
184
  if author_span
189
185
  author_links = author_span / 'a.info'
190
186
  authors = []
@@ -212,9 +208,7 @@ module Alexandria
212
208
  date_par = data % 'span.int_scheda[text()*=Data di pubblicazione]/..'
213
209
  date_par.inner_text =~ /:[\s]*([12][0-9]{3})[\s]*$/
214
210
  publish_year = nil
215
- if Regexp.last_match[1]
216
- publish_year = Regexp.last_match[1].to_i
217
- end
211
+ publish_year = Regexp.last_match[1].to_i if Regexp.last_match[1]
218
212
  isbn_spans = data / 'div.sotto/span.isbn'
219
213
  isbns = []
220
214
  isbn_spans.each do |span|
@@ -222,9 +216,7 @@ module Alexandria
222
216
  isbns << Regexp.last_match[1]
223
217
  end
224
218
  isbn = nil
225
- unless isbns.empty?
226
- isbn = Library.canonicalise_isbn(isbns.first)
227
- end
219
+ isbn = Library.canonicalise_isbn(isbns.first) unless isbns.empty?
228
220
  # Editore & Imprint : as publisher info above...
229
221
  # pages
230
222
  # page_par = data % 'span.int_scheda[text()*=Pagine]/..'
@@ -257,11 +249,11 @@ module Alexandria
257
249
  log.debug { "Cover Image URL:: #{image_url}" }
258
250
  end
259
251
  book = Book.new(title, authors, isbn, publisher, publish_year, binding)
260
- return [book, image_url]
252
+ [book, image_url]
261
253
  rescue => ex
262
254
  trace = ex.backtrace.join("\n> ")
263
255
  log.error { "Failed parsing DeaStore product page #{ex.message}\n#{trace}" }
264
- return nil
256
+ nil
265
257
  end
266
258
 
267
259
  def normalize(str)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- ruby -*-
2
4
  #
3
5
  # Copyright (C) 2009 Cathal Mc Ginley
@@ -32,8 +34,8 @@ module Alexandria
32
34
  class DoubanProvider < GenericProvider
33
35
  include Alexandria::Logging
34
36
 
35
- SITE = 'http://www.douban.com'.freeze
36
- BASE_URL = 'http://api.douban.com/book/subjects?q=%s&max-results=5&alt=json'.freeze
37
+ SITE = 'http://www.douban.com'
38
+ BASE_URL = 'http://api.douban.com/book/subjects?q=%s&max-results=5&alt=json'
37
39
 
38
40
  def initialize
39
41
  super('Douban', 'Douban (China)')
@@ -85,7 +87,7 @@ module Alexandria
85
87
  book_search_results = []
86
88
  begin
87
89
  # dbresult = JSON.parse(response)
88
- dbresult = YAML.load(json2yaml(response))
90
+ dbresult = YAML.safe_load(json2yaml(response))
89
91
  # File.open(",douban.yaml", "wb") {|f| f.write(json2yaml(response)) }
90
92
  if dbresult['opensearch:totalResults']['$t'].to_i > 0
91
93
  for item in dbresult['entry']
@@ -96,15 +98,9 @@ module Alexandria
96
98
  binding = nil
97
99
  for av in item['db:attribute']
98
100
  isbn = av['$t'] if av['@name'] == 'isbn13'
99
- if av['@name'] == 'publisher'
100
- publisher = av['$t']
101
- end
102
- if av['@name'] == 'pubdate'
103
- pubdate = av['$t']
104
- end
105
- if av['@name'] == 'binding'
106
- binding = av['$t']
107
- end
101
+ publisher = av['$t'] if av['@name'] == 'publisher'
102
+ pubdate = av['$t'] if av['@name'] == 'pubdate'
103
+ binding = av['$t'] if av['@name'] == 'binding'
108
104
  end
109
105
  authors = if item['author']
110
106
  item['author'].map { |a| a['name']['$t'] }
@@ -113,9 +109,7 @@ module Alexandria
113
109
  end
114
110
  image_url = nil
115
111
  for av in item['link']
116
- if av['@rel'] == 'image'
117
- image_url = av['@href']
118
- end
112
+ image_url = av['@href'] if av['@rel'] == 'image'
119
113
  end
120
114
  book = Book.new(name, authors, isbn, publisher, pubdate, binding)
121
115
  book_search_results << [book, image_url]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004 Javier Fernandez-Sanguino
2
4
  # Copyright (C) 2007 Javier Fernandez-Sanguino and Marco Costantini
3
5
  # Copyright (C) 2011, 2016 Matijs van Zuijlen
@@ -35,7 +37,7 @@ module Alexandria
35
37
  }.freeze
36
38
 
37
39
  # BASE_URI = "http://www.mcu.es/cgi-bin/BRSCGI3701?"
38
- BASE_URI = 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?'.freeze
40
+ BASE_URI = 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?'
39
41
  def initialize
40
42
  super('MCU', _('Spanish Culture Ministry'))
41
43
  # No preferences
@@ -46,31 +48,36 @@ module Alexandria
46
48
  prefs.read
47
49
  criterion = criterion.encode('ISO-8859-1') # still needed??
48
50
  print "Doing search with MCU #{criterion}, type: #{type}\n" if $DEBUG # for DEBUGing
49
- req = BASE_URI + 'CMD=VERLST&BASE=ISBN&DOCS=1-15&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1-1000&SEPARADOR=&'
51
+ req = BASE_URI +
52
+ 'CMD=VERLST&BASE=ISBN&DOCS=1-15&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1-1000&SEPARADOR=&'
50
53
  req += case type
51
54
  when SEARCH_BY_ISBN
52
- "WGEN-C=&WISB-C=#{CGI.escape(criterion)}&WAUT-C=&WTIT-C=&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C="
55
+ "WGEN-C=&WISB-C=#{CGI.escape(criterion)}&WAUT-C=&WTIT-C="
53
56
 
54
57
  when SEARCH_BY_TITLE
55
- "WGEN-C=&WISB-C=&WAUT-C=&WTIT-C=#{CGI.escape(criterion)}&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C="
58
+ "WGEN-C=&WISB-C=&WAUT-C=&WTIT-C=#{CGI.escape(criterion)}"
56
59
 
57
60
  when SEARCH_BY_AUTHORS
58
- "WGEN-C=&WISB-C=&WAUT-C=#{CGI.escape(criterion)}&WTIT-C=&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C="
61
+ "WGEN-C=&WISB-C=&WAUT-C=#{CGI.escape(criterion)}&WTIT-C="
59
62
 
60
63
  when SEARCH_BY_KEYWORD
61
- "WGEN-C=#{CGI.escape(criterion)}&WISB-C=&WAUT-C=&WTIT-C=&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C="
64
+ "WGEN-C=#{CGI.escape(criterion)}&WISB-C=&WAUT-C=&WTIT-C="
62
65
 
63
66
  else
64
67
  raise InvalidSearchTypeError
65
68
  end
69
+ req +=
70
+ '&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=' \
71
+ '&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C='
66
72
  products = {}
67
73
  print "Request page is #{req}\n" if $DEBUG # for DEBUGing
68
74
  transport.get(URI.parse(req)).each do |line|
69
75
  print "Reading line: #{line}" if $DEBUG # for DEBUGing
70
- if (line =~ /CMD=VERDOC.*&DOCN=([^&]*)&NDOC=([^&]*)/) && (!products[Regexp.last_match[1]]) && (book = parseBook(Regexp.last_match[1], Regexp.last_match[2]))
71
- products[Regexp.last_match[1]] = book
72
- puts Regexp.last_match[1] if $DEBUG # for DEBUGing
73
- end
76
+ next unless line =~ /CMD=VERDOC.*&DOCN=([^&]*)&NDOC=([^&]*)/
77
+ next if products[Regexp.last_match[1]]
78
+ next unless (book = parseBook(Regexp.last_match[1], Regexp.last_match[2]))
79
+ products[Regexp.last_match[1]] = book
80
+ puts Regexp.last_match[1] if $DEBUG # for DEBUGing
74
81
  end
75
82
 
76
83
  raise NoResultsError if products.values.empty?
@@ -79,7 +86,10 @@ module Alexandria
79
86
 
80
87
  def url(book)
81
88
  isbn = Library.canonicalise_isbn(book.isbn)
82
- "http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?CMD=VERLST&BASE=ISBN&DOCS=1-15&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1&SEPARADOR=&WGEN-C=&WISB-C=#{isbn}&WAUT-C=&WTIT-C=&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C="
89
+ 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?CMD=VERLST&BASE=ISBN&DOCS=1-15' \
90
+ "&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1&SEPARADOR=&WGEN-C=&WISB-C=#{isbn}&WAUT-C=&WTIT-C=" \
91
+ '&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=' \
92
+ '&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C='
83
93
  rescue => ex
84
94
  log.warn { "Cannot create url for book #{book}; #{ex.message}" }
85
95
  nil
@@ -88,7 +98,9 @@ module Alexandria
88
98
  private
89
99
 
90
100
  def parseBook(docn, ndoc)
91
- detailspage = 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?CMD=VERDOC&CONF=AEISPA.cnf&BASE=ISBN&DOCN=' + docn + '&NDOC=' + ndoc
101
+ detailspage =
102
+ 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?' \
103
+ 'CMD=VERDOC&CONF=AEISPA.cnf&BASE=ISBN&DOCN=' + docn + '&NDOC=' + ndoc
92
104
  print "Looking at detailspage: #{detailspage}\n" if $DEBUG # for DEBUGing
93
105
  product = {}
94
106
  product['authors'] = []
@@ -115,7 +127,8 @@ module Alexandria
115
127
  print "Authors are #{product['authors']}\n" if $DEBUG # for DEBUGing
116
128
  robotstate = 0
117
129
  end
118
- elsif (robotstate == 2) && line =~ /^(.*)$/ # The title es the next line to title declaration and has not tags on web src code
130
+ elsif (robotstate == 2) && line =~ /^(.*)$/
131
+ # The title es the next line to title declaration and has not tags on web src code
119
132
  product['name'] = Regexp.last_match[1].strip
120
133
  print "Name is #{product['name']}\n" if $DEBUG # for DEBUGing
121
134
  robotstate = 0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2009 Cathal Mc Ginley
2
4
  # Copyright (C) 2014-2016 Matijs van Zuijlen
3
5
  #
@@ -34,11 +36,11 @@ module Alexandria
34
36
  # it adds most to Alexandria (Amazon already has French and
35
37
  # English titles).
36
38
 
37
- SITE = 'http://www.proxis.nl'.freeze
39
+ SITE = 'http://www.proxis.nl'
38
40
  BASE_SEARCH_URL = "#{SITE}/NLNL/Search/IndexGSA.aspx?search=%s" \
39
- '&shop=100001NL&SelRubricLevel1Id=100001NL'.freeze
41
+ '&shop=100001NL&SelRubricLevel1Id=100001NL'
40
42
  ISBN_REDIRECT_BASE_URL = "#{SITE}/NLNL/Search/Index.aspx?search=%s" \
41
- '&shop=100001NL&SelRubricLevel1Id=100001NL'.freeze
43
+ '&shop=100001NL&SelRubricLevel1Id=100001NL'
42
44
 
43
45
  def initialize
44
46
  super('Proxis', 'Proxis (Belgium)')
@@ -76,9 +78,7 @@ module Alexandria
76
78
  end
77
79
 
78
80
  def url(book)
79
- if book.isbn.nil? || book.isbn.empty?
80
- ISBN_REDIRECT_BASE_URL % Library.canonicalise_ean(book.isbn)
81
- end
81
+ ISBN_REDIRECT_BASE_URL % Library.canonicalise_ean(book.isbn) if book.isbn.nil? || book.isbn.empty?
82
82
  end
83
83
 
84
84
  ## from Palatina
@@ -110,9 +110,7 @@ module Alexandria
110
110
  if title_link
111
111
  result[:title] = text_of(title_link)
112
112
  result[:lookup_url] = title_link['href']
113
- unless result[:lookup_url] =~ /^http/
114
- result[:lookup_url] = "#{SITE}#{result[:lookup_url]}"
115
- end
113
+ result[:lookup_url] = "#{SITE}#{result[:lookup_url]}" unless result[:lookup_url] =~ /^http/
116
114
  end
117
115
  book_search_results << result
118
116
  end
@@ -136,9 +134,7 @@ module Alexandria
136
134
  if (title_header = doc.search('div.detailBlock h3'))
137
135
  header_spans = title_header.first.search('span')
138
136
  title = text_of(header_spans.first)
139
- if title =~ /(.+)-$/
140
- title = Regexp.last_match[1].strip
141
- end
137
+ title = Regexp.last_match[1].strip if title =~ /(.+)-$/
142
138
  book_data[:title] = title
143
139
  end
144
140
 
@@ -147,9 +143,7 @@ module Alexandria
147
143
  isbns = []
148
144
  unless info_headers.empty?
149
145
  info_headers.each do |th|
150
- if th.inner_text =~ /(ISBN|EAN)/
151
- isbns << data_for_header(th)
152
- end
146
+ isbns << data_for_header(th) if th.inner_text =~ /(ISBN|EAN)/
153
147
  end
154
148
  book_data[:isbn] = Library.canonicalise_ean(isbns.first)
155
149
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2009 Cathal Mc Ginley
2
4
  # Copyright (C) 2010 Martin Sucha
3
5
  #
@@ -68,16 +70,12 @@ module Alexandria
68
70
 
69
71
  authors = []
70
72
  author_data = details[m[:authors][0]]
71
- if author_data
72
- author_data.each do |ad|
73
- author = ad[m[:authors][1]]
74
- if author
75
- author = author.strip
76
- if author =~ /(.*),$/
77
- author = Regexp.last_match[1]
78
- end
79
- authors << author
80
- end
73
+ author_data&.each do |ad|
74
+ author = ad[m[:authors][1]]
75
+ if author
76
+ author = author.strip
77
+ author = Regexp.last_match[1] if author =~ /(.*),$/
78
+ authors << author
81
79
  end
82
80
  end
83
81
 
@@ -85,40 +83,30 @@ module Alexandria
85
83
  binding = nil
86
84
  isbn_data = details[m[:isbn][0]]
87
85
  if isbn_data
88
- if isbn_data.first[m[:isbn][1]] =~ /([-0-9xX]+)/
89
- isbn = Regexp.last_match[1]
90
- end
86
+ isbn = Regexp.last_match[1] if isbn_data.first[m[:isbn][1]] =~ /([-0-9xX]+)/
91
87
  end
92
88
 
93
89
  binding_data = details[m[:binding][0]]
94
90
  if binding_data
95
- if binding_data.first[m[:binding][1]] =~ /([a-zA-Z][a-z\s]+[a-z])/
96
- binding = Regexp.last_match[1]
97
- end
91
+ binding = Regexp.last_match[1] if binding_data.first[m[:binding][1]] =~ /([a-zA-Z][a-z\s]+[a-z])/
98
92
  end
99
93
 
100
94
  publisher = nil
101
95
  publisher_data = details[m[:publisher][0]]
102
- if publisher_data
103
- publisher = publisher_data.first[m[:publisher][1]]
104
- end
96
+ publisher = publisher_data.first[m[:publisher][1]] if publisher_data
105
97
 
106
98
  year = nil
107
99
  publication_data = details[m[:year][0]]
108
100
  if publication_data
109
101
  year = publication_data.first[m[:year][1]]
110
- if year =~ /(\d+)/
111
- year = Regexp.last_match[1].to_i
112
- end
102
+ year = Regexp.last_match[1].to_i if year =~ /(\d+)/
113
103
  end
114
104
 
115
105
  notes = ''
116
106
  notes_data = details[m[:notes][0]]
117
- if notes_data
118
- notes_data.each do |note|
119
- txt = note[m[:notes][1]]
120
- notes += txt if txt
121
- end
107
+ notes_data&.each do |note|
108
+ txt = note[m[:notes][1]]
109
+ notes += txt if txt
122
110
  end
123
111
 
124
112
  if title.nil? && isbn.nil?