alexandria-book-collection-manager 0.7.5 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/ruby.yml +72 -0
  4. data/.gitignore +4 -1
  5. data/.rubocop.yml +65 -30
  6. data/.rubocop_todo.yml +49 -165
  7. data/.simplecov +5 -2
  8. data/CHANGELOG.md +64 -0
  9. data/ChangeLog.0 +19 -19
  10. data/INSTALL.md +26 -16
  11. data/README.md +31 -35
  12. data/Rakefile +18 -16
  13. data/alexandria-book-collection-manager.gemspec +35 -29
  14. data/doc/FAQ +2 -2
  15. data/doc/dependency_decisions.yml +22 -3
  16. data/lib/alexandria/about.rb +1 -1
  17. data/lib/alexandria/book_providers/bl_provider.rb +88 -0
  18. data/lib/alexandria/book_providers/douban.rb +2 -2
  19. data/lib/alexandria/book_providers/loc_provider.rb +38 -0
  20. data/lib/alexandria/book_providers/pseudomarc.rb +61 -71
  21. data/lib/alexandria/book_providers/sbn_provider.rb +108 -0
  22. data/lib/alexandria/book_providers/{thalia.rb → thalia_provider.rb} +37 -74
  23. data/lib/alexandria/book_providers/web.rb +2 -2
  24. data/lib/alexandria/book_providers/worldcat.rb +34 -38
  25. data/lib/alexandria/book_providers/z3950_provider.rb +199 -0
  26. data/lib/alexandria/book_providers.rb +48 -65
  27. data/lib/alexandria/default_preferences.rb +2 -1
  28. data/lib/alexandria/execution_queue.rb +13 -12
  29. data/lib/alexandria/export_library.rb +21 -22
  30. data/lib/alexandria/image_fetcher.rb +25 -0
  31. data/lib/alexandria/import_library.rb +46 -70
  32. data/lib/alexandria/import_library_csv.rb +16 -16
  33. data/lib/alexandria/library_sort_order.rb +3 -1
  34. data/lib/alexandria/library_store.rb +19 -20
  35. data/lib/alexandria/logging.rb +5 -9
  36. data/lib/alexandria/models/book.rb +15 -2
  37. data/lib/alexandria/models/library.rb +31 -35
  38. data/lib/alexandria/net.rb +1 -2
  39. data/lib/alexandria/preferences.rb +27 -33
  40. data/lib/alexandria/scanners/cue_cat.rb +6 -6
  41. data/lib/alexandria/scanners/keyboard.rb +1 -1
  42. data/lib/alexandria/scanners.rb +2 -2
  43. data/lib/alexandria/smart_library.rb +22 -26
  44. data/lib/alexandria/ui/about_dialog.rb +1 -1
  45. data/lib/alexandria/ui/acquire_dialog.rb +15 -19
  46. data/lib/alexandria/ui/alert_dialog.rb +36 -19
  47. data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
  48. data/lib/alexandria/ui/barcode_animation.rb +6 -6
  49. data/lib/alexandria/ui/book_properties_dialog.rb +2 -3
  50. data/lib/alexandria/ui/book_properties_dialog_base.rb +35 -137
  51. data/lib/alexandria/ui/calendar_popup.rb +58 -0
  52. data/lib/alexandria/ui/callbacks.rb +144 -123
  53. data/lib/alexandria/ui/completion_models.rb +2 -6
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +2 -2
  56. data/lib/alexandria/ui/error_dialog.rb +1 -1
  57. data/lib/alexandria/ui/export_dialog.rb +19 -18
  58. data/lib/alexandria/ui/icons.rb +34 -40
  59. data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
  60. data/lib/alexandria/ui/import_dialog.rb +49 -48
  61. data/lib/alexandria/ui/init.rb +14 -12
  62. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
  63. data/lib/alexandria/ui/libraries_combo.rb +10 -9
  64. data/lib/alexandria/ui/listview.rb +6 -7
  65. data/lib/alexandria/ui/main_app.rb +2 -2
  66. data/lib/alexandria/ui/multi_drag_treeview.rb +5 -7
  67. data/lib/alexandria/ui/new_book_dialog.rb +63 -65
  68. data/lib/alexandria/ui/new_book_dialog_manual.rb +1 -1
  69. data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
  70. data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
  71. data/lib/alexandria/ui/preferences_dialog.rb +25 -84
  72. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +10 -6
  73. data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
  74. data/lib/alexandria/ui/really_delete_dialog.rb +2 -2
  75. data/lib/alexandria/ui/sidepane_manager.rb +38 -38
  76. data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
  77. data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
  78. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +61 -244
  79. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  80. data/lib/alexandria/ui/sound.rb +4 -6
  81. data/lib/alexandria/ui/ui_manager.rb +80 -83
  82. data/lib/alexandria/ui.rb +7 -7
  83. data/lib/alexandria/version.rb +2 -2
  84. data/lib/alexandria/web_themes.rb +15 -15
  85. data/lib/alexandria.rb +2 -2
  86. data/po/cs.po +947 -865
  87. data/po/cy.po +913 -864
  88. data/po/de.po +961 -865
  89. data/po/el.po +956 -861
  90. data/po/es.po +952 -857
  91. data/po/fr.po +950 -865
  92. data/po/ga.po +866 -819
  93. data/po/gl.po +946 -861
  94. data/po/it.po +945 -858
  95. data/po/ja.po +921 -836
  96. data/po/mk.po +953 -858
  97. data/po/nb.po +932 -847
  98. data/po/nl.po +955 -849
  99. data/po/pl.po +999 -963
  100. data/po/pt.po +946 -850
  101. data/po/pt_BR.po +944 -859
  102. data/po/ru.po +959 -868
  103. data/po/sk.po +950 -863
  104. data/po/sv.po +944 -859
  105. data/po/uk.po +925 -846
  106. data/po/zh_TW.po +926 -841
  107. data/schemas/alexandria.schemas +1 -1
  108. data/share/alexandria/glade/main_app__builder.glade +6 -21
  109. data/share/gnome/help/alexandria/C/adding-books.xml +3 -4
  110. data/share/gnome/help/alexandria/C/introduction.xml +0 -16
  111. data/share/gnome/help/alexandria/C/searching.xml +1 -4
  112. data/share/gnome/help/alexandria/C/settings.xml +0 -30
  113. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  114. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  115. data/share/gnome/help/alexandria/fr/alexandria.xml +5 -160
  116. data/share/gnome/help/alexandria/ja/adding-books.xml +1 -1
  117. data/share/gnome/help/alexandria/ja/introduction.xml +0 -15
  118. data/share/gnome/help/alexandria/ja/searching.xml +3 -7
  119. data/share/gnome/help/alexandria/ja/settings.xml +0 -27
  120. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  121. data/spec/alexandria/book_providers/bl_provider_spec.rb +13 -0
  122. data/spec/alexandria/book_providers/loc_provider_spec.rb +17 -0
  123. data/spec/alexandria/book_providers/sbn_provider_spec.rb +13 -0
  124. data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
  125. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  126. data/spec/alexandria/book_providers_spec.rb +0 -154
  127. data/spec/alexandria/console_spec.rb +0 -5
  128. data/spec/alexandria/export_library_spec.rb +27 -38
  129. data/spec/alexandria/library_spec.rb +76 -46
  130. data/spec/alexandria/preferences_spec.rb +29 -3
  131. data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
  132. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  133. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  134. data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
  135. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  136. data/spec/alexandria/ui/book_properties_dialog_spec.rb +47 -5
  137. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
  138. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  139. data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
  140. data/spec/alexandria/ui/export_dialog_spec.rb +25 -4
  141. data/spec/alexandria/ui/icons_spec.rb +26 -0
  142. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  143. data/spec/alexandria/ui/import_dialog_spec.rb +35 -3
  144. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  145. data/spec/alexandria/ui/main_app_spec.rb +1 -1
  146. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +39 -3
  147. data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
  148. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
  149. data/spec/alexandria/ui/preferences_dialog_spec.rb +2 -2
  150. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
  151. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  152. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  153. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
  154. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +37 -6
  155. data/spec/alexandria/ui/ui_manager_spec.rb +116 -2
  156. data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +2 -0
  157. data/spec/end_to_end/basic_run_spec.rb +3 -8
  158. data/spec/fixtures/cover.jpg +0 -0
  159. data/spec/spec_helper.rb +47 -3
  160. data/tasks/spec.rake +3 -5
  161. data/util/rake/fileinstall.rb +16 -15
  162. data/util/rake/omfgenerate.rb +1 -1
  163. metadata +141 -52
  164. data/.travis.yml +0 -39
  165. data/lib/alexandria/book_providers/adlibris.rb +0 -196
  166. data/lib/alexandria/book_providers/amazon_aws.rb +0 -252
  167. data/lib/alexandria/book_providers/amazon_ecs_util.rb +0 -388
  168. data/lib/alexandria/book_providers/barnes_and_noble.rb +0 -209
  169. data/lib/alexandria/book_providers/proxis.rb +0 -175
  170. data/lib/alexandria/book_providers/siciliano.rb +0 -257
  171. data/lib/alexandria/book_providers/z3950.rb +0 -415
  172. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  173. data/spec/alexandria/utilities_spec.rb +0 -52
