alexandria-book-collection-manager 0.6.9.pre1 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -4
- data/.rubocop_todo.yml +21 -79
- data/CHANGELOG.md +9 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/alexandria-book-collection-manager.gemspec +26 -4
- data/bin/alexandria +1 -1
- data/doc/AUTHORS +2 -1
- data/lib/alexandria.rb +1 -1
- data/lib/alexandria/about.rb +6 -6
- data/lib/alexandria/book_providers.rb +1 -1
- data/lib/alexandria/book_providers/adlibris.rb +4 -4
- data/lib/alexandria/book_providers/barnes_and_noble.rb +9 -5
- data/lib/alexandria/book_providers/bol_it.rb +0 -2
- data/lib/alexandria/book_providers/ibs_it.rb +0 -2
- data/lib/alexandria/book_providers/mcu.rb +3 -5
- data/lib/alexandria/book_providers/proxis.rb +1 -5
- data/lib/alexandria/book_providers/renaud.rb +0 -2
- data/lib/alexandria/book_providers/thalia.rb +10 -8
- data/lib/alexandria/book_providers/webster_it.rb +0 -2
- data/lib/alexandria/book_providers/worldcat.rb +8 -4
- data/lib/alexandria/book_providers/z3950.rb +2 -8
- data/lib/alexandria/execution_queue.rb +1 -3
- data/lib/alexandria/export_library.rb +2 -7
- data/lib/alexandria/import_library.rb +1 -6
- data/lib/alexandria/logging.rb +1 -1
- data/lib/alexandria/models/book.rb +2 -2
- data/lib/alexandria/models/library.rb +5 -7
- data/lib/alexandria/preferences.rb +1 -1
- data/lib/alexandria/scanners.rb +4 -3
- data/lib/alexandria/scanners/cuecat.rb +1 -1
- data/lib/alexandria/smart_library.rb +4 -3
- data/lib/alexandria/ui/callbacks.rb +2 -2
- data/lib/alexandria/ui/completion_models.rb +22 -19
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +2 -4
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +1 -1
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +1 -3
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +0 -4
- data/lib/alexandria/ui/dialogs/export_dialog.rb +1 -3
- data/lib/alexandria/ui/dialogs/import_dialog.rb +4 -4
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +8 -11
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +4 -5
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +15 -9
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +20 -23
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +10 -14
- data/lib/alexandria/ui/dndable.rb +0 -1
- data/lib/alexandria/ui/gtk_thread_help.rb +2 -1
- data/lib/alexandria/ui/icons.rb +3 -3
- data/lib/alexandria/ui/iconview_tooltips.rb +9 -5
- data/lib/alexandria/ui/init.rb +6 -6
- data/lib/alexandria/ui/listview.rb +4 -4
- data/lib/alexandria/ui/main_app.rb +1 -1
- data/lib/alexandria/ui/multi_drag_treeview.rb +3 -5
- data/lib/alexandria/ui/sidepane.rb +26 -10
- data/lib/alexandria/ui/ui_manager.rb +5 -9
- data/lib/alexandria/undo_manager.rb +0 -2
- data/lib/alexandria/version.rb +3 -3
- data/lib/alexandria/web_themes.rb +1 -3
- data/{test/providers_test.rb → spec/alexandria/book_providers_spec.rb} +17 -15
- data/{test/book_test.rb → spec/alexandria/book_spec.rb} +4 -4
- data/spec/alexandria/library_spec.rb +189 -141
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -2
- data/spec/alexandria/ui/main_app_spec.rb +13 -8
- data/spec/alexandria/ui/sidepane_spec.rb +1 -1
- data/spec/alexandria/ui/ui_utilities_spec.rb +1 -1
- data/{test → spec}/data/isbns.txt +0 -0
- data/tasks/spec.rake +2 -0
- data/util/rake/fileinstall.rb +1 -1
- metadata +32 -16
- data/tasks/test.rake +0 -38
- data/test/application_test.rb +0 -39
- data/test/isbn_test.rb +0 -68
- data/test/test_helper.rb +0 -42
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
#
|
2
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
3
3
|
#
|
4
4
|
# Alexandria is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU General Public License as
|
@@ -61,9 +61,7 @@ module Alexandria
|
|
61
61
|
setup_calendar_widgets
|
62
62
|
end
|
63
63
|
|
64
|
-
#########
|
65
64
|
protected
|
66
|
-
#########
|
67
65
|
|
68
66
|
def smart_library_rules
|
69
67
|
fill_smart_library_rules_values
|
@@ -81,15 +79,15 @@ module Alexandria
|
|
81
79
|
def user_confirms_possible_weirdnesses_before_saving?
|
82
80
|
return true unless has_weirdnesses?
|
83
81
|
dialog = AlertDialog.new(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
82
|
+
self,
|
83
|
+
_('Empty or conflictive condition'),
|
84
|
+
Gtk::Stock::DIALOG_QUESTION,
|
85
|
+
[[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
86
|
+
[_('_Save However'), Gtk::Dialog::RESPONSE_YES]],
|
87
|
+
_('This smart library contains one or more conditions ' \
|
88
|
+
'which are empty or conflict with each other. This is ' \
|
89
|
+
'likely to result in never matching a book. Are you ' \
|
90
|
+
'sure you want to save this library?'))
|
93
91
|
dialog.default_response = Gtk::Dialog::RESPONSE_CANCEL
|
94
92
|
dialog.show_all
|
95
93
|
confirmed = dialog.run == Gtk::Dialog::RESPONSE_YES
|
@@ -341,7 +339,6 @@ module Alexandria
|
|
341
339
|
time = Time.gm(year, month, day)
|
342
340
|
@calendar_popup_for_entry.text = format_date(time)
|
343
341
|
end
|
344
|
-
|
345
342
|
end
|
346
343
|
|
347
344
|
@calendar.signal_connect('day-selected-double-click') do
|
@@ -364,7 +361,6 @@ module Alexandria
|
|
364
361
|
self.modal = true
|
365
362
|
|
366
363
|
Gtk.timeout_add(150) do
|
367
|
-
|
368
364
|
# If we set @popup_displayed=false immediately, then a click
|
369
365
|
# event on the primary icon of the Entry simultaneous with
|
370
366
|
# the focus-out-event of the Calendar causes the Calendar to
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#--
|
3
3
|
# Copyright (C) 2010 Cathal Mc Ginley
|
4
|
-
#
|
4
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
5
5
|
#
|
6
6
|
# This file is part of Alexandria, a GNOME book collection manager.
|
7
7
|
#
|
@@ -33,6 +33,7 @@
|
|
33
33
|
# false
|
34
34
|
# end
|
35
35
|
|
36
|
+
require 'cairo'
|
36
37
|
require 'gtk2'
|
37
38
|
require 'monitor'
|
38
39
|
|
data/lib/alexandria/ui/icons.rb
CHANGED
@@ -34,9 +34,9 @@ class Gdk::Pixbuf
|
|
34
34
|
|
35
35
|
# Copies the current pixbuf there (south-west).
|
36
36
|
copy_area(0, 0,
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
width, height,
|
38
|
+
new_pixbuf,
|
39
|
+
0, tweak_y)
|
40
40
|
|
41
41
|
# Copies the tag pixbuf there (north-est).
|
42
42
|
tag_pixbuf_x = width - (tweak_x * 2)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Copyright (C) 2007 kksou
|
4
4
|
# Copyright (C) 2008,2009 Cathal Mc Ginley
|
5
|
-
#
|
5
|
+
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
6
6
|
#
|
7
7
|
# Alexandria is free software; you can redistribute it and/or
|
8
8
|
# modify it under the terms of the GNU General Public License as
|
@@ -40,10 +40,12 @@ class IconViewTooltips
|
|
40
40
|
@tooltip_window.app_paintable = true
|
41
41
|
|
42
42
|
@tooltip_window.signal_connect('expose_event') { |window, event|
|
43
|
-
on_expose(window, event)
|
43
|
+
on_expose(window, event)
|
44
|
+
}
|
44
45
|
|
45
46
|
@tooltip_window.signal_connect('leave_notify_event') { |vw, event|
|
46
|
-
on_leave(vw, event)
|
47
|
+
on_leave(vw, event)
|
48
|
+
}
|
47
49
|
|
48
50
|
@label = Gtk::Label.new('')
|
49
51
|
@label.wrap = true
|
@@ -57,9 +59,11 @@ class IconViewTooltips
|
|
57
59
|
|
58
60
|
def set_view(view)
|
59
61
|
view.signal_connect('motion_notify_event') { |vw, event|
|
60
|
-
on_motion(vw, event)
|
62
|
+
on_motion(vw, event)
|
63
|
+
}
|
61
64
|
view.signal_connect('leave_notify_event') { |vw, event|
|
62
|
-
on_leave(vw, event)
|
65
|
+
on_leave(vw, event)
|
66
|
+
}
|
63
67
|
end
|
64
68
|
|
65
69
|
def on_expose(window, _event)
|
data/lib/alexandria/ui/init.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2008 Joseph Method
|
3
|
-
#
|
3
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
4
4
|
#
|
5
5
|
# Alexandria is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU General Public License as
|
@@ -21,11 +21,11 @@ class CellRendererToggle < Gtk::CellRendererToggle
|
|
21
21
|
attr_accessor :text
|
22
22
|
type_register
|
23
23
|
install_property(GLib::Param::String.new(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
'text',
|
25
|
+
'text',
|
26
|
+
'Some damn value',
|
27
|
+
'',
|
28
|
+
GLib::Param::READABLE | GLib::Param::WRITABLE))
|
29
29
|
end
|
30
30
|
|
31
31
|
class Gtk::ActionGroup
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2008 Joseph Method
|
3
3
|
# Copyright (C) 2010 Cathal Mc Ginley
|
4
|
-
#
|
4
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
5
5
|
#
|
6
6
|
# Alexandria is free software; you can redistribute it and/or
|
7
7
|
# modify it under the terms of the GNU General Public License aso
|
@@ -69,7 +69,8 @@ module Alexandria
|
|
69
69
|
column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
|
70
70
|
iter = @listview_model.convert_iter_to_child_iter(iter)
|
71
71
|
iter = @filtered_model.convert_iter_to_child_iter(iter)
|
72
|
-
cell.text
|
72
|
+
cell.text = iter[Columns::TITLE]
|
73
|
+
cell.editable = false # true
|
73
74
|
end
|
74
75
|
|
75
76
|
column.sort_column_id = Columns::TITLE
|
@@ -222,7 +223,6 @@ module Alexandria
|
|
222
223
|
rescue => e
|
223
224
|
log.error { "toggle failed for path #{path} #{e}\n" + e.backtrace.join("\n") }
|
224
225
|
end
|
225
|
-
|
226
226
|
end
|
227
227
|
column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
|
228
228
|
column.widget = Gtk::Label.new(title).show
|
@@ -294,7 +294,7 @@ module Alexandria
|
|
294
294
|
log.debug { "setup_listview_columns_width #{@prefs.cols_width}" }
|
295
295
|
if @prefs.cols_width
|
296
296
|
cols_width = YAML.load(@prefs.cols_width)
|
297
|
-
log.debug { "cols_width: #{cols_width.inspect
|
297
|
+
log.debug { "cols_width: #{cols_width.inspect}" }
|
298
298
|
@listview.columns.each do |c|
|
299
299
|
if cols_width.key?(c.title)
|
300
300
|
log.debug { "#{c.title} : #{cols_width[c.title]}" }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2007 Cathal Mc Ginley
|
3
|
-
#
|
3
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
4
4
|
#
|
5
5
|
# Alexandria is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU General Public License as
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
#
|
2
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
3
3
|
#
|
4
4
|
# Alexandria is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU General Public License as
|
@@ -62,17 +62,15 @@ class Gtk::TreeView
|
|
62
62
|
|
63
63
|
@context.button_press_handler =
|
64
64
|
signal_connect('button_press_event') do |_widget, event, _data|
|
65
|
-
|
66
|
-
|
65
|
+
button_press_event(event)
|
66
|
+
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def drag_context
|
70
70
|
@context.drag_context
|
71
71
|
end
|
72
72
|
|
73
|
-
#######
|
74
73
|
private
|
75
|
-
#######
|
76
74
|
|
77
75
|
def stop_drag_check
|
78
76
|
raise if @context.nil?
|
@@ -1,4 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# Copyright (C) 2008 Joseph Method
|
2
|
+
# Copyright (C) 2008,2009 Cathal Mc Ginley
|
3
|
+
# Copyright (C) 2011,2014,2015 Matijs van Zuijlen
|
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
|
+
|
2
20
|
module Alexandria
|
3
21
|
module UI
|
4
22
|
class SidePaneManager
|
@@ -99,7 +117,8 @@ module Alexandria
|
|
99
117
|
column.pack_start(renderer, true)
|
100
118
|
column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
|
101
119
|
# log.debug { "sidepane: editable #{cell}, #{iter} #{iter[1]}: #{iter[2]}" }
|
102
|
-
cell.text
|
120
|
+
cell.text = iter[1]
|
121
|
+
cell.editable = iter[2]
|
103
122
|
# log.debug { "exit sidepane: editable #{cell}, #{iter}" }
|
104
123
|
end
|
105
124
|
renderer.signal_connect('edited', &method(:on_edited_library))
|
@@ -120,11 +139,10 @@ module Alexandria
|
|
120
139
|
BOOKS_TARGET_TABLE,
|
121
140
|
Gdk::DragContext::ACTION_MOVE)
|
122
141
|
|
123
|
-
@library_listview.signal_connect('drag-motion') do
|
124
|
-
|_widget, drag_context, x, y, time, _data|
|
142
|
+
@library_listview.signal_connect('drag-motion') do |_widget, drag_context, x, y, time, _data|
|
125
143
|
log.debug { 'drag-motion' }
|
126
144
|
|
127
|
-
path, column,
|
145
|
+
path, column, =
|
128
146
|
@library_listview.get_path_at_pos(x, y)
|
129
147
|
|
130
148
|
if path
|
@@ -153,8 +171,7 @@ module Alexandria
|
|
153
171
|
time)
|
154
172
|
end
|
155
173
|
|
156
|
-
@library_listview.signal_connect('drag-drop') do
|
157
|
-
|widget, drag_context, _x, _y, time, _data|
|
174
|
+
@library_listview.signal_connect('drag-drop') do |widget, drag_context, _x, _y, time, _data|
|
158
175
|
log.debug { 'drag-drop' }
|
159
176
|
|
160
177
|
Gtk::Drag.get_data(widget,
|
@@ -164,13 +181,12 @@ module Alexandria
|
|
164
181
|
true
|
165
182
|
end
|
166
183
|
|
167
|
-
@library_listview.signal_connect('drag-data-received') do
|
168
|
-
|_widget, drag_context, x, y, selection_data, _info, _time|
|
184
|
+
@library_listview.signal_connect('drag-data-received') do |_widget, drag_context, x, y, selection_data, _info, _time|
|
169
185
|
log.debug { 'drag-data-received' }
|
170
186
|
|
171
187
|
success = false
|
172
188
|
if selection_data.type == Gdk::Selection::TYPE_STRING
|
173
|
-
path,
|
189
|
+
path, =
|
174
190
|
@library_listview.get_dest_row_at_pos(x, y)
|
175
191
|
|
176
192
|
if path
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2008 Joseph Method
|
3
|
-
#
|
3
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
4
4
|
#
|
5
5
|
# Alexandria is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU General Public License as
|
@@ -22,7 +22,7 @@ module Alexandria
|
|
22
22
|
MAX_RATING_STARS = 5
|
23
23
|
class UIManager < BuilderBase
|
24
24
|
attr_accessor :main_app, :actiongroup, :appbar, :prefs, :listview, :iconview, :listview_model,
|
25
|
-
|
25
|
+
:iconview_model, :filtered_model
|
26
26
|
attr_reader :model
|
27
27
|
include Logging
|
28
28
|
include GetText
|
@@ -208,7 +208,6 @@ module Alexandria
|
|
208
208
|
log.debug { 'setup_book_providers' }
|
209
209
|
mid = @uimanager.new_merge_id
|
210
210
|
BookProviders.each do |provider|
|
211
|
-
|
212
211
|
name = provider.action_name
|
213
212
|
['ui/MainMenubar/ViewMenu/OnlineInformation/',
|
214
213
|
'ui/BookPopup/OnlineInformation/',
|
@@ -498,14 +497,14 @@ module Alexandria
|
|
498
497
|
log.debug { "Books are empty: #{books.empty?}" }
|
499
498
|
@actiongroup['Properties'].sensitive = \
|
500
499
|
@actiongroup['OnlineInformation'].sensitive = \
|
501
|
-
|
500
|
+
books.length == 1
|
502
501
|
@actiongroup['SelectAll'].sensitive = \
|
503
502
|
books.length < library.length
|
504
503
|
|
505
504
|
@actiongroup['Delete'].sensitive = \
|
506
505
|
@actiongroup['DeselectAll'].sensitive = \
|
507
|
-
|
508
|
-
|
506
|
+
@actiongroup['Move'].sensitive =
|
507
|
+
@actiongroup['SetRating'].sensitive = !books.empty?
|
509
508
|
|
510
509
|
log.debug { "on_books_selection_changed Delete: #{@actiongroup['Delete'].sensitive?}" }
|
511
510
|
|
@@ -640,9 +639,7 @@ module Alexandria
|
|
640
639
|
end
|
641
640
|
end
|
642
641
|
|
643
|
-
#######
|
644
642
|
# private
|
645
|
-
#######
|
646
643
|
|
647
644
|
def open_web_browser(url)
|
648
645
|
if url.nil?
|
@@ -926,7 +923,6 @@ module Alexandria
|
|
926
923
|
n = 0
|
927
924
|
|
928
925
|
Gtk.idle_add do
|
929
|
-
|
930
926
|
block_return = true
|
931
927
|
book = library[n]
|
932
928
|
if book
|
data/lib/alexandria/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Matijs van Zuijlen
|
1
|
+
# Copyright (C) 2014, 2015 Matijs van Zuijlen
|
2
2
|
#
|
3
3
|
# This file is part of Alexandria.
|
4
4
|
#
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
19
|
|
20
20
|
module Alexandria
|
21
|
-
VERSION = '0.6.9
|
21
|
+
VERSION = '0.6.9'
|
22
22
|
DATA_VERSION = '0.6.3'
|
23
|
-
DISPLAY_VERSION = '0.6.9
|
23
|
+
DISPLAY_VERSION = '0.6.9'
|
24
24
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
#
|
2
|
+
# Copyright (C) 2011 Matijs van Zuijlen
|
3
3
|
#
|
4
4
|
# Alexandria is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU General Public License as
|
@@ -35,9 +35,7 @@ module Alexandria
|
|
35
35
|
File.exist?(@pixmaps_directory)
|
36
36
|
end
|
37
37
|
|
38
|
-
#######
|
39
38
|
private
|
40
|
-
#######
|
41
39
|
|
42
40
|
def self.load(themes_dir)
|
43
41
|
themes = []
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Copyright (C) 2005-2006 Laurent Sansonetti
|
3
|
-
# Copyright (C)
|
4
|
-
#
|
3
|
+
# Copyright (C) 2007 Joseph Method
|
4
|
+
# Copyright (C) 2011, 2014, 2015 Matijs van Zuijlen
|
5
5
|
#
|
6
6
|
# This file is part of Alexandria, a GNOME book collection manager.
|
7
7
|
#
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
21
21
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
22
22
|
|
23
|
-
require
|
23
|
+
require 'spec_helper'
|
24
24
|
|
25
25
|
describe Alexandria::BookProviders do
|
26
26
|
it 'should be less clever'
|
@@ -30,27 +30,29 @@ describe Alexandria::BookProviders do
|
|
30
30
|
|
31
31
|
puts results.inspect if $DEBUG
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
expect(results).to be_instance_of(Array), "Results are not an array for #{provider}"
|
34
|
+
expect(results).not_to be_empty, "Results are empty for #{provider}"
|
35
35
|
|
36
36
|
if search_type == Alexandria::BookProviders::SEARCH_BY_ISBN
|
37
|
-
|
37
|
+
expect(results.length).to be <= 2, "Results are greater than 2 for #{provider}"
|
38
38
|
|
39
39
|
book = results.first
|
40
40
|
|
41
|
-
|
41
|
+
expect(book).to be_instance_of(Alexandria::Book), "Result is not a Book for #{provider}"
|
42
42
|
|
43
43
|
canonical_query = Alexandria::Library.canonicalise_ean(query)
|
44
44
|
canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
|
45
|
-
|
46
|
-
"Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
|
45
|
+
expect(canonical_query).to eq(canonical_result),
|
46
|
+
"Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
|
47
47
|
|
48
48
|
if results.length == 2
|
49
49
|
cover_url = results.last
|
50
|
-
|
50
|
+
if cover_url
|
51
|
+
expect(cover_url).to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
|
52
|
+
end
|
51
53
|
end
|
52
54
|
else
|
53
|
-
|
55
|
+
expect(results.first.first).to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
|
54
56
|
end
|
55
57
|
results
|
56
58
|
end
|
@@ -86,6 +88,7 @@ describe Alexandria::BookProviders do
|
|
86
88
|
end
|
87
89
|
|
88
90
|
it 'dea should work' do
|
91
|
+
skip 'DEAStore is not operational at the moment'
|
89
92
|
assert_correct_search_result(Alexandria::BookProviders::DeaStoreProvider,
|
90
93
|
'9788817012980')
|
91
94
|
assert_correct_search_result(Alexandria::BookProviders::DeaStoreProvider,
|
@@ -244,11 +247,10 @@ describe Alexandria::BookProviders do
|
|
244
247
|
|
245
248
|
it 'Worldcat should work with multiple authors' do
|
246
249
|
results = assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
|
247
|
-
|
250
|
+
'9785941454136')
|
248
251
|
this_book = results.first
|
249
|
-
|
252
|
+
expect(this_book.authors).to be_instance_of(Array), 'Not an array!'
|
250
253
|
# puts this_book.authors
|
251
|
-
|
252
|
-
|
254
|
+
expect(this_book.authors.length).to eq(2), 'Wrong number of authors for this book!'
|
253
255
|
end
|
254
256
|
end
|