alexandria-book-collection-manager 0.7.1 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +9 -0
  3. data/.gitignore +5 -2
  4. data/.hound.yml +2 -0
  5. data/.rubocop.yml +113 -45
  6. data/.rubocop_todo.yml +82 -170
  7. data/.simplecov +5 -1
  8. data/.travis.yml +45 -0
  9. data/.yardopts +1 -1
  10. data/CHANGELOG.md +60 -0
  11. data/ChangeLog.0 +33 -35
  12. data/Gemfile +6 -5
  13. data/INSTALL.md +164 -0
  14. data/README.md +52 -42
  15. data/Rakefile +95 -109
  16. data/TODO.md +9 -1
  17. data/alexandria-book-collection-manager.gemspec +52 -45
  18. data/bin/alexandria +31 -53
  19. data/doc/AUTHORS +61 -0
  20. data/doc/BUGS +31 -0
  21. data/doc/FAQ +365 -0
  22. data/doc/HACKING +19 -0
  23. data/doc/NEWS +341 -0
  24. data/doc/alexandria.1 +120 -0
  25. data/doc/cuecat_support.rdoc +67 -0
  26. data/doc/dependency_decisions.yml +80 -0
  27. data/lib/alexandria.rb +29 -37
  28. data/lib/alexandria/about.rb +52 -51
  29. data/lib/alexandria/book_providers.rb +94 -101
  30. data/lib/alexandria/book_providers/adlibris.rb +45 -85
  31. data/lib/alexandria/book_providers/amazon_aws.rb +105 -113
  32. data/lib/alexandria/book_providers/amazon_ecs_util.rb +293 -324
  33. data/lib/alexandria/book_providers/barnes_and_noble.rb +54 -53
  34. data/lib/alexandria/book_providers/douban.rb +29 -51
  35. data/lib/alexandria/book_providers/proxis.rb +42 -59
  36. data/lib/alexandria/book_providers/pseudomarc.rb +79 -99
  37. data/lib/alexandria/book_providers/siciliano.rb +68 -70
  38. data/lib/alexandria/book_providers/thalia.rb +46 -45
  39. data/lib/alexandria/book_providers/web.rb +17 -33
  40. data/lib/alexandria/book_providers/worldcat.rb +74 -102
  41. data/lib/alexandria/book_providers/z3950.rb +170 -174
  42. data/lib/alexandria/config.rb +5 -3
  43. data/lib/alexandria/console.rb +10 -21
  44. data/lib/alexandria/default_preferences.rb +37 -0
  45. data/lib/alexandria/execution_queue.rb +17 -15
  46. data/lib/alexandria/export_format.rb +47 -0
  47. data/lib/alexandria/export_library.rb +188 -302
  48. data/lib/alexandria/import_library.rb +114 -155
  49. data/lib/alexandria/import_library_csv.rb +46 -96
  50. data/lib/alexandria/library_collection.rb +79 -0
  51. data/lib/alexandria/library_sort_order.rb +45 -0
  52. data/lib/alexandria/library_store.rb +233 -0
  53. data/lib/alexandria/logging.rb +15 -19
  54. data/lib/alexandria/models/book.rb +15 -20
  55. data/lib/alexandria/models/library.rb +81 -363
  56. data/lib/alexandria/net.rb +7 -6
  57. data/lib/alexandria/preferences.rb +73 -91
  58. data/lib/alexandria/scanners.rb +4 -2
  59. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +24 -20
  60. data/lib/alexandria/scanners/keyboard.rb +10 -8
  61. data/lib/alexandria/smart_library.rb +135 -171
  62. data/lib/alexandria/ui.rb +17 -15
  63. data/lib/alexandria/ui/about_dialog.rb +49 -0
  64. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +129 -152
  65. data/lib/alexandria/ui/alert_dialog.rb +64 -0
  66. data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
  67. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +18 -15
  68. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +44 -61
  69. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +84 -89
  70. data/lib/alexandria/ui/builder_base.rb +9 -27
  71. data/lib/alexandria/ui/callbacks.rb +188 -186
  72. data/lib/alexandria/ui/columns.rb +2 -0
  73. data/lib/alexandria/ui/completion_models.rb +12 -23
  74. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  75. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  76. data/lib/alexandria/ui/dndable.rb +10 -8
  77. data/lib/alexandria/ui/error_dialog.rb +25 -0
  78. data/lib/alexandria/ui/export_dialog.rb +139 -0
  79. data/lib/alexandria/ui/icons.rb +49 -65
  80. data/lib/alexandria/ui/iconview.rb +15 -13
  81. data/lib/alexandria/ui/iconview_tooltips.rb +43 -58
  82. data/lib/alexandria/ui/import_dialog.rb +157 -0
  83. data/lib/alexandria/ui/init.rb +23 -33
  84. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
  85. data/lib/alexandria/ui/libraries_combo.rb +18 -14
  86. data/lib/alexandria/ui/listview.rb +77 -88
  87. data/lib/alexandria/ui/main_app.rb +26 -26
  88. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  89. data/lib/alexandria/ui/multi_drag_treeview.rb +30 -41
  90. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +168 -215
  91. data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
  92. data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
  93. data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
  94. data/lib/alexandria/ui/preferences_dialog.rb +313 -0
  95. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
  96. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  97. data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
  98. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +62 -72
  99. data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
  100. data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
  101. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +96 -172
  102. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  103. data/lib/alexandria/ui/sound.rb +13 -13
  104. data/lib/alexandria/ui/ui_manager.rb +262 -283
  105. data/lib/alexandria/undo_manager.rb +3 -0
  106. data/lib/alexandria/version.rb +6 -19
  107. data/lib/alexandria/web_themes.rb +24 -21
  108. data/po/Makefile +2 -2
  109. data/po/cs.po +993 -880
  110. data/po/cy.po +957 -874
  111. data/po/de.po +990 -869
  112. data/po/el.po +989 -869
  113. data/po/es.po +985 -865
  114. data/po/fr.po +986 -870
  115. data/po/ga.po +907 -823
  116. data/po/gl.po +981 -865
  117. data/po/it.po +986 -868
  118. data/po/ja.po +969 -853
  119. data/po/mk.po +983 -863
  120. data/po/nb.po +979 -863
  121. data/po/nl.po +983 -864
  122. data/po/pl.po +1020 -969
  123. data/po/pt.po +988 -861
  124. data/po/pt_BR.po +984 -868
  125. data/po/ru.po +992 -873
  126. data/po/sk.po +987 -869
  127. data/po/sv.po +977 -861
  128. data/po/uk.po +975 -865
  129. data/po/zh_TW.po +976 -860
  130. data/schemas/alexandria.schemas +25 -3
  131. data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
  132. data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
  133. data/share/alexandria/glade/main_app__builder.glade +24 -33
  134. data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
  135. data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
  136. data/share/gnome/help/alexandria/C/introduction.xml +0 -8
  137. data/share/gnome/help/alexandria/C/searching.xml +1 -1
  138. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  139. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  140. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  141. data/share/gnome/help/alexandria/ja/introduction.xml +0 -8
  142. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  143. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  144. data/spec/alexandria/book_providers_spec.rb +77 -210
  145. data/spec/alexandria/book_spec.rb +16 -12
  146. data/spec/alexandria/console_spec.rb +27 -0
  147. data/spec/alexandria/export_library_spec.rb +130 -0
  148. data/spec/alexandria/library_spec.rb +130 -172
  149. data/spec/alexandria/library_store_spec.rb +37 -0
  150. data/spec/alexandria/preferences_spec.rb +46 -17
  151. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  152. data/spec/alexandria/smart_library_spec.rb +32 -25
  153. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  154. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  155. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  156. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  157. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  158. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  159. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  160. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  161. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  162. data/spec/alexandria/ui/icons_spec.rb +26 -0
  163. data/spec/alexandria/ui/iconview_spec.rb +9 -21
  164. data/spec/alexandria/ui/import_dialog_spec.rb +41 -0
  165. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  166. data/spec/alexandria/ui/main_app_spec.rb +8 -33
  167. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  168. data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
  169. data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
  170. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
  171. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  172. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
  173. data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
  174. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  175. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  176. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +32 -0
  177. data/spec/alexandria/ui/sound_spec.rb +4 -2
  178. data/spec/alexandria/ui/ui_manager_spec.rb +45 -20
  179. data/spec/end_to_end/basic_run_spec.rb +57 -0
  180. data/spec/spec_helper.rb +66 -33
  181. data/tasks/setup.rb +5 -3
  182. data/tasks/spec.rake +18 -3
  183. data/util/rake/fileinstall.rb +38 -40
  184. data/util/rake/gettextgenerate.rb +15 -70
  185. data/util/rake/omfgenerate.rb +10 -10
  186. metadata +176 -60
  187. data/INSTALL.rdoc +0 -148
  188. data/dogtail/basic_run_test.py +0 -9
  189. data/lib/alexandria/book_providers/bol_it.rb +0 -160
  190. data/lib/alexandria/book_providers/deastore.rb +0 -273
  191. data/lib/alexandria/book_providers/ibs_it.rb +0 -147
  192. data/lib/alexandria/book_providers/mcu.rb +0 -169
  193. data/lib/alexandria/book_providers/renaud.rb +0 -140
  194. data/lib/alexandria/book_providers/webster_it.rb +0 -167
  195. data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -59
  196. data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -70
  197. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -43
  198. data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
  199. data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
  200. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -85
  201. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
  202. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
  203. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -578
  204. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -57
  205. data/spec/alexandria/scanners/cuecat_spec.rb +0 -65
  206. data/spec/alexandria/ui/dialogs_spec.rb +0 -94
  207. data/spec/alexandria/ui/sidepane_spec.rb +0 -27
  208. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -60
  209. data/spec/alexandria/utilities_spec.rb +0 -50
  210. data/tasks/dogtail.rake +0 -4
