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
@@ -0,0 +1,120 @@
1
+ .de URL
2
+ \\$2 \(laURL: \\$1 \(ra\\$3
3
+ ..
4
+ .if \n[.g] .mso www.tmac
5
+ .TH ALEXANDRIA 1 "December 1, 2007" gnome "GNOME User's Manuals"
6
+ .SH NAME
7
+ alexandria \- a book collection manager
8
+
9
+ .SH SYNOPSIS
10
+ .B alexandria
11
+ .I "[OPTIONS]"
12
+
13
+ .SH DESCRIPTION
14
+ .I Alexandria
15
+ is a GNOME desktop application for managing book collections. It has a
16
+ simple user interface which makes it easy to enter the details of your
17
+ library, generally using Internet sources to find catalogue
18
+ information for your books. It also enables you to create filtered
19
+ views of your book collection based on details such as author,
20
+ publisher etc.
21
+ .LP
22
+ When launched without any options the
23
+ .I Alexandria
24
+ main window opens and presents a view of your libraries, or if run
25
+ for the first time creates a new library ready for you to add books
26
+ either manually or with the help of providers of book information on
27
+ the Internet.
28
+
29
+ .SH OPTIONS
30
+ .B \-\-debug
31
+ Print verbose debug information describing the operation of the
32
+ program. Useful for determining behaviour when a problem is
33
+ encountered. This also sets the logger level to DEBUG.
34
+ .LP
35
+ .B \-\-version
36
+ Show program version information and exit.
37
+ .LP
38
+ .B \-\-help
39
+ Show summary of options and exit. This also shows a great many
40
+ predefined options common to all GTK programs which are not
41
+ defined in this manual page.
42
+
43
+ .SH FILES
44
+ .B $HOME/.alexandria
45
+ The per-user configuration of
46
+ .I Alexandria
47
+ is stored in this directory. Each the books in each library are
48
+ stored in a sub-directory with the library's name e.g. `My
49
+ Library'. Book files are stored in YAML format (a text-based data
50
+ format). They are named after the book's ISBN
51
+ e.g. 9780755322800.yaml The cover images are also named after with
52
+ book's ISBN, with the file extension .cover, although they are
53
+ usually JPEG format files. If a book has no ISBN, it's ID will be
54
+ a number generated from the book title.
55
+ .LP
56
+ .B $HOME/.alexandria/.smart_libraries
57
+ Smart Libraries are a filtered view of your book collection, and
58
+ are saved as YAML format files in this directory.
59
+
60
+ .SH ENVIRONMENT
61
+ .B LOGLEVEL
62
+ Setting this environment variable affects the level at which
63
+ messages will be logged. The log levels are cumulative, setting
64
+ the level to log information messages means it will also include
65
+ all warnings and error messages. Possible values are:
66
+ .RS
67
+ .LP
68
+ .B FATAL
69
+ Only log messages for fatal errors.
70
+ .LP
71
+ .B ERROR
72
+ Log messages for all errors.
73
+ .LP
74
+ .B WARN
75
+ Log warnings and errors.
76
+ .LP
77
+ .B INFO
78
+ Also include information messages.
79
+ .LP
80
+ .B DEBUG
81
+ Log everything, including debug messages.
82
+ .RE
83
+ .LP
84
+ The default level is
85
+ .B WARN
86
+
87
+ .SH BUGS
88
+ Please report any bugs you find on the
89
+ .URL "http://rubyforge.org/tracker/?group_id=205" "Tracker" " at RubyForge."
90
+ Please check for any similar reports before reporting a new bug.
91
+ .LP
92
+ You can also discuss any problems you encounter with the
93
+ .I Alexandria
94
+ developers and other users by joining the
95
+ .URL "http://rubyforge.org/mailman/listinfo/alexandria-list" "alexandria-list" " mailing list."
96
+
97
+ .SH WEB SITE
98
+ News, details of the development team and further documentation may be
99
+ found on the
100
+ .URL "http://alexandria.rubyforge.org/" "Alexandria web site" "."
101
+
102
+ .SH AUTHOR
103
+ Alexandria was originally written by Laurent Sansonetti. The current
104
+ maintainer is Joseph Method <tristil@gmail.com>. For a full list of
105
+ contributors, see the file AUTHORS in Alexandria's documentation.
106
+ .LP
107
+ This manual page was written by Cathal Mc Ginley
108
+ <cathal.alexandria@gnostai.org>.
109
+
110
+ .SH COPYRIGHT
111
+ Copyright (C) 2004-2006 Laurent Sansonetti
112
+ .LP
113
+ Copyright (C) 2007-2010 Alexandria Contributors
114
+
115
+ .SH LICENSE
116
+ .I Alexandria
117
+ is free software; you can redistribute it and/or
118
+ modify it under the terms of the GNU General Public License as
119
+ published by the Free Software Foundation; either version 2 of the
120
+ License, or (at your option) any later version.
@@ -0,0 +1,67 @@
1
+ = CueCat Barcode Scanner Support
2
+
3
+ Alexandria now supports the use of unmodified CueCat barcode scanners
4
+ for scanning ISBN barcodes.
5
+
6
+
7
+ == What is a CueCat?
8
+
9
+ The CueCat is a wand-style barcode scanner, available with either a
10
+ PS/2 keyboard connector (and a PS/2 keyboard pass-through), or with a
11
+ standard keyboard-type USB connector.
12
+
13
+ You scan a barcode by placing the 'nose' of the scanner on one side of
14
+ the barcode, in the clear area before the first black bar, and waiting
15
+ until the flashing red light stops flashing and illuminates the
16
+ surface brightly, then swiftly passing the scanner across the barcode
17
+ and into the clear area on the far side. The scan data is then input
18
+ into your computer as if through a keyboard. You can test the
19
+ operation of your CueCat by placing your keyboard cursor inside any
20
+ text editor and scanning a barcode.
21
+
22
+ By default the scan data is scrambled. There are instructions, widely
23
+ available on the Internet, detailing how to modify the circuit board to
24
+ disable scrambling, but some barcode scanning applications, including
25
+ Alexandria, can automatically decode scrambled data from a CueCat.
26
+
27
+
28
+ == The History of CueCat?
29
+
30
+ Millions of CueCat scanners were distributed free of charge by their
31
+ creator the Digital Convergence Corporation in the late 1990s and
32
+ early 2000s. The intention was that customers would use the scanners
33
+ to scan special barcodes in magazine advertisments and articles, and
34
+ software would take the customers to a related web page.
35
+
36
+ Dozens of eager hackers, upon recieving these barcode scanners,
37
+ immediately set about finding a way to use them for a wider variety of
38
+ purposes, such as book cataloging. They decoded the very simple
39
+ scrambling of the scanner output data (it was a form of Base64
40
+ encoding), and even reported on how to lift a single microchip pin to
41
+ circumvent the scrambling in hardware. They also discovered that each
42
+ CueCat has a unique serial number (which could have allowed
43
+ DigitalConvergence to build up profiles of the products customers were
44
+ interested in) and showed how to zero-out or avoid the serial number.
45
+
46
+ Digital Convergence attempted to restrict such activities, but
47
+ eventually the company went bust, leaving several electronics
48
+ warehouses to buy up hundreds of thousands of unshipped CueCats in the
49
+ ensuing liquidation sale.
50
+
51
+ Today, PS/2 and USB CueCat scanners are available cheaply over the
52
+ internet (about US$12 in 2007). Apart from the slight inconvenience
53
+ caused by the data scrambling, they are eminently usable as cheap,
54
+ robust, wand-style barcode scanners.
55
+
56
+ == The Old Linux Driver
57
+
58
+ A kernel driver for the CueCat was developed as a patch for the 2.4
59
+ Linux kernel series. This provided decoding of the scrambled input,
60
+ and made input data available from <tt>/dev/scanners/cuecat</tt>.
61
+
62
+ Since this driver is currently unmaintained and does not work with 2.6
63
+ kernels, support for this has been dropped from Alexandria. However,
64
+ since Alexandria 0.6.2, there is so-called 'userland' support for the
65
+ CueCat, which simply means that modifications to the kernel are not
66
+ necessary. Instead, the decoding of the simple data scrambling is done
67
+ by the application software.
@@ -0,0 +1,61 @@
1
+ ---
2
+ - - :whitelist
3
+ - LGPL-3+
4
+ - :who:
5
+ :why:
6
+ :versions: []
7
+ :when: 2017-07-23 05:51:53.629753437 Z
8
+ - - :whitelist
9
+ - LGPL-2.1+
10
+ - :who:
11
+ :why:
12
+ :versions: []
13
+ :when: 2017-07-23 05:52:02.088395832 Z
14
+ - - :whitelist
15
+ - MIT
16
+ - :who:
17
+ :why:
18
+ :versions: []
19
+ :when: 2017-07-23 05:52:06.806192042 Z
20
+ - - :whitelist
21
+ - LGPLv2+
22
+ - :who:
23
+ :why:
24
+ :versions: []
25
+ :when: 2017-07-23 05:52:24.618189811 Z
26
+ - - :whitelist
27
+ - ruby
28
+ - :who:
29
+ :why:
30
+ :versions: []
31
+ :when: 2017-07-23 05:52:36.986497403 Z
32
+ - - :approve
33
+ - alexandria-book-collection-manager
34
+ - :who:
35
+ :why:
36
+ :versions: []
37
+ :when: 2017-07-23 05:53:02.657760962 Z
38
+ - - :approve
39
+ - unf
40
+ - :who:
41
+ :why:
42
+ :versions: []
43
+ :when: 2017-07-23 05:54:45.171526986 Z
44
+ - - :approve
45
+ - gettext
46
+ - :who:
47
+ :why:
48
+ :versions: []
49
+ :when: 2017-07-23 05:54:51.349832715 Z
50
+ - - :approve
51
+ - cairo
52
+ - :who:
53
+ :why:
54
+ :versions: []
55
+ :when: 2017-07-23 05:54:54.822319735 Z
56
+ - - :approve
57
+ - zoom
58
+ - :who:
59
+ :why: Actually licensed under LGPL-2.1
60
+ :versions: []
61
+ :when: 2017-07-23 06:00:43.594558953 Z
@@ -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
  #
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
3
4
  # Copyright (C) 2008 Joseph Method
4
5
  # Copyright (C) 2015 Matijs van Zuijlen
@@ -19,13 +20,13 @@
19
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
20
21
 
21
22
  module Alexandria
22
- TITLE = 'Alexandria'.freeze
23
- TEXTDOMAIN = 'alexandria'.freeze
23
+ TITLE = 'Alexandria'
24
+ TEXTDOMAIN = 'alexandria'
24
25
  extend GetText
25
26
  bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
26
27
  DESCRIPTION = _('A program to help you manage your book collection.')
27
28
  COPYRIGHT = "Copyright (C) 2004-2006 Laurent Sansonetti\n" \
28
- 'Copyright (C) 2007-2010,2014,2015 Alexandria Contributors'.freeze
29
+ 'Copyright (C) 2007-2010,2014,2015 Alexandria Contributors'
29
30
  AUTHORS = [
30
31
  'Alexander McCormmach <alexander@tunicate.org>',
31
32
  'Aymeric Nys <aymeric@nnx.com>',
@@ -77,6 +78,6 @@ module Alexandria
77
78
  'Andreas Nilsson <nisses.mail@home.se>',
78
79
  'Stefanie Dijoux <stefanie.dijoux@gmail.com>'
79
80
  ].freeze
80
- BUGREPORT_URL = 'http://www.github.com/mvz/alexandria-book-collection-manager/issues'.freeze
81
- WEBSITE_URL = 'http://www.github.com/mvz/alexandria-book-collection-manager'.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'
82
83
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2009 Cathal Mc Ginley
3
5
  # Copyright (C) 2011, 2014 Matijs van Zuijlen
@@ -89,8 +91,8 @@ module Alexandria
89
91
  'expired.') % factory.name
