alexandria-book-collection-manager 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +28 -25
- data/.rubocop_todo.yml +87 -67
- data/CHANGELOG.md +12 -1
- data/Gemfile +4 -3
- data/README.md +16 -6
- data/Rakefile +71 -72
- data/alexandria-book-collection-manager.gemspec +44 -44
- data/bin/alexandria +12 -12
- data/lib/alexandria.rb +22 -22
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +50 -50
- data/lib/alexandria/book_providers/adlibris.rb +28 -44
- data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
- data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
- data/lib/alexandria/book_providers/douban.rb +21 -37
- data/lib/alexandria/book_providers/proxis.rb +24 -24
- data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
- data/lib/alexandria/book_providers/renaud.rb +44 -57
- data/lib/alexandria/book_providers/siciliano.rb +39 -39
- data/lib/alexandria/book_providers/thalia.rb +33 -33
- data/lib/alexandria/book_providers/web.rb +5 -5
- data/lib/alexandria/book_providers/worldcat.rb +44 -69
- data/lib/alexandria/book_providers/z3950.rb +94 -109
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +3 -3
- data/lib/alexandria/export_format.rb +8 -8
- data/lib/alexandria/export_library.rb +112 -113
- data/lib/alexandria/import_library.rb +45 -45
- data/lib/alexandria/import_library_csv.rb +30 -30
- data/lib/alexandria/library_collection.rb +4 -4
- data/lib/alexandria/library_sort_order.rb +1 -1
- data/lib/alexandria/library_store.rb +14 -14
- data/lib/alexandria/logging.rb +5 -5
- data/lib/alexandria/models/book.rb +1 -1
- data/lib/alexandria/models/library.rb +36 -36
- data/lib/alexandria/net.rb +5 -5
- data/lib/alexandria/preferences.rb +32 -32
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
- data/lib/alexandria/scanners/keyboard.rb +5 -5
- data/lib/alexandria/smart_library.rb +53 -53
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
- data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
- data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/callbacks.rb +95 -91
- data/lib/alexandria/ui/completion_models.rb +7 -21
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
- data/lib/alexandria/ui/icons.rb +6 -6
- data/lib/alexandria/ui/iconview.rb +7 -7
- data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
- data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
- data/lib/alexandria/ui/init.rb +16 -29
- data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
- data/lib/alexandria/ui/libraries_combo.rb +7 -7
- data/lib/alexandria/ui/listview.rb +40 -40
- data/lib/alexandria/ui/main_app.rb +22 -24
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
- data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
- data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
- data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
- data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
- data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
- data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
- data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
- data/lib/alexandria/ui/sound.rb +8 -8
- data/lib/alexandria/ui/ui_manager.rb +136 -135
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +8 -8
- data/po/cs.po +97 -97
- data/po/cy.po +97 -97
- data/po/de.po +97 -97
- data/po/el.po +97 -97
- data/po/es.po +97 -97
- data/po/fr.po +97 -97
- data/po/ga.po +97 -97
- data/po/gl.po +97 -97
- data/po/it.po +97 -97
- data/po/ja.po +97 -97
- data/po/mk.po +97 -97
- data/po/nb.po +97 -97
- data/po/nl.po +97 -97
- data/po/pl.po +97 -97
- data/po/pt.po +97 -97
- data/po/pt_BR.po +97 -97
- data/po/ru.po +97 -97
- data/po/sk.po +97 -97
- data/po/sv.po +97 -97
- data/po/uk.po +97 -97
- data/po/zh_TW.po +97 -97
- data/schemas/alexandria.schemas +24 -2
- data/spec/alexandria/book_providers_spec.rb +65 -82
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +9 -9
- data/spec/alexandria/export_library_spec.rb +31 -31
- data/spec/alexandria/library_spec.rb +86 -86
- data/spec/alexandria/library_store_spec.rb +8 -8
- data/spec/alexandria/preferences_spec.rb +18 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +15 -15
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +6 -6
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
- data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
- data/spec/alexandria/utilities_spec.rb +6 -6
- data/spec/end_to_end/basic_run_spec.rb +24 -36
- data/spec/spec_helper.rb +9 -9
- data/tasks/dogtail.rake +1 -1
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +11 -11
- data/util/rake/fileinstall.rb +25 -25
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +59 -33
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -162
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
data/schemas/alexandria.schemas
CHANGED
@@ -203,7 +203,7 @@
|
|
203
203
|
<long>Whether the publisher column should be visible in the list view.</long>
|
204
204
|
</locale>
|
205
205
|
</schema>
|
206
|
-
<schema>
|
206
|
+
<schema>
|
207
207
|
<key>/schemas/apps/alexandria/col_publish_date_visible</key>
|
208
208
|
<applyto>/apps/alexandria/col_publish_date_visible</applyto>
|
209
209
|
<owner>alexandria</owner>
|
@@ -214,6 +214,17 @@
|
|
214
214
|
<long>Whether the publish date column should be visible in the list view.</long>
|
215
215
|
</locale>
|
216
216
|
</schema>
|
217
|
+
<schema>
|
218
|
+
<key>/schemas/apps/alexandria/col_loaned_to_visible</key>
|
219
|
+
<applyto>/apps/alexandria/col_loaned_to_visible</applyto>
|
220
|
+
<owner>alexandria</owner>
|
221
|
+
<type>bool</type>
|
222
|
+
<default>true</default>
|
223
|
+
<locale name="C">
|
224
|
+
<short>Loaned to visibility</short>
|
225
|
+
<long>Whether the loaned to column should be visible in the list view.</long>
|
226
|
+
</locale>
|
227
|
+
</schema>
|
217
228
|
<schema>
|
218
229
|
<key>/schemas/apps/alexandria/col_rating_visible</key>
|
219
230
|
<applyto>/apps/alexandria/col_rating_visible</applyto>
|
@@ -247,7 +258,7 @@
|
|
247
258
|
<long>Whether the own column should be visible in the list view.</long>
|
248
259
|
</locale>
|
249
260
|
</schema>
|
250
|
-
<schema>
|
261
|
+
<schema>
|
251
262
|
<key>/schemas/apps/alexandria/col_want_visible</key>
|
252
263
|
<applyto>/apps/alexandria/col_want_visible</applyto>
|
253
264
|
<owner>alexandria</owner>
|
@@ -258,6 +269,17 @@
|
|
258
269
|
<long>Whether the want column should be visible in the list view.</long>
|
259
270
|
</locale>
|
260
271
|
</schema>
|
272
|
+
<schema>
|
273
|
+
<key>/schemas/apps/alexandria/col_tags_visible</key>
|
274
|
+
<applyto>/apps/alexandria/col_tags_visible</applyto>
|
275
|
+
<owner>alexandria</owner>
|
276
|
+
<type>bool</type>
|
277
|
+
<default>true</default>
|
278
|
+
<locale name="C">
|
279
|
+
<short>Tags column visibility</short>
|
280
|
+
<long>Whether the tags column should be visible in the list view.</long>
|
281
|
+
</locale>
|
282
|
+
</schema>
|
261
283
|
<schema>
|
262
284
|
<key>/schemas/apps/alexandria/cols_width</key>
|
263
285
|
<applyto>/apps/alexandria/cols_width</applyto>
|
@@ -1,37 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2007 Joseph Method
|
5
|
-
# Copyright (C) 2011, 2014, 2015 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# Alexandria is free software; you can redistribute it and/or
|
10
|
-
# modify it under the terms of the GNU General Public License as
|
11
|
-
# published by the Free Software Foundation; either version 2 of the
|
12
|
-
# License, or (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Alexandria is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
-
# General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public
|
20
|
-
# License along with Alexandria; see the file COPYING. If not,
|
21
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
22
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
23
6
|
|
24
|
-
require
|
7
|
+
require "spec_helper"
|
25
8
|
|
26
9
|
describe Alexandria::BookProviders do
|
27
|
-
it
|
10
|
+
it "should be less clever"
|
28
11
|
|
29
12
|
def assert_correct_search_result(provider, query,
|
30
13
|
search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
|
31
14
|
begin
|
32
15
|
results = provider.instance.search(query, search_type)
|
33
16
|
rescue SocketError
|
34
|
-
skip
|
17
|
+
skip "Service is offline"
|
35
18
|
end
|
36
19
|
|
37
20
|
puts results.inspect if $DEBUG
|
@@ -48,139 +31,139 @@ describe Alexandria::BookProviders do
|
|
48
31
|
|
49
32
|
canonical_query = Alexandria::Library.canonicalise_ean(query)
|
50
33
|
canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
|
51
|
-
expect(canonical_query)
|
52
|
-
to eq(canonical_result),
|
53
|
-
|
34
|
+
expect(canonical_query)
|
35
|
+
.to eq(canonical_result),
|
36
|
+
"Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
|
54
37
|
|
55
38
|
if results.length == 2
|
56
39
|
cover_url = results.last
|
57
40
|
if cover_url
|
58
|
-
expect(cover_url)
|
59
|
-
to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
|
41
|
+
expect(cover_url)
|
42
|
+
.to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
|
60
43
|
end
|
61
44
|
end
|
62
45
|
else
|
63
|
-
expect(results.first.first)
|
64
|
-
to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
|
46
|
+
expect(results.first.first)
|
47
|
+
.to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
|
65
48
|
end
|
66
49
|
results
|
67
50
|
end
|
68
51
|
|
69
|
-
it
|
70
|
-
skip
|
52
|
+
it "does not piss off Rich Burridge" do
|
53
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
71
54
|
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
72
|
-
|
55
|
+
"033025068X")
|
73
56
|
end
|
74
57
|
|
75
|
-
it
|
76
|
-
skip
|
58
|
+
it "amazon should work" do
|
59
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
77
60
|
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
78
|
-
|
61
|
+
"9780385504201")
|
79
62
|
end
|
80
63
|
|
81
|
-
it
|
82
|
-
skip
|
64
|
+
it "amazon title should work" do
|
65
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
83
66
|
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
84
|
-
|
67
|
+
"A Confederacy of Dunces", Alexandria::BookProviders::SEARCH_BY_TITLE)
|
85
68
|
end
|
86
69
|
|
87
|
-
it
|
88
|
-
skip
|
70
|
+
it "amazon authors should work" do
|
71
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
89
72
|
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
90
|
-
|
73
|
+
"John Kennedy Toole", Alexandria::BookProviders::SEARCH_BY_AUTHORS)
|
91
74
|
end
|
92
75
|
|
93
|
-
it
|
94
|
-
skip
|
76
|
+
it "amazon keyword should work" do
|
77
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
95
78
|
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
96
|
-
|
79
|
+
"Confederacy Dunces", Alexandria::BookProviders::SEARCH_BY_KEYWORD)
|
97
80
|
end
|
98
81
|
|
99
|
-
it
|
82
|
+
it "LOC should work" do
|
100
83
|
assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
|
101
|
-
|
84
|
+
"9780805335583")
|
102
85
|
# this book has non-ASCII letters
|
103
86
|
assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
|
104
|
-
|
87
|
+
"9782070379248")
|
105
88
|
end
|
106
89
|
|
107
|
-
it
|
108
|
-
skip
|
90
|
+
it "BL should work" do
|
91
|
+
skip "Not working: connect failed"
|
109
92
|
assert_correct_search_result(Alexandria::BookProviders::BLProvider,
|
110
|
-
|
93
|
+
"9781853260803")
|
111
94
|
end
|
112
95
|
|
113
|
-
it
|
96
|
+
it "SBN should work" do
|
114
97
|
assert_correct_search_result(Alexandria::BookProviders::SBNProvider,
|
115
|
-
|
98
|
+
"9788835926436")
|
116
99
|
end
|
117
100
|
|
118
|
-
it
|
119
|
-
skip
|
101
|
+
it "Barnes and Noble should work" do
|
102
|
+
skip "Barnes and Noble is not operational at the moment"
|
120
103
|
assert_correct_search_result(Alexandria::BookProviders::BarnesAndNobleProvider,
|
121
|
-
|
104
|
+
"9780961328917") # see #1433
|
122
105
|
end
|
123
106
|
|
124
|
-
it
|
125
|
-
skip
|
107
|
+
it "Proxis should work" do
|
108
|
+
skip "Needs fixing"
|
126
109
|
assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
|
127
|
-
|
110
|
+
"9789026965746")
|
128
111
|
assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
|
129
|
-
|
112
|
+
"9780586071403")
|
130
113
|
end
|
131
114
|
|
132
|
-
it
|
133
|
-
skip
|
115
|
+
it "Thalia should work" do
|
116
|
+
skip "Needs fixing"
|
134
117
|
# german book
|
135
118
|
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
136
|
-
|
119
|
+
"9783896673305")
|
137
120
|
# international book
|
138
121
|
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
139
|
-
|
122
|
+
"9780440241904")
|
140
123
|
# movie dvd
|
141
124
|
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
142
|
-
|
125
|
+
"4010232037824")
|
143
126
|
# music cd
|
144
127
|
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
145
|
-
|
128
|
+
"0094638203520")
|
146
129
|
end
|
147
130
|
|
148
|
-
it
|
149
|
-
skip
|
131
|
+
it "AdLibris should work" do
|
132
|
+
skip "Needs fixing: site has changed"
|
150
133
|
assert_correct_search_result(Alexandria::BookProviders::AdLibrisProvider,
|
151
|
-
|
134
|
+
"9789100109332")
|
152
135
|
end
|
153
136
|
|
154
|
-
it
|
155
|
-
skip
|
137
|
+
it "Siciliano should work" do
|
138
|
+
skip "Needs fixing: no results found"
|
156
139
|
assert_correct_search_result(Alexandria::BookProviders::SicilianoProvider,
|
157
|
-
|
140
|
+
"9788599170380")
|
158
141
|
end
|
159
142
|
|
160
|
-
it
|
161
|
-
skip
|
143
|
+
it "Renaud should work" do
|
144
|
+
skip "Marked in code as not working; remove implementation entirely."
|
162
145
|
# adultes
|
163
146
|
assert_correct_search_result(Alexandria::BookProviders::RENAUDProvider,
|
164
|
-
|
147
|
+
"9782894723388")
|
165
148
|
# jeunesse
|
166
149
|
assert_correct_search_result(Alexandria::BookProviders::RENAUDProvider,
|
167
|
-
|
150
|
+
"9782764605059")
|
168
151
|
end
|
169
152
|
|
170
|
-
it
|
153
|
+
it "Worldcat should work" do
|
171
154
|
assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
|
172
|
-
|
155
|
+
"9780521247108")
|
173
156
|
# this one is with <div class=vernacular lang="[^"]+">)
|
174
157
|
assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
|
175
|
-
|
158
|
+
"9785941454136")
|
176
159
|
end
|
177
160
|
|
178
|
-
it
|
161
|
+
it "Worldcat should work with multiple authors" do
|
179
162
|
results = assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
|
180
|
-
|
163
|
+
"9785941454136")
|
181
164
|
this_book = results.first
|
182
|
-
expect(this_book.authors).to be_instance_of(Array),
|
165
|
+
expect(this_book.authors).to be_instance_of(Array), "Not an array!"
|
183
166
|
# puts this_book.authors
|
184
|
-
expect(this_book.authors.length).to eq(2),
|
167
|
+
expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!"
|
185
168
|
end
|
186
169
|
end
|
@@ -18,41 +18,43 @@
|
|
18
18
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
19
19
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
20
20
|
|
21
|
-
require
|
21
|
+
require "spec_helper"
|
22
22
|
|
23
23
|
describe Alexandria::Book do
|
24
|
-
it
|
24
|
+
it "is a thing" do
|
25
25
|
an_artist_of_the_floating_world
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it "establishes equality only with books with the same identity" do
|
29
29
|
book = an_artist_of_the_floating_world
|
30
30
|
same_book = an_artist_of_the_floating_world
|
31
31
|
expect(same_book).to eq book
|
32
32
|
different_book = an_artist_of_the_floating_world
|
33
|
-
different_book.isbn =
|
33
|
+
different_book.isbn = "9780571147999"
|
34
34
|
expect(different_book).not_to eq book
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
37
|
+
describe "#rating" do
|
38
38
|
let(:book) { an_artist_of_the_floating_world }
|
39
|
-
|
39
|
+
|
40
|
+
it "returns 0 by default" do
|
40
41
|
expect(book.rating).to eq 0
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
describe
|
45
|
+
describe "#rating=" do
|
45
46
|
let(:book) { an_artist_of_the_floating_world }
|
46
|
-
|
47
|
+
|
48
|
+
it "assigns rating" do
|
47
49
|
book.rating = 5
|
48
50
|
expect(book.rating).to eq 5
|
49
51
|
end
|
50
52
|
|
51
|
-
it
|
53
|
+
it "does not allow higher rating than 5 to be assigned" do
|
52
54
|
expect { book.rating = 6 }.to raise_error ArgumentError
|
53
55
|
end
|
54
56
|
|
55
|
-
it
|
57
|
+
it "does not allow lower rating than 0 to be assigned" do
|
56
58
|
expect { book.rating = -1 }.to raise_error ArgumentError
|
57
59
|
end
|
58
60
|
end
|
@@ -4,19 +4,23 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
-
require
|
7
|
+
require "spec_helper"
|
8
8
|
|
9
9
|
RSpec.describe Alexandria do
|
10
|
-
let(:lib_version) { File.join(LIBDIR,
|
10
|
+
let(:lib_version) { File.join(LIBDIR, "0.6.2") }
|
11
11
|
|
12
12
|
before do
|
13
13
|
FileUtils.rm_rf(TESTDIR)
|
14
14
|
FileUtils.cp_r(lib_version, TESTDIR)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
after do
|
18
|
+
FileUtils.rm_rf(TESTDIR)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".list_books_on_console" do
|
22
|
+
it "returns a string containing a list of all books" do
|
23
|
+
expect(described_class.list_books_on_console).to eq <<~LIST
|
20
24
|
The Dispossessed, Ursula Le Guin
|
21
25
|
Pattern Recognition, William Gibson
|
22
26
|
Bonjour Tristesse, Francoise Sagan & Irene Ash
|
@@ -25,8 +29,4 @@ RSpec.describe Alexandria do
|
|
25
29
|
LIST
|
26
30
|
end
|
27
31
|
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
FileUtils.rm_rf(TESTDIR)
|
31
|
-
end
|
32
32
|
end
|
@@ -4,66 +4,71 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
-
require
|
7
|
+
require "spec_helper"
|
8
8
|
|
9
9
|
RSpec.describe Alexandria::ExportLibrary do
|
10
|
-
let(:lib_version) { File.join(LIBDIR,
|
10
|
+
let(:lib_version) { File.join(LIBDIR, "0.6.2") }
|
11
11
|
|
12
12
|
let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
|
13
13
|
|
14
14
|
let(:format) { Alexandria::ExportFormat.all.find { |it| it.message == message } }
|
15
|
-
let(:outfile_base) { format.ext ? "my-library.#{format.ext}" :
|
15
|
+
let(:outfile_base) { format.ext ? "my-library.#{format.ext}" : "my-library" }
|
16
16
|
let(:outfile) { File.join(Dir.tmpdir, outfile_base) }
|
17
17
|
|
18
18
|
let(:unsorted) { Alexandria::LibrarySortOrder::Unsorted.new }
|
19
19
|
|
20
20
|
before do
|
21
21
|
FileUtils.cp_r(lib_version, TESTDIR)
|
22
|
-
@my_library = loader.load_library(
|
22
|
+
@my_library = loader.load_library("My Library")
|
23
23
|
expect(@my_library.size).to eq 5
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
after do
|
27
|
+
FileUtils.rm_rf(TESTDIR)
|
28
|
+
FileUtils.rm_rf(outfile) if File.exist? outfile
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#export_as_csv_list" do
|
27
32
|
let(:message) { :export_as_csv_list }
|
28
33
|
|
29
34
|
def load_rows_from_csv
|
30
|
-
CSV.read(outfile, col_sep:
|
35
|
+
CSV.read(outfile, col_sep: ";")
|
31
36
|
end
|
32
37
|
|
33
|
-
it
|
38
|
+
it "can sort by title" do
|
34
39
|
sort_by_title = Alexandria::LibrarySortOrder.new(:title)
|
35
40
|
format.invoke(@my_library, sort_by_title, outfile)
|
36
41
|
expect(File.exist?(outfile)).to be_truthy
|
37
42
|
rows = load_rows_from_csv
|
38
43
|
rows.shift
|
39
44
|
expect(rows.size).to eq(@my_library.size)
|
40
|
-
|
45
|
+
title_index = 0
|
41
46
|
comparisons = rows.size - 1
|
42
47
|
comparisons.times do |index|
|
43
|
-
expect(rows[index][
|
48
|
+
expect(rows[index][title_index]).to be <= rows[index + 1][title_index]
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
47
|
-
it
|
52
|
+
it "can sort in descending order" do
|
48
53
|
sort_by_date_desc = Alexandria::LibrarySortOrder.new(:publishing_year, false)
|
49
54
|
format.invoke(@my_library, sort_by_date_desc, outfile)
|
50
55
|
expect(File.exist?(outfile)).to be_truthy
|
51
56
|
rows = load_rows_from_csv
|
52
57
|
rows.shift
|
53
58
|
expect(rows.size).to eq(@my_library.size)
|
54
|
-
|
59
|
+
date_index = 5
|
55
60
|
comparisons = rows.size - 1
|
56
61
|
comparisons.times do |index|
|
57
|
-
expect(rows[index][
|
62
|
+
expect(rows[index][date_index]).to be >= rows[index + 1][date_index]
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
|
-
describe
|
67
|
+
describe "#export_as_html" do
|
63
68
|
let(:message) { :export_as_html }
|
64
|
-
let(:index) { File.join(outfile,
|
69
|
+
let(:index) { File.join(outfile, "index.html") }
|
65
70
|
|
66
|
-
it
|
71
|
+
it "can export unsorted" do
|
67
72
|
format.invoke(@my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
|
68
73
|
aggregate_failures do
|
69
74
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -73,10 +78,10 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
76
|
-
describe
|
81
|
+
describe "#export_as_onix_xml_archive" do
|
77
82
|
let(:message) { :export_as_onix_xml_archive }
|
78
83
|
|
79
|
-
it
|
84
|
+
it "can export unsorted" do
|
80
85
|
format.invoke(@my_library, unsorted, outfile)
|
81
86
|
aggregate_failures do
|
82
87
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -85,10 +90,10 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
|
-
describe
|
93
|
+
describe "#export_as_tellico_xml_archive" do
|
89
94
|
let(:message) { :export_as_tellico_xml_archive }
|
90
95
|
|
91
|
-
it
|
96
|
+
it "can export unsorted" do
|
92
97
|
format.invoke(@my_library, unsorted, outfile)
|
93
98
|
aggregate_failures do
|
94
99
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -97,10 +102,10 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
100
|
-
describe
|
105
|
+
describe "#export_as_bibtex" do
|
101
106
|
let(:message) { :export_as_bibtex }
|
102
107
|
|
103
|
-
it
|
108
|
+
it "can export unsorted" do
|
104
109
|
format.invoke(@my_library, unsorted, outfile)
|
105
110
|
aggregate_failures do
|
106
111
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -109,10 +114,10 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
112
|
-
describe
|
117
|
+
describe "#export_as_isbn_list" do
|
113
118
|
let(:message) { :export_as_isbn_list }
|
114
119
|
|
115
|
-
it
|
120
|
+
it "can export unsorted" do
|
116
121
|
format.invoke(@my_library, unsorted, outfile)
|
117
122
|
aggregate_failures do
|
118
123
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -121,11 +126,11 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
121
126
|
end
|
122
127
|
end
|
123
128
|
|
124
|
-
describe
|
129
|
+
describe "#export_as_ipod_notes" do
|
125
130
|
let(:message) { :export_as_ipod_notes }
|
126
|
-
let(:index) { File.join(outfile,
|
131
|
+
let(:index) { File.join(outfile, "index.linx") }
|
127
132
|
|
128
|
-
it
|
133
|
+
it "can export unsorted" do
|
129
134
|
format.invoke(@my_library, unsorted, outfile, nil)
|
130
135
|
aggregate_failures do
|
131
136
|
expect(File.exist?(outfile)).to be_truthy
|
@@ -133,9 +138,4 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
136
|
-
|
137
|
-
after(:each) do
|
138
|
-
FileUtils.rm_rf(TESTDIR)
|
139
|
-
FileUtils.rm_rf(outfile) if File.exist? outfile
|
140
|
-
end
|
141
141
|
end
|