@@ -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,80 @@
1
+ ---
2
+ - - :permit
3
+ - LGPL-3+
4
+ - :who:
5
+ :why:
6
+ :versions: []
7
+ :when: 2017-07-23 05:51:53.629753437 Z
8
+ - - :permit
9
+ - LGPL-2.1+
10
+ - :who:
11
+ :why:
12
+ :versions: []
13
+ :when: 2017-07-23 05:52:02.088395832 Z
14
+ - - :permit
15
+ - MIT
16
+ - :who:
17
+ :why:
18
+ :versions: []
19
+ :when: 2017-07-23 05:52:06.806192042 Z
20
+ - - :permit
21
+ - LGPLv2+
22
+ - :who:
23
+ :why:
24
+ :versions: []
25
+ :when: 2017-07-23 05:52:24.618189811 Z
26
+ - - :permit
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
+ - - :license
57
+ - zoom
58
+ - LGPL-2.1
59
+ - :who:
60
+ :why:
61
+ :versions: []
62
+ :when: 2020-07-30 06:44:22.960902375 Z
63
+ - - :permit
64
+ - Simplified BSD
65
+ - :who:
66
+ :why:
67
+ :versions: []
68
+ :when: 2020-07-30 06:45:58.599399721 Z
69
+ - - :permit
70
+ - Apache 2.0
71
+ - :who:
72
+ :why:
73
+ :versions: []
74
+ :when: 2020-07-30 06:46:08.280121582 Z
75
+ - - :permit
76
+ - LGPL-2.1
77
+ - :who:
78
+ :why:
79
+ :versions: []
80
+ :when: 2020-07-30 06:46:32.729325577 Z
@@ -1,22 +1,10 @@
1
- # Copyright (C) 2004-2006 Laurent Sansonetti
2
- # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
- #
4
- # Alexandria is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU General Public License as
6
- # published by the Free Software Foundation; either version 2 of the
7
- # License, or (at your option) any later version.
8
- #
9
- # Alexandria is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # General Public License for more details.
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Alexandria.
13
4
  #