90
92
 
91
93
  when SocketError
92
- _("Couldn't reach the provider '%s': socket " \
93
- 'error (%s).') % [factory.name, boom.message]
94
+ format(_("Couldn't reach the provider '%s': socket " \
95
+ 'error (%s).'), factory.name, boom.message)
94
96
 
95
97
  when NoResultsError
96
98
  _('No results were found. Make sure your ' \
@@ -273,6 +275,7 @@ module Alexandria
273
275
  fullname <=> provider.fullname
274
276
  end
275
277
 
278
+ # FIXME: Clean up this complex abstract/concrete class system
276
279
  def self.unabstract
277
280
  include Singleton
278
281
  undef_method :reinitialize
@@ -289,11 +292,8 @@ module Alexandria
289
292
  require 'alexandria/book_providers/mcu' # yep, still mostly works !
290
293
  require 'alexandria/book_providers/douban' # only requires YAML
291
294
 
292
- # require 'alexandria/book_providers/ibs_it'
293
295
  # require 'alexandria/book_providers/renaud'
294
- # require 'alexandria/book_providers/bol_it'
295
- # require 'alexandria/book_providers/webster_it'
296
- log.info { 'Not loading IBS, Renaud, BOL, Webster (providers not functional)' }
296
+ log.info { 'Not loading Renaud (provider not functional)' }
297
297
 
298
298
  # Amazon AWS (Amazon Associates Web Services) provider, needs hpricot
299
299
  require 'alexandria/book_providers/amazon_aws'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- ruby -*-
2
4
  #
3
5
  # Copyright (C) 2009 Cathal Mc Ginley
@@ -33,12 +35,12 @@ module Alexandria
33
35
  class AdLibrisProvider < WebsiteBasedProvider
34
36
  include Alexandria::Logging
35
37
 
36
- SITE = 'http://www.adlibris.com/se/'.freeze
38
+ SITE = 'http://www.adlibris.com/se/'
37
39
 
38
40
  BASE_SEARCH_URL = "#{SITE}searchresult.aspx?search=advanced&%s=%s" \
39
- '&fromproduct=False'.freeze # type/term
41
+ '&fromproduct=False' # type/term
40
42
 
41
- PRODUCT_URL = "#{SITE}product.aspx?isbn=%s".freeze
43
+ PRODUCT_URL = "#{SITE}product.aspx?isbn=%s"
42
44
 
43
45
  def initialize
44
46
  super('AdLibris', 'AdLibris (Sweden)')
@@ -82,7 +84,7 @@ module Alexandria
82
84
  SEARCH_BY_KEYWORD => 'keyword'
83
85
  }[search_type]) || 'keyword'
