alexandria-book-collection-manager 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.gitignore +4 -1
  4. data/.rubocop.yml +51 -29
  5. data/.rubocop_todo.yml +33 -155
  6. data/.simplecov +5 -2
  7. data/.travis.yml +10 -4
  8. data/CHANGELOG.md +19 -0
  9. data/INSTALL.md +23 -11
  10. data/README.md +36 -35
  11. data/Rakefile +7 -5
  12. data/alexandria-book-collection-manager.gemspec +8 -3
  13. data/doc/dependency_decisions.yml +22 -3
  14. data/lib/alexandria.rb +2 -2
  15. data/lib/alexandria/book_providers.rb +47 -49
  16. data/lib/alexandria/book_providers/adlibris.rb +8 -13
  17. data/lib/alexandria/book_providers/amazon_aws.rb +47 -60
  18. data/lib/alexandria/book_providers/amazon_ecs_util.rb +283 -298
  19. data/lib/alexandria/book_providers/barnes_and_noble.rb +8 -8
  20. data/lib/alexandria/book_providers/douban.rb +2 -2
  21. data/lib/alexandria/book_providers/proxis.rb +12 -11
  22. data/lib/alexandria/book_providers/pseudomarc.rb +60 -70
  23. data/lib/alexandria/book_providers/siciliano.rb +5 -6
  24. data/lib/alexandria/book_providers/thalia.rb +8 -9
  25. data/lib/alexandria/book_providers/worldcat.rb +25 -31
  26. data/lib/alexandria/book_providers/z3950.rb +62 -69
  27. data/lib/alexandria/default_preferences.rb +37 -0
  28. data/lib/alexandria/execution_queue.rb +13 -12
  29. data/lib/alexandria/export_library.rb +4 -8
  30. data/lib/alexandria/import_library.rb +38 -62
  31. data/lib/alexandria/import_library_csv.rb +16 -16
  32. data/lib/alexandria/library_sort_order.rb +3 -1
  33. data/lib/alexandria/library_store.rb +16 -16
  34. data/lib/alexandria/logging.rb +4 -8
  35. data/lib/alexandria/models/book.rb +2 -2
  36. data/lib/alexandria/models/library.rb +18 -14
  37. data/lib/alexandria/net.rb +1 -2
  38. data/lib/alexandria/preferences.rb +27 -31
  39. data/lib/alexandria/scanners.rb +2 -2
  40. data/lib/alexandria/scanners/cue_cat.rb +5 -5
  41. data/lib/alexandria/scanners/keyboard.rb +1 -1
  42. data/lib/alexandria/smart_library.rb +22 -26
  43. data/lib/alexandria/ui.rb +7 -7
  44. data/lib/alexandria/ui/about_dialog.rb +1 -1
  45. data/lib/alexandria/ui/acquire_dialog.rb +9 -10
  46. data/lib/alexandria/ui/alert_dialog.rb +34 -19
  47. data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
  48. data/lib/alexandria/ui/barcode_animation.rb +5 -5
  49. data/lib/alexandria/ui/book_properties_dialog.rb +2 -2
  50. data/lib/alexandria/ui/book_properties_dialog_base.rb +23 -17
  51. data/lib/alexandria/ui/callbacks.rb +141 -120
  52. data/lib/alexandria/ui/completion_models.rb +1 -1
  53. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
  54. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
  55. data/lib/alexandria/ui/error_dialog.rb +1 -1
  56. data/lib/alexandria/ui/export_dialog.rb +13 -15
  57. data/lib/alexandria/ui/icons.rb +34 -40
  58. data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
  59. data/lib/alexandria/ui/import_dialog.rb +48 -47
  60. data/lib/alexandria/ui/init.rb +3 -2
  61. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
  62. data/lib/alexandria/ui/libraries_combo.rb +10 -9
  63. data/lib/alexandria/ui/listview.rb +5 -6
  64. data/lib/alexandria/ui/main_app.rb +2 -2
  65. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -6
  66. data/lib/alexandria/ui/new_book_dialog.rb +52 -52
  67. data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
  68. data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
  69. data/lib/alexandria/ui/preferences_dialog.rb +23 -82
  70. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +9 -5
  71. data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
  72. data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
  73. data/lib/alexandria/ui/sidepane_manager.rb +35 -37
  74. data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
  75. data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
  76. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +59 -138
  77. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  78. data/lib/alexandria/ui/sound.rb +4 -6
  79. data/lib/alexandria/ui/ui_manager.rb +62 -64
  80. data/lib/alexandria/version.rb +2 -2
  81. data/lib/alexandria/web_themes.rb +15 -15
  82. data/po/cs.po +991 -874
  83. data/po/cy.po +957 -870
  84. data/po/de.po +991 -866
  85. data/po/el.po +987 -863
  86. data/po/es.po +986 -862
  87. data/po/fr.po +988 -868
  88. data/po/ga.po +910 -822
  89. data/po/gl.po +983 -863
  90. data/po/it.po +984 -862
  91. data/po/ja.po +969 -849
  92. data/po/mk.po +983 -859
  93. data/po/nb.po +982 -862
  94. data/po/nl.po +992 -869
  95. data/po/pl.po +1018 -963
  96. data/po/pt.po +983 -852
  97. data/po/pt_BR.po +983 -863
  98. data/po/ru.po +992 -869
  99. data/po/sk.po +986 -864
  100. data/po/sv.po +980 -860
  101. data/po/uk.po +975 -861
  102. data/po/zh_TW.po +974 -854
  103. data/share/alexandria/glade/main_app__builder.glade +6 -21
  104. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  105. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  106. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  107. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  108. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  109. data/spec/alexandria/book_providers_spec.rb +73 -129
  110. data/spec/alexandria/console_spec.rb +0 -5
  111. data/spec/alexandria/export_library_spec.rb +27 -38
  112. data/spec/alexandria/library_spec.rb +56 -44
  113. data/spec/alexandria/preferences_spec.rb +29 -3
  114. data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
  115. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  116. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  117. data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
  118. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  119. data/spec/alexandria/ui/book_properties_dialog_spec.rb +1 -1
  120. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
  121. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  122. data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
  123. data/spec/alexandria/ui/export_dialog_spec.rb +1 -1
  124. data/spec/alexandria/ui/icons_spec.rb +26 -0
  125. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  126. data/spec/alexandria/ui/import_dialog_spec.rb +30 -3
  127. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  128. data/spec/alexandria/ui/main_app_spec.rb +1 -1
  129. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
  130. data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
  131. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
  132. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  133. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
  134. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  135. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  136. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
  137. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +21 -7
  138. data/spec/alexandria/ui/ui_manager_spec.rb +39 -2
  139. data/spec/spec_helper.rb +46 -3
  140. data/tasks/spec.rake +3 -5
  141. data/util/rake/fileinstall.rb +12 -11
  142. metadata +82 -10
  143. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  144. data/spec/alexandria/utilities_spec.rb +0 -52