14
- # You should have received a copy of the GNU General Public
15
- # License along with Alexandria; see the file COPYING. If not,
16
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
17
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
18
6
 
19
- require 'gettext'
7
+ require "gettext"
20
8
 
21
9
  # XXX: Gettext hotfix
22
10
  module Gem
@@ -28,18 +16,20 @@ module Gem
28
16
  end
29
17
  end
30
18
 
31
- require 'logger'
32
- require 'alexandria/logging'
33
- require 'alexandria/about'
19
+ require "logger"
20
+ require "alexandria/logging"
21
+ require "alexandria/about"
34
22
 
35
23
  module Alexandria
36
24
  def self.set_proxy
37
- ENV['http_proxy'] = nil if !ENV['http_proxy'].nil? && URI.parse(ENV['http_proxy']).userinfo.nil?
25
+ if !ENV["http_proxy"].nil? && URI.parse(ENV["http_proxy"]).userinfo.nil?
26
+ ENV["http_proxy"] = nil
27
+ end
38
28
  end
39
29
 
40
30
  def self.set_log_level
41
- Alexandria.log.level = Logger::DEBUG if $DEBUG
42
- Alexandria.log.debug { 'Initializing Alexandria...' }
31
+ log.level = Logger::DEBUG if $DEBUG
32
+ log.debug { "Initializing Alexandria" }
43
33
  end