84
86
  search_term_encoded = CGI.escape(search_term)
85
- BASE_SEARCH_URL % [search_type_code, search_term_encoded]
87
+ format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
86
88
  end
87
89
  end
88
90
 
@@ -142,7 +144,6 @@ module Alexandria
142
144
  # doc = Hpricot(html)
143
145
  doc = html_to_doc(html)
144
146
  begin
145
-
146
147
  title = nil
147
148
  if (h1 = doc.at('div.productTitleFormat h1'))
148
149
  title = text_of(h1)
@@ -169,17 +170,13 @@ module Alexandria
169
170
  binding = nil
170
171
  if (format = doc.search('div.productTitleFormat span').first)
171
172
  binding = text_of(format)
172
- if binding =~ /\(([^\)]+)\)/
173
- binding = Regexp.last_match[1]
174
- end
173
+ binding = Regexp.last_match[1] if binding =~ /\(([^\)]+)\)/
175
174
  end
176
175
 
177
176
  year = nil
178
177
  if (published = product.search('span[@id$="Published"]').first)
179
178
  publication = published.inner_text
180
- if publication =~ /([12][0-9]{3})/
181
- year = Regexp.last_match[1].to_i
182
- end
179
+ year = Regexp.last_match[1].to_i if publication =~ /([12][0-9]{3})/
183
180
  end