@@ -1,415 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is part of Alexandria.
4
- #
5
- # See the file README.md for authorship and licensing information.
6
-
7
- ## $Z3950_DEBUG = $DEBUG
8
-
9
- require "zoom"
10
- require "alexandria/book_providers/pseudomarc"
11
- require "marc"
12
-
13
- module Alexandria
14
- class BookProviders
15
- class Z3950Provider < AbstractProvider
16
- include Logging
17
- include GetText
18
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
19
-
20
- def initialize(name = "Z3950", fullname = "Z39.50")
21
- super
22
- prefs.add("hostname", _("Hostname"), "")
23
- prefs.add("port", _("Port"), 7090)
24
- prefs.add("database", _("Database"), "")
25
- prefs.add("record_syntax", _("Record syntax"), "USMARC",
26
- ["USMARC", "UNIMARC", "SUTRS"])
27
- prefs.add("username", _("Username"), "", nil, false)
28
- prefs.add("password", _("Password"), "", nil, false)
29
- prefs.add("charset", _("Charset encoding"), "ISO-8859-1")
30
-
31
- # HACK : piggybacking support
32
- prefs.add("piggyback", "Piggyback", true, [true, false])
33
- prefs.read
34
- end
35
-
36
- def search(criterion, type)
37
- prefs.read
38
- criterion = criterion.encode(prefs["charset"])
39
-
40
- # We only decode MARC at the moment.
41
- # SUTRS needs to be decoded separately, because each Z39.50 server has a
42
- # different one.
43
- raise NoResultsError unless marc?
44
-
45
- isbn = type == SEARCH_BY_ISBN ? criterion : nil
46
- criterion = Library.canonicalise_isbn(criterion) if type == SEARCH_BY_ISBN
47
- conn_count = type == SEARCH_BY_ISBN ? 1 : 10 # results to retrieve
48
- resultset = search_records(criterion, type, conn_count)
49
- log.debug { "total #{resultset.length}" }
50
- raise NoResultsError if resultset.length == 0
51
-
52
- results = books_from_marc(resultset, isbn)
53
- type == SEARCH_BY_ISBN ? results.first : results
54
- end
55
-
56
- def url(_book)
57
- nil
58
- end
59
-
60
- private
61
-
62
- def marc_to_book(marc_txt)
63
- begin
64
- marc = MARC::Record.new_from_marc(marc_txt, forgiving: true)
65
- rescue StandardError => ex
66
- log.error { ex.message }
67
- log.error { ex.backtrace.join("> \n") }
68
- begin
69
- marc = MARC::Record.new(marc_txt)
70
- rescue StandardError => ex
71
- log.error { ex.message }
72
- log.error { ex.backtrace.join("> \n") }
73
- raise ex
74
- end
75
- end
76
-
77
- log.debug do
78
- msg = "Parsing MARC"
79
- msg += "\n title: #{marc.title}"
80
- msg += "\n authors: #{marc.authors.join(', ')}"
81
- msg += "\n isbn: #{marc.isbn}, #{isbn}"
82
- msg += "\n publisher: #{marc.publisher}"
83
- msg += "\n publish year: #{marc.publish_year}" if marc.respond_to?(:publish_year)
84
- msg += "\n edition: #{marc.edition}"
85
- msg
86
- end
87
-
88
- return if marc.title.nil? # or marc.authors.empty?
89
-
90
- (isbn = isbn) || marc.isbn
91
- isbn = Library.canonicalise_ean(isbn)
92
-
93
- book = Book.new(marc.title, marc.authors,
94
- isbn,
95
- (marc.publisher || ""),
96
- marc.respond_to?(:publish_year) ? marc.publish_year.to_i : nil,
97
- (marc.edition || ""))
98
- book
99
- end
100
-
101
- def books_from_marc(resultset, _isbn)
102
- results = []
103
- resultset[0..9].each do |record|
104
- marc_txt = record.render(prefs["charset"], "UTF-8")
105
- log.debug { marc_txt }
106
- if $DEBUG
107
- File.open(",marc.txt", "wb") do |f| # DEBUG
108
- f.write(marc_txt)
109
- end
110
- end
111
- book = nil
112
- begin
113
- mappings = Alexandria::PseudoMarcParser::USMARC_MAPPINGS
114
- if prefs["hostname"] == "z3950.bnf.fr"
115
- mappings = Alexandria::PseudoMarcParser::BNF_FR_MAPPINGS
116
- end
117
- # try pseudo-marc parser first (it seems to have more luck)
118
- book = Alexandria::PseudoMarcParser.marc_text_to_book(marc_txt,
119
- mappings)
120
- if book.nil?
121
- # failing that, try the genuine MARC parser
122
- book = marc_to_book(marc_txt)
123
- end
124
- rescue StandardError => ex
125
- log.warn { ex }
126
- log.warn { ex.backtrace }
127
- end
128
-
129
- results << [book] unless book.nil?
130
- end
131
- results
132
- end
133
-
134
- def marc?
135
- /MARC$/.match(prefs["record_syntax"])
136
- end
137
-
138
- def search_records(criterion, type, conn_count)
139
- options = {}
140
- unless prefs["username"].empty? || prefs["password"].empty?
141
- options["user"] = prefs["username"]
142
- options["password"] = prefs["password"]
143
- end
144
- hostname = prefs["hostname"]
145
- port = prefs["port"].to_i
146
- log.debug { "hostname #{hostname} port #{port} options #{options}" }
147
- conn = ZOOM::Connection.new(options).connect(hostname, port)
148
- conn.database_name = prefs["database"]
149
-
150
- # HACK: turn off piggybacking, just to see CMcG
151
- # #conn.piggyback = false
152
-
153
- conn.preferred_record_syntax = prefs["record_syntax"]
154
- conn.element_set_name = "F"
155
- conn.count = conn_count
156
- attr = case type
157
- when SEARCH_BY_ISBN then [7]
158
- when SEARCH_BY_TITLE then [4]
159
- when SEARCH_BY_AUTHORS then [1, 1003]
160
- when SEARCH_BY_KEYWORD then [1016]
161
- end
162
- pqf = ""
163
- attr.each { |att| pqf += "@attr 1=#{att} " }
164
- pqf += '"' + criterion.upcase + '"'
165
- log.debug { "pqf is #{pqf}, syntax #{prefs['record_syntax']}" }
166
-
167
- begin
168
- if prefs.variable_named("piggyback")
169
- unless prefs["piggyback"]
170
- log.debug { "setting conn.piggyback to false" }
171
- conn.piggyback = false
172
- end
173
- end
174
- conn.search(pqf)
175
- rescue StandardError => ex
176
- if /1005/.match?(ex.message)
177
- if prefs.variable_named("piggyback") && prefs["piggyback"]
178
- log.error { "Z39.50 search failed:: #{ex.message}" }
179
- log.info { "Turning off piggybacking for this provider" }
180
- prefs.variable_named("piggyback").new_value = false
181
- search_records(criterion, type, conn_count)
182
- # hopefully these precautions will prevent infinite loops here
183
- else
184
- raise ex
185
- end
186
- else
187
- raise ex
188
- end
189
- end
190
- end
191
- end
192
-
193
- class LOCProvider < Z3950Provider
194
- # http://en.wikipedia.org/wiki/Library_of_Congress
195
- unabstract
196
-
197
- include GetText
198
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
199
-
200
- def initialize
201
- super("LOC", _("Library of Congress (Usa)"))
202
- prefs.variable_named("hostname").default_value = "z3950.loc.gov"
203
- prefs.variable_named("port").default_value = 7090
204
- prefs.variable_named("database").default_value = "Voyager"
205
- prefs.variable_named("record_syntax").default_value = "USMARC"
206
- prefs.variable_named("charset").default_value = "ISO-8859-1"
207
- prefs.read
208
- end
209
-
210
- def url(book)
211
- isbn = Library.canonicalise_isbn(book.isbn)
212
- "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?" \
213
- "DB=local&CNT=25+records+per+page&CMD=isbn+#{isbn}"
214
- rescue StandardError => ex
215
- log.warn { "Cannot create url for book #{book}; #{ex.message}" }
216
- nil
217
- end
218
- end
219
-
220
- class BLProvider < Z3950Provider
221
- # http://en.wikipedia.org/wiki/Copac
222
- # http://en.wikipedia.org/wiki/British_Library
223
- # http://www.bl.uk/catalogues/z3950fullaccess.html
224
- # http://www.bl.uk/catalogues/z3950copacaccess.html
225
- #
226
- # FIXME: switch from BL to Copac, which incudes the BL itself and many more
227
- # libraries: http://copac.ac.uk/libraries/
228
- #
229
- # Details: http://copac.ac.uk/interfaces/z39.50/
230
- # The SUTRS format used by Copac is different from the one used by BL
231
- unabstract
232
-
233
- include GetText
234
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
235
-
236
- def initialize
237
- super("BL", _("British Library"))
238
- prefs.variable_named("hostname").default_value = "z3950cat.bl.uk"
239
- prefs.variable_named("port").default_value = 9909
240
- prefs.variable_named("database").default_value = "BLAC"
241
- prefs.variable_named("record_syntax").default_value = "SUTRS"
242
- prefs.variable_named("charset").default_value = "ISO-8859-1"
243
- prefs.read
244
- end
245
-
246
- def search(criterion, type)
247
- return super unless prefs["record_syntax"] == "SUTRS"
248
-
249
- prefs.read
250
- criterion = Library.canonicalise_isbn(criterion) if type == SEARCH_BY_ISBN
251
- conn_count = type == SEARCH_BY_ISBN ? 1 : 10 # results to retrieve
252
- resultset = search_records(criterion, type, conn_count)
253
- log.debug { "total #{resultset.length}" }
254
- raise NoResultsError if resultset.length == 0
255
-
256
- results = books_from_sutrs(resultset)
257
- type == SEARCH_BY_ISBN ? results.first : results
258
- end
259
-
260
- def url(book)
261
- "http://copac.ac.uk/openurl?isbn=" + Library.canonicalise_isbn(book.isbn)
262
- rescue StandardError => ex
263
- log.warn { "Cannot create url for book #{book}; #{ex.message}" }
264
- nil
265
- end
266
-
267
- private
268
-
269
- def books_from_sutrs(resultset)
270
- results = []
271
- resultset[0..9].each do |record|
272
- text = record.render(prefs["charset"], "UTF-8")
273
- # File.open(',bl.marc', 'wb') {|f| f.write(text) }
274
- log.debug { text }
275
-
276
- title = isbn = publisher = publish_year = edition = nil
277
- authors = []
278
-
279
- text.split(/\n/).each do |line|
280
- if (md = /^Title:\s+(.*)$/.match(line))
281
- title = md[1].sub(/\.$/, "").squeeze(" ")
282
- elsif (md = /^Added Person Name:\s+(.*),[^,]+$/.match(line))
283
- authors << md[1]
284
- elsif (md = /^ME-Personal Name:\s+(.*),[^,]+$/.match(line))
285
- authors << md[1]
286
- elsif (md = /^ISBN:\s+([\dXx]+)/.match(line))
287
- isbn = Library.canonicalise_ean(md[1])
288
- elsif (md = /^Imprint:.+\:\s*(.+)\,/.match(line))
289
- publisher = md[1]
290
- end
291
- end
292
-
293
- log.debug do
294
- msg = "Parsing SUTRS"
295
- msg += "\n title: #{title}"
296
- msg += "\n authors: #{authors.join(' and ')}"
297
- msg += "\n isbn: #{isbn}"
298
- msg += "\n publisher: #{publisher}"
299
- msg += "\n edition: #{edition}"
300
- msg
301
- end
302
-
303
- if title # and !authors.empty?
304
- book = Book.new(title, authors, isbn, (publisher || nil),
305
- (publish_year || nil), (edition || nil))
306
- results << [book]
307
- end
308
- end
309
- results
310
- end
311
- end
312
-
313
- class SBNProvider < Z3950Provider
314
- # http://sbnonline.sbn.it/
315
- # http://it.wikipedia.org/wiki/ICCU
316
- unabstract
317
-
318
- include GetText
319
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
320
-
321
- def initialize
322
- super("SBN", "Servizio Bibliotecario Nazionale (Italy)")
323
- prefs.variable_named("hostname").default_value = "opac.sbn.it"
324
- prefs.variable_named("port").default_value = 3950
325
- prefs.variable_named("database").default_value = "nopac"
326
- # supported 'USMARC', 'UNIMARC' , 'SUTRS'
327
- prefs.variable_named("record_syntax").default_value = "USMARC"
328
- prefs.variable_named("charset").default_value = "ISO-8859-1"
329
- prefs.read
330
- end
331
-
332
- def search(criterion, type)
333
- prefs.read
334
-
335
- isbn = type == SEARCH_BY_ISBN ? criterion : nil
336
- criterion = canonicalise_isbn_with_dashes(criterion)
337
- resultset = search_records(criterion, type, 0)
338
- log.debug { "total #{resultset.length}" }
339
- raise NoResultsError if resultset.length == 0
340
-
341
- results = books_from_marc(resultset, isbn)
342
- type == SEARCH_BY_ISBN ? results.first : results
343
- end
344
-
345
- def url(book)
346
- "http://sbnonline.sbn.it/cgi-bin/zgw/BRIEF.pl?displayquery=" \
347
- "%253CB%253E%253Cfont%2520color%253D%2523000064%253E" \
348
- "Codice%2520ISBN%253C%2FB%253E%253C%2Ffont%253E%2520" \
349
- "contiene%2520%2522%2520%253CFONT%2520COLOR%253Dred%253E" +
350
- canonicalise_isbn_with_dashes(book.isbn) +
351
- "%253C%2FFONT%253E%2522&session=&zurl=opac" \
352
- "&zquery=%281%3D7+4%3D2+2%3D3+5%3D100+6%3D1+3%3D3+%22" +
353
- canonicalise_isbn_with_dashes(book.isbn) +
354
- "%22%29&language=it&maxentries=10&target=0&position=1"
355
- rescue StandardError => ex
356
- log.warn { "Cannot create url for book #{book}; #{ex.message}" }
357
- nil
358
- end
359
-
360
- private
361
-
362
- def canonicalise_isbn_with_dashes(isbn)
363
- # The reference for the position of the dashes is
364
- # http://www.isbn-international.org/converter/ranges.htm
365
-
366
- isbn = Alexandria::Library.canonicalise_isbn(isbn)
367
-
368
- if isbn[0..1] == "88"
369
- # Italian speaking area
370
- if isbn > "8895000" && (isbn <= "8899999996")
371
- isbn[0..1] + "-" + isbn[2..6] + "-" + isbn[7..8] + "-" + isbn[9..9]
372
- elsif isbn > "88900000"
373
- isbn[0..1] + "-" + isbn[2..7] + "-" + isbn[8..8] + "-" + isbn[9..9]
374
- elsif isbn > "8885000"
375
- isbn[0..1] + "-" + isbn[2..6] + "-" + isbn[7..8] + "-" + isbn[9..9]
376
- elsif isbn > "886000"
377
- isbn[0..1] + "-" + isbn[2..5] + "-" + isbn[6..8] + "-" + isbn[9..9]
378
- elsif isbn > "88200"
379
- isbn[0..1] + "-" + isbn[2..4] + "-" + isbn[5..8] + "-" + isbn[9..9]
380
- elsif isbn > "8800"
381
- isbn[0..1] + "-" + isbn[2..3] + "-" + isbn[4..8] + "-" + isbn[9..9]
382
- else
383
- raise "Invalid ISBN"
384
- end
385
-
386
- else
387
- isbn
388
- end
389
- end
390
- #
391
- # Remarks about SBN
392
- #
393
- # This provider requires that value of conn.count is 0.
394
- # It's a Yaz option "Number of records to be retrieved".
395
- # This provider requires to specify the value of conn.element_set_name = 'F'.
396
- # It's a Yaz option "Element-Set name of records".
397
- # See http://www.indexdata.dk/yaz/doc/zoom.resultsets.tkl
398
- #
399
- # Dashes:
400
- # this database requires that Italian books are searched with dashes :(
401
- # However, they have also books with dashes in wrong positions, for
402
- # instance 88-061-4934-2
403
- #
404
- # References:
405
- # http://opac.internetculturale.it/cgi-bin/main.cgi?type=field
406
- # http://www.internetculturale.it/
407
- # http://sbnonline.sbn.it/zgw/homeit.html
408
- # http://www.iccu.sbn.it/genera.jsp?id=124
409
- # with link at http://www.iccu.sbn.it/upload/documenti/cartecsbn.pdf
410
- # http://www.loc.gov/cgi-bin/zgstart?ACTION=INIT&FORM_HOST_PORT=/prod/www/data/z3950/iccu.html,opac.sbn.it,2100
411
- # http://gwz.cilea.it/cgi-bin/reportOpac.cgi
412
- #
413
- end
414
- end
415
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (C) 2007 Joseph Method
4
- # Copyright (C) 2011, 2014-2016 Matijs van Zuijlen
5
- #
6
- # Alexandria is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU General Public License as
8
- # published by the Free Software Foundation; either version 2 of the
9
- # License, or (at your option) any later version.
10
- #
11
- # Alexandria is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public
17
- # License along with Alexandria; see the file COPYING. If not,
18
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
- # Fifth Floor, Boston, MA 02110-1301 USA.
20
-
21
- require File.dirname(__FILE__) + "/../../spec_helper"
22
-
23
- # from completion_models
24
- describe Gtk::Entry do
25
- it "should extend Gtk::Entry"
26
- end
27
-
28
- describe Alexandria::UI::CompletionModels do
29
- it "should work"
30
- end
31
-
32
- # from glade_base
33
-
34
- describe Alexandria::UI::BuilderBase do
35
- it "should be revisited"
36
- end
37
-
38
- # from icons
39
-
40
- describe GdkPixbuf::Pixbuf do
41
- it "should extend GdkPixbuf::PixBuf"
42
- end
43
-
44
- describe Alexandria::UI::Icons do
45
- it "should aid identification"
46
- end
47
-
48
- # from libraries_combo
49
-
50
- describe Gtk::ComboBox do
51
- it "should extend Gtk::ComboBox"
52
- end
53
-
54
- # from multi_drag_treeview
55
-
56
- describe Gdk::Event do
57
- it "should extend Gdk::Event"
58
- end
59
-
60
- describe Gtk::TreeView do
61
- it "should extend Gtk::TreeView"
62
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (C) 2007 Joseph Method
4
- #
5
- # Alexandria is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License as
7
- # published by the Free Software Foundation; either version 2 of the
8
- # License, or (at your option) any later version.
9
- #
10
- # Alexandria is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public
16
- # License along with Alexandria; see the file COPYING. If not,
17
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
- # Fifth Floor, Boston, MA 02110-1301 USA.
19
-
20
- require File.dirname(__FILE__) + "/../spec_helper"
21
-
22
- describe Alexandria::ExecutionQueue do
23
- it "should not have so many u's and e's"
24
- end
25
-
26
- describe Alexandria::ExportFormat do
27
- it "should justify its existence"
28
- end
29
-
30
- describe Alexandria::ImportFilter do
31
- it "should justify its 'importance'"
32
- end
33
-
34
- describe Alexandria::Logger do
35
- it "should fulfill its function"
36
- end
37
-
38
- describe Alexandria::UndoManager do
39
- it "should make right what is wrong"
40
- end
41
-
42
- describe Time do
43
- it "should clarify what it's doing"
44
- end
45
-
46
- describe String do
47
- it "should do what it does"
48
- end
49
-
50
- describe Alexandria::WebTheme do
51
- it "should be themeable"
52
- end