44
34
 
45
35
  def self.main
@@ -51,8 +41,8 @@ end
51
41
 
52
42
  # lrz says 'macui' is obsolete (may be supported again some day)
53
43
  # unless $MACOSX
54
- require 'alexandria/config'
55
- require 'alexandria/version'
44
+ require "alexandria/config"
45
+ require "alexandria/version"
56
46
 
57
47
  # else
58
48
  # module Alexandria
@@ -63,20 +53,22 @@ require 'alexandria/version'
63
53
  # end
64
54
  # end
65
55
 
66
- require 'alexandria/models/book'
67
- require 'alexandria/models/library'
56
+ require "alexandria/models/book"
57
+ require "alexandria/library_store"
58
+ require "alexandria/library_collection"
59
+ require "alexandria/models/library"
68
60
 
69
- require 'alexandria/smart_library'
70
- require 'alexandria/execution_queue'
71
- require 'alexandria/import_library'
72
- require 'alexandria/export_library'
73
- require 'alexandria/book_providers'
74
- require 'alexandria/preferences'
75
- require 'alexandria/undo_manager'
76
- require 'alexandria/web_themes'
61
+ require "alexandria/smart_library"
62
+ require "alexandria/execution_queue"
63
+ require "alexandria/import_library"
64
+ require "alexandria/export_library"
65
+ require "alexandria/book_providers"
66
+ require "alexandria/preferences"
67
+ require "alexandria/undo_manager"
68
+ require "alexandria/web_themes"
77
69
 
78
70
  # lrz says 'macui' is obsolete (may be supported again some day)
79
71
  # require $MACOSX ? 'alexandria/macui' : 'alexandria/ui'
80
72
 
81
- require 'alexandria/ui'
82
- require 'alexandria/console'
73
+ require "alexandria/ui"
74
+ require "alexandria/console"
@@ -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,64 +20,64 @@
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
- bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
26
- 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.")
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
- 'Alexander McCormmach <alexander@tunicate.org>',
31
- 'Aymeric Nys <aymeric@nnx.com>',
32
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org>',
33
- 'Claudio Belotti <bel8@lilik.it>',
34
- 'Constantine Evans <cevans@costinet.org>',
35
- 'Dafydd Harries <daf@muse.19inch.net>',
36
- 'Javier Fernandez-Sanguino Pena <jfs@debian.org>',
37
- 'Joseph Method <tristil@gmail.com>',
38
- 'Kevin Schultz <schultkl@ieee.org>',
39
- 'Laurent Sansonetti <lrz@gnome.org>',
40
- 'Marco Costantini <costanti@science.unitn.it>',
41
- 'Mathieu Leduc-Hamel <arrak@arrak.org>',
42
- 'Matijs van Zuijlen <matijs@matijs.net>',
43
- 'Owain Evans <o.evans@gmail.com>',
44
- 'Pascal Terjan <pterjan@linuxfr.org>',
45
- 'Rene Samselnig <sandman@sdm-net.org>',
46
- 'Robby Stephenson <robby@periapsis.org>',
47
- 'Sun Ning <classicning@gmail.com>',
48
- 'Takayuki Kusano <AE5T-KSN@asahi-net.or.jp>',
49
- 'Timothy Malone <timothy.malone@gmail.com>',
50
- '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>"
51
52
  ].freeze