184
181
 
185
182
  isbns = []
@@ -189,9 +186,7 @@ module Alexandria
189
186
  isbn = isbn_td.inner_text
190
187
  next unless isbn =~ /[0-9x]{10,13}/i
191
188
  isbn.gsub(/(\n|\r)/, ' ')
192
- if isbn =~ /:[\s]*([0-9x]+)/i
193
- isbn = Regexp.last_match[1]
194
- end
189
+ isbn = Regexp.last_match[1] if isbn =~ /:[\s]*([0-9x]+)/i
195
190
  isbns << isbn
196
191
  end
197
192
  isbn = isbns.first
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2008 Cathal Mc Ginley
3
5
  # Copyright (C) 2014, 2016 Matijs van Zuijlen
@@ -46,29 +48,19 @@ module Alexandria
46
48
  # kill old (shorter) tokens, or previously distributed Access Key Id (see #26250)
47
49
 
48
50
  if token
49
- if token.value != token.value.strip
50
- token.new_value = token.value.strip
51
- end
52
- end
53
- if token && ((token.value.size != 20) || (token.value == '0J356Z09CN88KB743582'))
54
- token.new_value = ''
51
+ token.new_value = token.value.strip if token.value != token.value.strip
55
52
  end
53
+ token.new_value = '' if token && ((token.value.size != 20) || (token.value == '0J356Z09CN88KB743582'))
56
54
 