data/.simplecov CHANGED
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  SimpleCov.start do
2
- track_files 'lib/**/*.rb'
3
- add_filter '/spec/'
4
+ add_group "Main", "lib"
5
+ add_group "Specs", "spec"
6
+ enable_coverage :branch
4
7
  end
@@ -29,10 +29,16 @@ before_install:
29
29
  cache:
30
30
  bundler: true
31
31
 
32
- rvm:
33
- - 2.5
34
- - 2.6
35
- - 2.7
32
+ script: bundle exec rake
33
+
34
+ jobs:
35
+ include:
36
+ - rvm: 2.5
37
+ - rvm: 2.6
38
+ - rvm: 2.7
39
+ - rvm: 2.7.1
40
+ name: "RuboCop"
41
+ script: bundle exec rubocop
36
42
 
37
43
  branches:
38
44
  only:
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.6 / 2020-11-01
4
+
5
+ * Make more strings translatable with help from rubocop-i18n
6
+ * Code quality and testing infrastructure improvements
7
+ * Update Polish translation ([#51] and [#64], by [Piotr Drąg][piotrdrag])
8
+ * Update Dutch translation
9
+ * Make several dialogs that stopped appearing appear again
10
+ * Remove ability to enable and disable providers through a pop-up menu
11
+ * Fix New Library functionality
12
+ * Update dependencies on gtk3, gstreamer, and psych
13
+ * Fix issues in preferences, smart library dialog, and book selection
14
+ * Improve installation instructions
15
+ * Improve README ([#83] by [Happy][HappyFacade])
16
+
3
17
  ## 0.7.5 / 2020-05-11
4
18
 
5
19
  * Avoid crash when opening Import dialog
@@ -82,7 +96,12 @@
82
96
 
83
97
  <!-- contributors -->
84
98
  [jrmhaig]: https://github.com/jrmhaig
99
+ [piotrdrag]: https://github.com/piotrdrag
100
+ [HappyFacade]: https://github.com/HappyFacade
85
101
 
86
102
  <!-- issues and pull requests -->
103
+ [#83]: https://github.com/mvz/alexandria-book-collection-manager/pull/83
104
+ [#64]: https://github.com/mvz/alexandria-book-collection-manager/pull/64
105
+ [#51]: https://github.com/mvz/alexandria-book-collection-manager/pull/51
87
106
  [#23]: https://github.com/mvz/alexandria-book-collection-manager/pull/23
88
107
  [#19]: https://github.com/mvz/alexandria-book-collection-manager/issues/19
data/INSTALL.md CHANGED
@@ -56,23 +56,35 @@ to merge translations into generated files (and to extract
56
56
  translatable string from xml files during development).
57
57
 
58
58
  Note that these files are pre-generated in tar.gz releases, so you'll
59
- only need them if you're building from the SVN version, or want to
59
+ only need them if you're building from the Git version, or want to
60
60
  change the translations.
61
61
 
62
+ For support of the Z38.50 protocol you will need the
63
+ [`yaz`](http://www.indexdata.dk/yaz) package.
64
+
65
+ Alexandria also uses the outdate gconf2 configuration storage system, so you'll
66
+ need to install `gconf2`.
67
+
68
+ On Debian/Ubuntu systems, you can install the needed dependencies by running
69
+
70
+ ```
71
+ apt-get install gettext intltool libyaz-dev gconf2
72
+ ```
73
+
62
74
  ### Ruby/ZOOM and Yaz
63
75
 
64
- For Z39.50 support and and the *Library of Congress* and
65
- *British Library* book providers you will need
66
- [`ruby-zoom`](http://ruby-zoom.rubyforge.org), which in turn
67
- requires the non-Ruby package [`yaz`](http://www.indexdata.dk/yaz).
76
+ For Z39.50 support and the *Library of Congress* and *British Library* book
77
+ providers you will need [`ruby-zoom`](http://ruby-zoom.rubyforge.org), which in
78
+ turn requires the non-Ruby package [`yaz`](http://www.indexdata.dk/yaz) (see
79
+ Native Dependencies above).
68
80
 
69
- Note that if you install the recent Ruby/ZOOM as the `zoom` gem, you
70
- will also need to install the `marc` gem. (Older implementations of
71
- ruby-zoom contained their own implementation of MARC.)
81
+ Note that if you install the recent Ruby/ZOOM as the `zoom` gem, you will also
82
+ need to install the `marc` gem. (Older implementations of ruby-zoom contained
83
+ their own implementation of MARC.)
72
84
 
73
- The Z39.50 Object-Orientation Model (ZOOM) is an international
74
- standard for communication between computer systems, particularly
75
- libraries and information-related systems.
85
+ The Z39.50 Object-Orientation Model (ZOOM) is an international standard for
86
+ communication between computer systems, particularly libraries and
87
+ information-related systems.
76
88
 
77
89
  ### image_size
78
90
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ Alexandria is a GNOME application for managing collections of books.
4
4
 
5
5
  Alexandria is written in Ruby, and is free software, distributed under
6
6
  the terms of the GNU General Public License, version 2 or later. See
7
- the file COPYING for more information.
7
+ the file [COPYING](COPYING) for more information.
8
8
 
9
9
  What is Alexandria?
10
10
  ===================
@@ -39,49 +39,50 @@ Alexandria is a simple program designed to allow individuals to keep a
39
39
  catalogue of their book collection. In addition, it enables users to
40
40
  keep track of books which are on loan.
41
41
 
42
- * retrieves and displays book information (sometimes with cover
43
- pictures) from several online libraries and bookshops, such as
44
- o Amazon
45
- o Proxis
46
- o AdLibris
47
- o Spanish Ministry of Culture
48
- o Livraria Siciliano
49
- o WorldCat
50
- o US Library of Congress
51
- o British Library
52
- * allows books to be added and updated by hand
53
- * enables searches either by ISBN, title, author or keyword
54
- * supports the Z39.50 standard and allow you to manage your own
55
- sources (e.g. university libraries)
56
- * saves data using the plain-text YAML format
57
- * can import and export data into ONIX, Tellico, ISBN-list
58
- and GoodReads CSV formats
59
- * can export XHTML web pages of your libraries, themable with CSS
60
- * allows marking your books as loaned, each with the loan-date and
61
- the name of the person who has borrowed them
62
- * features a HIG-compliant user interface
63
- * shows books in different views (standard list or icons list),
64
- that can be filtered and/or sorted
65
- * handles book rating and notes
66
- * supports CueCat and standard "keyboard wedge" barcode readers
67
- * includes translations for several languages
68
- * is documented in a complete manual (at the moment only in
69
- English and Japanese)
70
-
71
- Alexandria is not without problems. See doc/BUGS for a summary of issues.
42
+ * retrieves and displays book information (sometimes with cover
43
+ pictures) from several online libraries and bookshops, such as
44
+ - Amazon
45
+ - Proxis
46
+ - AdLibris
47
+ - Spanish Ministry of Culture
48
+ - Livraria Siciliano
49
+ - WorldCat
50
+ - US Library of Congress
51
+ - British Library
52
+ * allows books to be added and updated by hand
53
+ * enables searches either by ISBN, title, author or keyword
54
+ * supports the Z39.50 standard and allow you to manage your own
55
+ sources (e.g. university libraries)
56
+ * saves data using the plain-text YAML format
57
+ * can import and export data into ONIX, Tellico, ISBN-list
58
+ and GoodReads CSV formats
59
+ * can export XHTML web pages of your libraries, themable with CSS
60
+ * allows marking your books as loaned, each with the loan-date and
61
+ the name of the person who has borrowed them
62
+ * features a HIG-compliant user interface
63
+ * shows books in different views (standard list or icons list),
64
+ that can be filtered and/or sorted
65
+ * handles book rating and notes
66
+ * supports CueCat and standard "keyboard wedge" barcode readers
67
+ * includes translations for several languages
68
+ * is documented in a complete manual (at the moment only in
69
+ English and Japanese)
70
+
71
+ Alexandria is not without problems. See [doc/BUGS](doc/BUGS) for a
72
+ summary of issues.
72
73
 
73
74
  ## Installation
74
75
 
75
76
  There are full instructions for installing Alexandria from source in the
76
- file INSTALL, including information about all the dependencies.
77
+ file [INSTALL](INSTALL), including information about all the dependencies.
77
78
 
78
79
  If you are installing on a Debian-based system, things should be
79
80
  easier as the dependencies can be handled automatically.
80
81
 
81
82
  To run the program, just type
82
- alexandria
83
+ `alexandria`
83
84
  or, to get verbose debugging information,
84
- alexandria --debug
85
+ `alexandria --debug`
85
86
 
86
87
  If you are running GNOME, Alexandria should appear under the
87
88
  'Applications > Office' menu.
@@ -166,4 +167,4 @@ Copyright (C) 2005-2010,2014-2020 Alexandria Contributors
166
167
  Alexandria is free software; you can redistribute it and/or modify it under the
167
168
  terms of the GNU General Public License as published by the Free Software
168
169
  Foundation; either version 2 of the License, or (at your option) any later
169
- version. See the file COPYING for details.
170
+ version. See the file [COPYING](COPYING) for details.
data/Rakefile CHANGED
@@ -107,8 +107,10 @@ def convert_with_type(value, type)
107
107
  value.to_f
108
108
  when "bool"
109
109
  value == "true"
110
+ when "string"
111
+ value.to_s.strip
110
112
  else
111
- value.strip
113
+ raise NotImplementedError, "Unknown type #{type}"
112
114
  end
113
115
  end
114
116
 
@@ -117,14 +119,13 @@ SCHEMA_PATH = "schemas/alexandria.schemas"
117
119
  # This generates default_preferences.rb by copying over values from
118
120
  # providers_priority key in alexandria.schemas (necessary?)
119
121
 
120
- file "lib/alexandria/default_preferences.rb" => [SCHEMA_PATH] do |f|
122
+ file "lib/alexandria/default_preferences.rb" => ["Rakefile", SCHEMA_PATH] do |f|
121
123
  require "rexml/document"
122
124
  generated_lines = []
123
125
 
124
126
  doc = REXML::Document.new(IO.read(SCHEMA_PATH))
125
127
  doc.elements.each("gconfschemafile/schemalist/schema") do |element|
126
128
  default = element.elements["default"].text
127
- next unless default
128
129
 
129
130
  varname = File.basename(element.elements["key"].text)
130
131
  type = element.elements["type"].text
@@ -133,10 +134,11 @@ file "lib/alexandria/default_preferences.rb" => [SCHEMA_PATH] do |f|
133
134
  ary = default[1..-2].split(",")
134
135
  next if ary.empty?
135
136
 
136
- if type == "list"
137
+ case type
138
+ when "list"
137
139
  list_type = element.elements["list_type"].text
138
140
  ary.map! { |x| convert_with_type(x, list_type) }
139
- elsif type == "pair"
141
+ when "pair"
140
142
  next if ary.length != 2
141
143
 
142
144
  ary[0] = convert_with_type(ary[0],
@@ -45,19 +45,24 @@ Gem::Specification.new do |s|
45
45
  s.rdoc_options = ["--main", "README.md"]
46
46
 
47
47
  s.add_runtime_dependency("gettext", ["~> 3.1"])
48
- s.add_runtime_dependency("gstreamer", ["~> 3.4.1"])
49
- s.add_runtime_dependency("gtk3", ["~> 3.4.1"])
48
+ s.add_runtime_dependency("gstreamer", ["~> 3.4.3"])
49
+ s.add_runtime_dependency("gtk3", ["~> 3.4.3"])
50
50
  s.add_runtime_dependency("hpricot", ["~> 0.8.5"])
51
51
  s.add_runtime_dependency("htmlentities", ["~> 4.3"])
52
52
  s.add_runtime_dependency("image_size", ["~> 2.0"])
53
53
  s.add_runtime_dependency("marc", ["~> 1.0.0"])
54
- s.add_runtime_dependency("psych", ["~> 3.1.0"])
54
+ s.add_runtime_dependency("psych", ["~> 3.2.0"])
55
55
  s.add_runtime_dependency("zoom", ["~> 0.5.0"])
56
56
 
57
57
  s.add_development_dependency("gnome_app_driver", ["~> 0.2.1"])
58
58
  s.add_development_dependency("minitest", ["~> 5.0"])
59
59
  s.add_development_dependency("rake", ["~> 13.0"])
60
60
  s.add_development_dependency("rspec", ["~> 3.0"])
61
+ s.add_development_dependency("rubocop", "~> 0.93.1")
62
+ s.add_development_dependency("rubocop-i18n", ["~> 2.0.2"])
63
+ s.add_development_dependency("rubocop-performance", ["~> 1.8.0"])
64
+ s.add_development_dependency("rubocop-rspec", "~> 1.44.1")
65
+ s.add_development_dependency("webmock", "~> 3.9")
61
66
 
62
67
  s.require_paths = ["lib"]
63
68
  end
@@ -53,9 +53,28 @@
53
53
  :why:
54
54
  :versions: []
55
55
  :when: 2017-07-23 05:54:54.822319735 Z
56
- - - :approve
56
+ - - :license
57
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
58
71
  - :who:
59
- :why: Actually licensed under LGPL-2.1
72
+ :why:
73
+ :versions: []
74
+ :when: 2020-07-30 06:46:08.280121582 Z
75
+ - - :permit
76
+ - LGPL-2.1
77
+ - :who:
78
+ :why:
60
79
  :versions: []
61
- :when: 2017-07-23 06:00:43.594558953 Z
80
+ :when: 2020-07-30 06:46:32.729325577 Z
@@ -28,8 +28,8 @@ module Alexandria
28
28
  end
29
29
 
30
30
  def self.set_log_level
31
- Alexandria.log.level = Logger::DEBUG if $DEBUG
32
- Alexandria.log.debug { "Initializing Alexandria..." }
31
+ log.level = Logger::DEBUG if $DEBUG
32
+ log.debug { "Initializing Alexandria" }
33
33
  end
34
34
 
35
35
  def self.main
@@ -36,20 +36,21 @@ module Alexandria
36
36
 
37
37
  class SearchError < StandardError; end
38
38
  class NoResultsError < SearchError; end
39
- class ProviderSkippedError < NoResultsError; end # not an error :^(
40
- class SearchEmptyError < SearchError; end # sigh, again not really an error
41
39
  class TooManyResultsError < SearchError; end
42
40
  class InvalidSearchTypeError < SearchError; end
43
41
 
42
+ # These errors are not really errors
43
+ class ProviderSkippedError < NoResultsError; end
44
+ class SearchEmptyError < SearchError; end
45
+
44
46
  def self.search(criterion, type)
45
47
  factory_n = 0
46
- # puts "book_providers search #{self.instance.count_observers}"
47
48
 
48
49
  begin
49
50
  factory = instance[factory_n]
50
- puts factory.fullname + " lookup" if $DEBUG
51
+ log.debug { factory.fullname + " lookup" }
51
52
  unless factory.enabled
52
- puts factory.fullname + " disabled!, skipping..." if $DEBUG
53
+ log.debug { factory.fullname + " disabled!, skipping..." }
53
54
  raise ProviderSkippedError
54
55
  end
55
56
  instance.changed
@@ -83,7 +84,7 @@ module Alexandria
83
84
  trace = ex.backtrace.join("\n >")
84
85
  log.warn { "Provider #{factory.name} encountered error: #{ex.message} #{trace}" }
85
86
  end
86
- if last == factory
87
+ if factory == instance.last
87
88
  log.warn { "Error while searching #{criterion}" }
88
89
  message = case ex
89
90
  when Timeout::Error
@@ -113,8 +114,8 @@ module Alexandria
113
114
  else
114
115
  ex.message
115
116
  end
116
- puts "raising empty error #{message}"
117
- raise SearchEmptyError, message
117
+ log.debug { "raising empty error #{message}" }
118
+ raise SearchEmptyError, message # rubocop:disable GetText/DecorateFunctionMessage
118
119
  else
119
120
  factory_n += 1
120
121
  retry
@@ -152,9 +153,8 @@ module Alexandria
152
153
  end
153
154
 
154
155
  def new_value=(new_value)
155
- message = @provider.variable_name(self) + "="
156
- Alexandria::Preferences.instance.send(message,
157
- new_value)
156
+ name = @provider.variable_name(self)
157
+ Alexandria::Preferences.instance.set_variable(name, new_value)
158
158
  self.value = new_value
159
159
  end
160
160
 
@@ -187,8 +187,8 @@ module Alexandria
187
187
 
188
188
  def read
189
189
  each do |var|
190
- message = @provider.variable_name(var)
191
- val = Alexandria::Preferences.instance.send(message)
190
+ name = @provider.variable_name(var)
191
+ val = Alexandria::Preferences.instance.get_variable(name)
192
192
  var.value = val unless val.nil? || ((val == "") && var.mandatory?)
193
193
  end
194
194
  end
@@ -216,22 +216,22 @@ module Alexandria
216
216
  end
217
217
 
218
218
  def reinitialize(fullname)
219
- @name << "_" << fullname.hash.to_s
219
+ @name = "#{name}_#{fullname.hash}"
220
220
  @fullname = fullname
221
221
  prefs = Alexandria::Preferences.instance
222
- ary = prefs.abstract_providers
222
+ ary = prefs.get_variable :abstract_providers
223
223
  ary ||= []
224
224
  ary << @name
225
- prefs.abstract_providers = ary
226
- message = variable_name("name") + "="
227
- prefs.send(message, @fullname)
225
+ prefs.set_variable :abstract_providers, ary
226
+ message = variable_name("name")
227
+ prefs.set_variable(message, @fullname)
228
228
  end
229
229
 
230
230
  def remove
231
231
  prefs = Alexandria::Preferences.instance
232
- if (ary = prefs.abstract_providers)
232
+ if (ary = prefs.get_variable :abstract_providers)
233
233
  ary.delete(@name)
234
- prefs.abstract_providers = ary
234
+ prefs.set_variable :abstract_providers, ary
235
235
  end
236
236
  if (ary = prefs.providers_priority) && ary.include?(@name)
237
237
  ary.delete(@name)
@@ -271,8 +271,8 @@ module Alexandria
271
271
  !included_modules.include?(Singleton)
272
272
  end
273
273
 
274
- def <=>(provider)
275
- fullname <=> provider.fullname
274
+ def <=>(other)
275
+ fullname <=> other.fullname
276
276
  end
277
277
 
278
278
  # FIXME: Clean up this complex abstract/concrete class system
@@ -325,10 +325,9 @@ module Alexandria
325
325
  next unless md
326
326
 
327
327
  klass = self.class.module_eval(constant.to_s)
328
- if klass.ancestors.include?(AbstractProvider) &&
328
+ if klass < AbstractProvider &&
329
329
  (klass != GenericProvider) &&
330
- (klass != WebsiteBasedProvider) &&
331
- (klass != AbstractProvider)
330
+ (klass != WebsiteBasedProvider)
332
331
 
333
332
  if klass.abstract?
334
333
  @abstract_classes << klass
@@ -337,7 +336,7 @@ module Alexandria
337
336
  end
338
337
  end
339
338
  end
340
- if (ary = @prefs.abstract_providers)
339
+ if (ary = @prefs.get_variable :abstract_providers)
341
340
  ary.each do |name|
342
341
  md = /^(.+)_/.match(name)
343
342
  next unless md
@@ -366,37 +365,36 @@ module Alexandria
366
365
  compact!
367
366
  end
368
367
 
369
- # FIXME: Define the handful of methods that use this.
370
- def self.method_missing(id, *args, &block)
371
- if instance.respond_to? id
372
- instance.method(id).call(*args, &block)
373
- else
374
- super
375
- end
368
+ def self.list
369
+ instance
370
+ end
371
+
372
+ def self.abstract_classes
373
+ instance.abstract_classes
376
374
  end
377
375
 
378
376
  private
379
377
 
380
378
  def rejig_providers_priority
381
379
  priority = (@prefs.providers_priority || [])
382
- unless priority.empty?
383
- changed = false
380
+ return if priority.empty?
384
381
 
385
- if (ecs_index = priority.index("AmazonECS"))
386
- priority[ecs_index] = "Amazon" # replace legacy "AmazonECS" name
387
- priority.uniq! # remove any other "Amazon" from the list
388
- changed = true
389
- end
390
- if (worldcat_index = priority.index("Worldcat"))
391
- priority[worldcat_index] = "WorldCat"
392
- changed = true
393
- end
394
- if (adlibris_index = priority.index("Adlibris"))
395
- priority[adlibris_index] = "AdLibris"
396
- changed = true
397
- end
398
- @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
399
396
  end
397
+ @prefs.providers_priority = priority if changed
400
398
  end
401
399
  end
402
400
  end