52
53
  DOCUMENTERS = [
53
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org>',
54
- 'Liam Davison <registrations@liamjdavison.info>'
54
+ "Cathal Mc Ginley <cathal.alexandria@gnostai.org>",
55
+ "Liam Davison <registrations@liamjdavison.info>"
55
56
  ].freeze
56
57
  TRANSLATORS = [
57
- 'Adrián Chaves Fernández <adriyetichaves@gmail.com> (gl)',
58
- 'Cathal Mc Ginley <cathal.alexandria@gnostai.org> (ga)',
59
- 'CHIKAMA Masaki <masaki.chikama@gmail.com> (ja)',
60
- 'Dafydd Harries <daf@muse.19inch.net> (cy)',
61
- 'Damjan Dimitrioski <damjandimitrioski@gmail.com> (mk)',
62
- 'Giacomo Margarito <giacomomargarito@gmail.com> (it)',
63
- 'Jack Myrseh <jack@enkom.no> (nb)',
64
- 'Joachim Breitner <mail@joachim-breitner.de> (de)',
65
- 'José Ling <jlgdot369@gmail.com> (zh_TW)',
66
- 'Lennart Karssen <lennart@karssen.org> (nl)',
67
- 'Lígia Moreira <ligia.moreira@netvisao.pt> (fr, pt, pt_BR)',
68
- 'Martin Karlsson <martinkarlsson81@hotmail.com> (sv)',
69
- 'Michael Kotsarinis <mkotsari1@pre.forthnet.gr> (el)',
70
- 'Miguel Ángel García <magmax@ieee.org> (es)',
71
- 'Peter Kováč <kovac.peter@fotopriestor.sk> (sk)',
72
- 'Petr Vanek <vanous@penguin.cz> (cs)',
73
- 'Piotr Drąg <piotrdrag@gmail.com> (pl)',
74
- '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)"
75
76
  ].freeze
76
77
  ARTISTS = [
77
- 'Andreas Nilsson <nisses.mail@home.se>',
78
- 'Stefanie Dijoux <stefanie.dijoux@gmail.com>'
78
+ "Andreas Nilsson <nisses.mail@home.se>",
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
@@ -17,8 +19,8 @@
17
19
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
19
21
 
20
- require 'singleton'
21
- require 'observer'
22
+ require "singleton"
23
+ require "observer"
22
24
 
23
25
  module Alexandria
24
26
  # FIXME: Use delegation instead of inheritance.
@@ -27,27 +29,28 @@ module Alexandria
27
29
  include Singleton
28
30
  include Observable
29
31
  include GetText
30
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
32
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
31
33
 
32
34
  SEARCH_BY_ISBN, SEARCH_BY_TITLE, SEARCH_BY_AUTHORS,
33
35
  SEARCH_BY_KEYWORD = (0..3).to_a
34
36
 
35
37
  class SearchError < StandardError; end
36
38
  class NoResultsError < SearchError; end
37
- class ProviderSkippedError < NoResultsError; end # not an error :^(
38
- class SearchEmptyError < SearchError; end # sigh, again not really an error
39
39
  class TooManyResultsError < SearchError; end
40
40
  class InvalidSearchTypeError < SearchError; end
41
41
 
42
+ # These errors are not really errors
43
+ class ProviderSkippedError < NoResultsError; end
44
+ class SearchEmptyError < SearchError; end
45
+
42
46
  def self.search(criterion, type)
43
47
  factory_n = 0
44
- # puts "book_providers search #{self.instance.count_observers}"
45
48
 
46
49
  begin
47
50
  factory = instance[factory_n]
48
- puts factory.fullname + ' lookup' if $DEBUG
51
+ log.debug { factory.fullname + " lookup" }
49
52
  unless factory.enabled
50
- puts factory.fullname + ' disabled!, skipping...' if $DEBUG
53
+ log.debug { factory.fullname + " disabled!, skipping..." }
51
54
  raise ProviderSkippedError
52
55
  end
53
56
  instance.changed
@@ -62,14 +65,14 @@ module Alexandria
62
65
  instance.notify_observers(:not_found, factory.fullname) # new
63
66
  raise NoResultsError
64
67
  else
65
- log.info { 'found at ' + factory.fullname }
68
+ log.info { "found at " + factory.fullname }
66
69
  instance.changed
67
70
  instance.notify_observers(:found, factory.fullname) # new
68
- return results
71
+ results
69
72
  end
70
- rescue => boom
71
- if boom.is_a? NoResultsError
72
- unless boom.instance_of? ProviderSkippedError
73
+ rescue StandardError => ex
74
+ if ex.is_a? NoResultsError
75
+ unless ex.instance_of? ProviderSkippedError
73
76
  instance.changed
74
77
  instance.notify_observers(:not_found, factory.fullname) # new
75
78
  Thread.new { sleep(0.5) }.join
@@ -78,41 +81,41 @@ module Alexandria
78
81
  instance.changed
79
82
  instance.notify_observers(:error, factory.fullname) # new
80
83
  Thread.new { sleep(0.5) }.join # hrmmmm, to make readable...
81
- trace = boom.backtrace.join("\n >")
82
- log.warn { "Provider #{factory.name} encountered error: #{boom.message} #{trace}" }
84
+ trace = ex.backtrace.join("\n >")
85
+ log.warn { "Provider #{factory.name} encountered error: #{ex.message} #{trace}" }
83
86
  end
84
- if last == factory
87
+ if factory == instance.last
85
88
  log.warn { "Error while searching #{criterion}" }
86
- message = case boom
89
+ message = case ex
87
90
  when Timeout::Error
88
91
  _("Couldn't reach the provider '%s': timeout " \
89
- 'expired.') % factory.name
92
+ "expired.") % factory.name
90
93
 