57
55
  secret = prefs.variable_named('secret_key')
58
56
  if secret
59
- if secret.value != secret.value.strip
60
- secret.new_value = secret.value.strip
61
- end
57
+ secret.new_value = secret.value.strip if secret.value != secret.value.strip
62
58
  end
63
59
 
64
60
  associate = prefs.variable_named('associate_tag')
65
61
  if associate
66
- if associate.value.strip.empty?
67
- associate.new_value = 'rubyalexa-20'
68
- end
69
- if associate.value != associate.value.strip
70
- associate.new_value = associate.value.strip
71
- end
62
+ associate.new_value = 'rubyalexa-20' if associate.value.strip.empty?
63
+ associate.new_value = associate.value.strip if associate.value != associate.value.strip
72
64
  end
73
65
  end
74
66
 
@@ -76,7 +68,9 @@ module Alexandria
76
68
  prefs.read
77
69
 
78
70
  if prefs['secret_key'].empty?
79
- raise Amazon::RequestError, 'Secret Access Key required for Authentication: you must sign up for your own Amazon AWS account'
71
+ raise(Amazon::RequestError,
72
+ 'Secret Access Key required for Authentication:' \
73
+ ' you must sign up for your own Amazon AWS account')
80
74
  end
81
75
 
82
76
  if (config = Alexandria::Preferences.instance.http_proxy_config)
@@ -105,7 +99,8 @@ module Alexandria
105
99
  when SEARCH_BY_ISBN
106
100
  criterion = Library.canonicalise_isbn(criterion)
107
101
  # This isn't ideal : I'd like to do an ISBN/EAN-specific search
108
- res = Amazon::Ecs.item_search(criterion, response_group: 'ItemAttributes,Images', country: request_locale)
102
+ res = Amazon::Ecs.item_search(criterion, response_group: 'ItemAttributes,Images',
103
+ country: request_locale)
109
104
  res.items.each do |item|