91
94
  when SocketError
92
- _("Couldn't reach the provider '%s': socket " \
93
- 'error (%s).') % [factory.name, boom.message]
95
+ format(_("Couldn't reach the provider '%s': socket " \
96
+ "error (%s)."), factory.name, ex.message)
94
97
 
95
98
  when NoResultsError
96
- _('No results were found. Make sure your ' \
97
- 'search criterion is spelled correctly, and ' \
98
- 'try again.')
99
+ _("No results were found. Make sure your " \
100
+ "search criterion is spelled correctly, and " \
101
+ "try again.")
99
102
 
100
103
  when ProviderSkippedError
101
- _('No results were found. Make sure your ' \
102
- 'search criterion is spelled correctly, and ' \
103
- 'try again.')
104
+ _("No results were found. Make sure your " \
105
+ "search criterion is spelled correctly, and " \
106
+ "try again.")
104
107
 
105
108
  when TooManyResultsError
106
- _('Too many results for that search.')
109
+ _("Too many results for that search.")
107
110
 
108
111
  when InvalidSearchTypeError
109
- _('Invalid search type.')
112
+ _("Invalid search type.")
110
113
 
111
114
  else
112
- boom.message
115
+ ex.message
113
116
  end
114
- puts "raising empty error #{message}"
115
- raise SearchEmptyError, message
117
+ log.debug { "raising empty error #{message}" }
118
+ raise SearchEmptyError, message # rubocop:disable GetText/DecorateFunctionMessage
116
119
  else
117
120
  factory_n += 1
118
121
  retry
@@ -150,9 +153,8 @@ module Alexandria
150
153
  end
151
154
 
152
155
  def new_value=(new_value)
153
- message = @provider.variable_name(self) + '='
154
- Alexandria::Preferences.instance.send(message,
155
- new_value)
156
+ name = @provider.variable_name(self)
157
+ Alexandria::Preferences.instance.set_variable(name, new_value)
156
158
  self.value = new_value
157
159
  end
158
160
 
@@ -185,9 +187,9 @@ module Alexandria
185
187
 
186
188
  def read
187
189
  each do |var|
188
- message = @provider.variable_name(var)
189
- val = Alexandria::Preferences.instance.send(message)
190
- var.value = val unless val.nil? || ((val == '') && var.mandatory?)
190
+ name = @provider.variable_name(var)
191
+ val = Alexandria::Preferences.instance.get_variable(name)
192
+ var.value = val unless val.nil? || ((val == "") && var.mandatory?)
191
193
  end
192
194
  end
193
195
  end
@@ -201,35 +203,35 @@ module Alexandria
201
203
  @name = name
202
204
  @fullname = (fullname || name)
203
205
  @prefs = Preferences.new(self)
204
- @prefs.add('enabled', _('Enabled'), true, [true, false])
206
+ @prefs.add("enabled", _("Enabled"), true, [true, false])
205
207
  end
206
208
 
207
209
  def enabled
208
- @prefs['enabled']
210
+ @prefs["enabled"]
209
211
  end
210
212
 
211
213
  def toggle_enabled
212
214
  old_value = enabled
213
- @prefs.variable_named('enabled').new_value = !old_value
215
+ @prefs.variable_named("enabled").new_value = !old_value
214
216
  end
215
217
 
216
218
  def reinitialize(fullname)
217
- @name << '_' << fullname.hash.to_s
219
+ @name = "#{name}_#{fullname.hash}"
218
220
  @fullname = fullname
219
221
  prefs = Alexandria::Preferences.instance
220
- ary = prefs.abstract_providers
222
+ ary = prefs.get_variable :abstract_providers
221
223
  ary ||= []
222
224
  ary << @name
223
- prefs.abstract_providers = ary
224
- message = variable_name('name') + '='
225
- prefs.send(message, @fullname)
225
+ prefs.set_variable :abstract_providers, ary
226
+ message = variable_name("name")
227
+ prefs.set_variable(message, @fullname)
226
228
  end
227
229
 
228
230
  def remove
229
231
  prefs = Alexandria::Preferences.instance
230
- if (ary = prefs.abstract_providers)
232
+ if (ary = prefs.get_variable :abstract_providers)
231
233
  ary.delete(@name)
232
- prefs.abstract_providers = ary
234
+ prefs.set_variable :abstract_providers, ary
233
235
  end
234
236
  if (ary = prefs.providers_priority) && ary.include?(@name)
235
237
  ary.delete(@name)
@@ -239,7 +241,7 @@ module Alexandria
239
241
  name = variable_name(variable)
240
242
  prefs.remove_preference(name)
241
243
  end
242
- name = variable_name('name')
244
+ name = variable_name("name")
243
245
  prefs.remove_preference(name)
244
246
  prefs.save!
245
247
  end
@@ -253,7 +255,7 @@ module Alexandria
253
255
  else
254
256
  raise
255
257
  end
256
- @name.downcase + '_' + s
258
+ @name.downcase + "_" + s
257
259
  end
258
260
 
259
261
  def transport
@@ -269,10 +271,11 @@ module Alexandria
269
271
  !included_modules.include?(Singleton)
270
272
  end
271
273
 
272
- def <=>(provider)
273
- fullname <=> provider.fullname
274
+ def <=>(other)
275
+ fullname <=> other.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
@@ -286,29 +289,21 @@ module Alexandria
286
289
  unabstract
287
290
  end
288
291
 
289
- require 'alexandria/book_providers/mcu' # yep, still mostly works !
290
- require 'alexandria/book_providers/douban' # only requires YAML
291
-
292
- # require 'alexandria/book_providers/ibs_it'
293
- # 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)' }
292
+ require "alexandria/book_providers/douban" # only requires YAML
297
293
 
298
294
  # Amazon AWS (Amazon Associates Web Services) provider, needs hpricot
299
- require 'alexandria/book_providers/amazon_aws'
295
+ require "alexandria/book_providers/amazon_aws"
300
296
 
301
297
  # Website based providers
302
- require 'alexandria/book_providers/adlibris'
303
- require 'alexandria/book_providers/barnes_and_noble'
304
- require 'alexandria/book_providers/deastore'
305
- require 'alexandria/book_providers/proxis'
306
- require 'alexandria/book_providers/siciliano'
307
- require 'alexandria/book_providers/thalia'
308
- require 'alexandria/book_providers/worldcat'
298
+ require "alexandria/book_providers/adlibris"
299
+ require "alexandria/book_providers/barnes_and_noble"
300
+ require "alexandria/book_providers/proxis"
301
+ require "alexandria/book_providers/siciliano"
302
+ require "alexandria/book_providers/thalia"
303
+ require "alexandria/book_providers/worldcat"
309
304
 