110
105
  products << item
111
106
  end
@@ -125,29 +120,36 @@ module Alexandria
125
120
  # result with different ISBNs
126
121
 
127
122
  if products.length > 1
128
- log.warn { "ISBN search at Amazon[#{request_locale}] got #{products.length} results; returning the first result only" }
123
+ log.warn {
124
+ "ISBN search at Amazon[#{request_locale}] got #{products.length} results;" \
125
+ ' returning the first result only'
126
+ }
129
127
  end
130
128
 
131
129
  when SEARCH_BY_TITLE
132
- res = Amazon::Ecs.item_search(criterion, response_group: 'ItemAttributes,Images', country: request_locale)
130
+ res = Amazon::Ecs.item_search(criterion,
131
+ response_group: 'ItemAttributes,Images',
132
+ country: request_locale)
133
133
 
134
134
  res.items.each do |item|
135
- if item.get('itemattributes/title') =~ /#{criterion}/i
136
- products << item
137
- end
135
+ products << item if item.get('itemattributes/title') =~ /#{criterion}/i
138
136
  end
139
137
  # #req.keyword_search(criterion) do |product|
140
138
 
141
139
  when SEARCH_BY_AUTHORS
142
140
  criterion = "author:#{criterion}"
143
- res = Amazon::Ecs.item_search(criterion, response_group: 'ItemAttributes,Images', country: request_locale, type: 'Power')
141
+ res = Amazon::Ecs.item_search(criterion,
142
+ response_group: 'ItemAttributes,Images',
143
+ country: request_locale, type: 'Power')
144
144
  res.items.each do |item|
145
145
  products << item
146
146
  end
147
147
  # #req.author_search(criterion) do |product|
148
148
 
149
149
  when SEARCH_BY_KEYWORD
150
- res = Amazon::Ecs.item_search(criterion, response_group: 'ItemAttributes,Images', country: request_locale)
150
+ res = Amazon::Ecs.item_search(criterion,
151
+ response_group: 'ItemAttributes,Images',
152
+ country: request_locale)
151
153
 
152
154
  res.items.each do |item|
153
155
  products << item
@@ -156,9 +158,7 @@ module Alexandria
156
158
  else
157
159
  raise InvalidSearchTypeError
158
160
  end
159
- if products.empty?
160
- raise Amazon::RequestError, 'No products'
161
- end
161
+ raise Amazon::RequestError, 'No products' if products.empty?
162
162
  # raise NoResultsError if products.empty?
163
163
  rescue Amazon::RequestError => re
164
164
  log.debug { "Got Amazon::RequestError at #{request_locale}: #{re}" }
@@ -176,9 +176,7 @@ module Alexandria
176
176
  media = nil if media == 'Unknown Binding'
177
177
 
178
178
  isbn = normalize(atts.get('isbn'))
179
- isbn = if isbn && Library.valid_isbn?(isbn)
180
- Library.canonicalise_ean(isbn)
181
- end
179
+ isbn = (Library.canonicalise_ean(isbn) if isbn && Library.valid_isbn?(isbn))
182
180
  # hack, extract year by regexp (not Y10K compatible :-)
183
181
  /([1-9][0-9]{3})/ =~ atts.get('publicationdate')
184
182
  publishing_year = Regexp.last_match[1] ? Regexp.last_match[1].to_i : nil
@@ -202,9 +200,7 @@ module Alexandria
202
200
  results.each do |rslt|
203
201
  book = rslt[0]
204
202
  book_isbn_canon = Library.canonicalise_ean(book.isbn)
205
- if query_isbn_canon == book_isbn_canon
206
- return rslt
207
- end
203
+ return rslt if query_isbn_canon == book_isbn_canon
208
204
  log.debug { "rejected possible result #{book}" }
209
205
  end
210
206
  # gone through all and no ISBN match, so just return first result