310
305
  # Z39.50 based providers
311
- require 'alexandria/book_providers/z3950'
306
+ require "alexandria/book_providers/z3950"
312
307
 
313
308
  attr_reader :abstract_classes
314
309
 
@@ -328,11 +323,11 @@ module Alexandria
328
323
  self.class.constants.each do |constant|
329
324
  md = /(.+)Provider$/.match(constant)
330
325
  next unless md
326
+
331
327
  klass = self.class.module_eval(constant.to_s)
332
- if klass.ancestors.include?(AbstractProvider) &&
328
+ if klass < AbstractProvider &&
333
329
  (klass != GenericProvider) &&
334
- (klass != WebsiteBasedProvider) &&
335
- (klass != AbstractProvider)
330
+ (klass != WebsiteBasedProvider)
336
331
 
337
332
  if klass.abstract?
338
333
  @abstract_classes << klass
@@ -341,15 +336,18 @@ module Alexandria
341
336
  end
342
337
  end
343
338
  end
344
- if (ary = @prefs.abstract_providers)
339
+ if (ary = @prefs.get_variable :abstract_providers)
345
340
  ary.each do |name|
346
341
  md = /^(.+)_/.match(name)
347
342
  next unless md
348
- klass_name = md[1] + 'Provider'
343
+
344
+ klass_name = md[1] + "Provider"
349
345
  klass = @abstract_classes.find { |x| x.name.include?(klass_name) }
350
346
  next unless klass
351
- fullname = @prefs.send(name.downcase + '_name')
347
+
348
+ fullname = @prefs.send(name.downcase + "_name")
352
349
  next unless fullname
350
+
353
351
  instance = klass.new
354
352
  instance.name = name
355
353
  instance.fullname = fullname
@@ -367,41 +365,36 @@ module Alexandria
367
365
  compact!
368
366
  end
369
367
 
370
- # FIXME: Define the handful of methods that use this.
371
- def self.method_missing(id, *args, &block)
372
- if instance.respond_to? id
373
- instance.method(id).call(*args, &block)
374
- else
375
- super
376
- end
368
+ def self.list
369
+ instance
370
+ end
371
+
372
+ def self.abstract_classes
373
+ instance.abstract_classes
377
374
  end
378
375
 
379
376
  private
380
377
 
381
378
  def rejig_providers_priority
382
379
  priority = (@prefs.providers_priority || [])
383
- unless priority.empty?
384
- changed = false
380
+ return if priority.empty?
385
381
 
386
- if (ecs_index = priority.index('AmazonECS'))
387
- priority[ecs_index] = 'Amazon' # replace legacy "AmazonECS" name
388
- priority.uniq! # remove any other "Amazon" from the list
389
- changed = true
390
- end
391
- if (deastore_index = priority.index('DeaStore_it'))
392
- priority[deastore_index] = 'DeaStore'
393
- changed = true
394
- end
395
- if (worldcat_index = priority.index('Worldcat'))
396
- priority[worldcat_index] = 'WorldCat'
397
- changed = true
398
- end
399
- if (adlibris_index = priority.index('Adlibris'))
400
- priority[adlibris_index] = 'AdLibris'
401
- changed = true
402
- end
403
- @prefs.providers_priority = priority if changed
382
+ changed = false
383
+
384
+ if (ecs_index = priority.index("AmazonECS"))
385
+ priority[ecs_index] = "Amazon" # replace legacy "AmazonECS" name
386
+ priority.uniq! # remove any other "Amazon" from the list
387
+ changed = true
388
+ end
389
+ if (worldcat_index = priority.index("Worldcat"))
390
+ priority[worldcat_index] = "WorldCat"
391
+ changed = true
392
+ end
393
+ if (adlibris_index = priority.index("Adlibris"))
394
+ priority[adlibris_index] = "AdLibris"
395
+ changed = true
404
396
  end
397
+ @prefs.providers_priority = priority if changed
405
398
  end
406
399
  end
407
400
  end