alexandria-book-collection-manager 0.7.3 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ruby.yml +77 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +86 -36
- data/.rubocop_todo.yml +58 -161
- data/.simplecov +5 -2
- data/CHANGELOG.md +56 -2
- data/Gemfile +4 -3
- data/INSTALL.md +23 -11
- data/README.md +52 -41
- data/Rakefile +78 -75
- data/alexandria-book-collection-manager.gemspec +50 -44
- data/bin/alexandria +12 -22
- data/doc/FAQ +1 -2
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +25 -23
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +86 -91
- data/lib/alexandria/book_providers/adlibris.rb +37 -74
- data/lib/alexandria/book_providers/amazon_aws.rb +94 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +289 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +42 -42
- data/lib/alexandria/book_providers/douban.rb +25 -41
- data/lib/alexandria/book_providers/proxis.rb +34 -29
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +60 -64
- data/lib/alexandria/book_providers/thalia_provider.rb +161 -0
- data/lib/alexandria/book_providers/web.rb +5 -5
- data/lib/alexandria/book_providers/worldcat.rb +66 -95
- data/lib/alexandria/book_providers/z3950.rb +153 -169
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +3 -3
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +13 -12
- data/lib/alexandria/export_format.rb +8 -8
- data/lib/alexandria/export_library.rb +128 -127
- data/lib/alexandria/import_library.rb +102 -126
- data/lib/alexandria/import_library_csv.rb +41 -41
- data/lib/alexandria/library_collection.rb +6 -5
- data/lib/alexandria/library_sort_order.rb +4 -2
- data/lib/alexandria/library_store.rb +39 -28
- data/lib/alexandria/logging.rb +10 -14
- data/lib/alexandria/models/book.rb +5 -4
- data/lib/alexandria/models/library.rb +63 -53
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +66 -63
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +17 -17
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +110 -112
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +2 -2
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +108 -109
- data/lib/alexandria/ui/alert_dialog.rb +66 -0
- data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +13 -9
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -38
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +64 -157
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +187 -155
- data/lib/alexandria/ui/completion_models.rb +8 -22
- 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} +37 -58
- data/lib/alexandria/ui/icons.rb +38 -43
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +30 -41
- data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +9 -6
- data/lib/alexandria/ui/libraries_combo.rb +15 -14
- data/lib/alexandria/ui/listview.rb +69 -67
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +8 -9
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +113 -114
- data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +22 -19
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +7 -28
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +53 -48
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +216 -200
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +21 -21
- data/po/Makefile +2 -2
- data/po/cs.po +992 -875
- data/po/cy.po +961 -874
- data/po/de.po +990 -865
- data/po/el.po +989 -865
- data/po/es.po +985 -861
- data/po/fr.po +987 -867
- data/po/ga.po +908 -820
- data/po/gl.po +980 -860
- data/po/it.po +986 -864
- data/po/ja.po +969 -849
- data/po/mk.po +984 -860
- data/po/nb.po +979 -859
- data/po/nl.po +983 -860
- data/po/pl.po +1018 -971
- data/po/pt.po +988 -857
- data/po/pt_BR.po +983 -863
- data/po/ru.po +994 -871
- data/po/sk.po +989 -867
- data/po/sv.po +976 -856
- data/po/uk.po +972 -858
- data/po/zh_TW.po +974 -854
- data/schemas/alexandria.schemas +24 -2
- data/share/alexandria/glade/acquire_dialog__builder.glade +1 -1
- data/share/alexandria/glade/book_properties_dialog__builder.glade +1 -1
- data/share/alexandria/glade/main_app__builder.glade +6 -21
- data/share/alexandria/glade/new_book_dialog__builder.glade +1 -1
- data/share/alexandria/glade/preferences_dialog__builder.glade +1 -1
- data/share/gnome/help/alexandria/C/introduction.xml +0 -4
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +62 -156
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +6 -11
- data/spec/alexandria/export_library_spec.rb +47 -58
- data/spec/alexandria/library_spec.rb +121 -109
- data/spec/alexandria/library_store_spec.rb +8 -8
- data/spec/alexandria/preferences_spec.rb +44 -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 +59 -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 +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +51 -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 +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -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 +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +44 -20
- data/spec/end_to_end/basic_run_spec.rb +21 -38
- data/spec/fixtures/cover.jpg +0 -0
- data/spec/spec_helper.rb +54 -10
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +11 -11
- data/util/rake/fileinstall.rb +38 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +158 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/renaud.rb +0 -155
- data/lib/alexandria/book_providers/thalia.rb +0 -198
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -63
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -176
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -62
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -563
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -423
- 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/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
@@ -1,186 +1,92 @@
|
|
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
|
28
|
-
|
29
|
-
def assert_correct_search_result(provider, query,
|
30
|
-
search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
|
31
|
-
begin
|
32
|
-
results = provider.instance.search(query, search_type)
|
33
|
-
rescue SocketError
|
34
|
-
skip 'Service is offline'
|
35
|
-
end
|
36
|
-
|
37
|
-
puts results.inspect if $DEBUG
|
38
|
-
|
39
|
-
expect(results).to be_instance_of(Array), "Results are not an array for #{provider}"
|
40
|
-
expect(results).not_to be_empty, "Results are empty for #{provider}"
|
41
|
-
|
42
|
-
if search_type == Alexandria::BookProviders::SEARCH_BY_ISBN
|
43
|
-
expect(results.length).to be <= 2, "Results are greater than 2 for #{provider}"
|
44
|
-
|
45
|
-
book = results.first
|
46
|
-
|
47
|
-
expect(book).to be_instance_of(Alexandria::Book), "Result is not a Book for #{provider}"
|
10
|
+
it "should be less clever"
|
48
11
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
to eq(canonical_result),
|
53
|
-
"Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
|
54
|
-
|
55
|
-
if results.length == 2
|
56
|
-
cover_url = results.last
|
57
|
-
if cover_url
|
58
|
-
expect(cover_url).
|
59
|
-
to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
else
|
63
|
-
expect(results.first.first).
|
64
|
-
to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
|
12
|
+
describe Alexandria::BookProviders::AmazonProvider do
|
13
|
+
before do
|
14
|
+
skip "Amazon requires an API key. Remove it altogether as a provider?"
|
65
15
|
end
|
66
|
-
results
|
67
|
-
end
|
68
16
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
'033025068X')
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'amazon should work' do
|
76
|
-
skip 'Amazon requires an API key. Remove it altogether as a provider?'
|
77
|
-
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
78
|
-
'9780385504201')
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'amazon title should work' do
|
82
|
-
skip 'Amazon requires an API key. Remove it altogether as a provider?'
|
83
|
-
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
84
|
-
'A Confederacy of Dunces', Alexandria::BookProviders::SEARCH_BY_TITLE)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'amazon authors should work' do
|
88
|
-
skip 'Amazon requires an API key. Remove it altogether as a provider?'
|
89
|
-
assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
|
90
|
-
'John Kennedy Toole', Alexandria::BookProviders::SEARCH_BY_AUTHORS)
|
91
|
-
end
|
17
|
+
it "does not piss off Rich Burridge" do
|
18
|
+
assert_correct_search_result(described_class, "033025068X")
|
19
|
+
end
|
92
20
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
'Confederacy Dunces', Alexandria::BookProviders::SEARCH_BY_KEYWORD)
|
97
|
-
end
|
21
|
+
it "works" do
|
22
|
+
assert_correct_search_result(described_class, "9780385504201")
|
23
|
+
end
|
98
24
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
|
104
|
-
'9782070379248')
|
105
|
-
end
|
25
|
+
it "works when searching for title" do
|
26
|
+
assert_correct_search_result(described_class, "A Confederacy of Dunces",
|
27
|
+
Alexandria::BookProviders::SEARCH_BY_TITLE)
|
28
|
+
end
|
106
29
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
30
|
+
it "amazon authors should work" do
|
31
|
+
assert_correct_search_result(described_class, "John Kennedy Toole",
|
32
|
+
Alexandria::BookProviders::SEARCH_BY_AUTHORS)
|
33
|
+
end
|
112
34
|
|
113
|
-
|
114
|
-
|
115
|
-
|
35
|
+
it "amazon keyword should work" do
|
36
|
+
assert_correct_search_result(described_class, "Confederacy Dunces",
|
37
|
+
Alexandria::BookProviders::SEARCH_BY_KEYWORD)
|
38
|
+
end
|
116
39
|
end
|
117
40
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
41
|
+
describe Alexandria::BookProviders::LOCProvider do
|
42
|
+
it "works for a book with ASCII title" do
|
43
|
+
assert_correct_search_result(described_class, "9780805335583")
|
44
|
+
end
|
123
45
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
'9789026965746')
|
128
|
-
assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
|
129
|
-
'9780586071403')
|
46
|
+
it "works for a book with a title with non-ASCII letters" do
|
47
|
+
assert_correct_search_result(described_class, "9782070379248")
|
48
|
+
end
|
130
49
|
end
|
131
50
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
# international book
|
138
|
-
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
139
|
-
'9780440241904')
|
140
|
-
# movie dvd
|
141
|
-
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
142
|
-
'4010232037824')
|
143
|
-
# music cd
|
144
|
-
assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
|
145
|
-
'0094638203520')
|
51
|
+
describe Alexandria::BookProviders::BLProvider do
|
52
|
+
it "works" do
|
53
|
+
skip "Not working: connect failed"
|
54
|
+
assert_correct_search_result(described_class, "9781853260803")
|
55
|
+
end
|
146
56
|
end
|
147
57
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
58
|
+
describe Alexandria::BookProviders::SBNProvider do
|
59
|
+
it "works" do
|
60
|
+
assert_correct_search_result(described_class, "9788835926436")
|
61
|
+
end
|
152
62
|
end
|
153
63
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
64
|
+
describe Alexandria::BookProviders::BarnesAndNobleProvider do
|
65
|
+
it "works" do
|
66
|
+
skip "Barnes and Noble is not operational at the moment"
|
67
|
+
assert_correct_search_result(described_class, "9780961328917") # see #1433
|
68
|
+
end
|
158
69
|
end
|
159
70
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
assert_correct_search_result(Alexandria::BookProviders::RENAUDProvider,
|
167
|
-
'9782764605059')
|
71
|
+
describe Alexandria::BookProviders::ProxisProvider do
|
72
|
+
it "works" do
|
73
|
+
skip "Needs fixing"
|
74
|
+
assert_correct_search_result(described_class, "9789026965746")
|
75
|
+
assert_correct_search_result(described_class, "9780586071403")
|
76
|
+
end
|
168
77
|
end
|
169
78
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
'9785941454136')
|
79
|
+
describe Alexandria::BookProviders::AdLibrisProvider do
|
80
|
+
it "works" do
|
81
|
+
skip "Needs fixing: site has changed"
|
82
|
+
assert_correct_search_result(described_class, "9789100109332")
|
83
|
+
end
|
176
84
|
end
|
177
85
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
# puts this_book.authors
|
184
|
-
expect(this_book.authors.length).to eq(2), 'Wrong number of authors for this book!'
|
86
|
+
describe Alexandria::BookProviders::SicilianoProvider do
|
87
|
+
it "works" do
|
88
|
+
skip "Needs fixing: no results found"
|
89
|
+
assert_correct_search_result(described_class, "9788599170380")
|
90
|
+
end
|
185
91
|
end
|
186
92
|
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,29 +4,24 @@
|
|
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
|
-
FileUtils.rm_rf(TESTDIR)
|
14
13
|
FileUtils.cp_r(lib_version, TESTDIR)
|
15
14
|
end
|
16
15
|
|
17
|
-
describe
|
18
|
-
it
|
19
|
-
expect(
|
20
|
-
The Dispossessed, Ursula Le Guin
|
16
|
+
describe ".list_books_on_console" do
|
17
|
+
it "returns a string containing a list of all books" do
|
18
|
+
expect(described_class.list_books_on_console).to eq <<~LIST
|
21
19
|
Pattern Recognition, William Gibson
|
22
20
|
Bonjour Tristesse, Francoise Sagan & Irene Ash
|
23
21
|
An Artist of the Floating World, Kazuo Ishiguro
|
22
|
+
The Dispossessed, Ursula Le Guin
|
24
23
|
Neverwhere, Neil Gaiman
|
25
24
|
LIST
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
FileUtils.rm_rf(TESTDIR)
|
31
|
-
end
|
32
27
|
end
|
@@ -4,67 +4,60 @@
|
|
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(:
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
let(:my_library) do
|
11
|
+
loader = Alexandria::LibraryStore.new(TESTDIR)
|
12
|
+
loader.load_library("My Library")
|
13
|
+
end
|
14
14
|
let(:format) { Alexandria::ExportFormat.all.find { |it| it.message == message } }
|
15
|
-
let(:
|
16
|
-
|
17
|
-
|
15
|
+
let(:outfile) do
|
16
|
+
outfile_base = format.ext ? "my-library.#{format.ext}" : "my-library"
|
17
|
+
File.join(Dir.tmpdir, outfile_base)
|
18
|
+
end
|
18
19
|
let(:unsorted) { Alexandria::LibrarySortOrder::Unsorted.new }
|
19
20
|
|
20
21
|
before do
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
test_library = File.join(LIBDIR, "0.6.2")
|
23
|
+
FileUtils.cp_r(test_library, TESTDIR)
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
FileUtils.rm_rf(outfile) if File.exist? outfile
|
24
28
|
end
|
25
29
|
|
26
|
-
describe
|
30
|
+
describe "#export_as_csv_list" do
|
27
31
|
let(:message) { :export_as_csv_list }
|
28
32
|
|
29
33
|
def load_rows_from_csv
|
30
|
-
CSV.read(outfile, col_sep:
|
34
|
+
CSV.read(outfile, col_sep: ";", headers: true)
|
31
35
|
end
|
32
36
|
|
33
|
-
it
|
37
|
+
it "can sort by title" do
|
34
38
|
sort_by_title = Alexandria::LibrarySortOrder.new(:title)
|
35
|
-
format.invoke(
|
36
|
-
expect(File.exist?(outfile)).to be_truthy
|
39
|
+
format.invoke(my_library, sort_by_title, outfile)
|
37
40
|
rows = load_rows_from_csv
|
38
|
-
rows.
|
39
|
-
expect(
|
40
|
-
TITLE = 0
|
41
|
-
comparisons = rows.size - 1
|
42
|
-
comparisons.times do |index|
|
43
|
-
expect(rows[index][TITLE]).to be <= rows[index + 1][TITLE]
|
44
|
-
end
|
41
|
+
titles = rows.map { |it| it["Title"] }
|
42
|
+
expect(titles).to eq titles.sort
|
45
43
|
end
|
46
44
|
|
47
|
-
it
|
45
|
+
it "can sort in descending order" do
|
48
46
|
sort_by_date_desc = Alexandria::LibrarySortOrder.new(:publishing_year, false)
|
49
|
-
format.invoke(
|
50
|
-
expect(File.exist?(outfile)).to be_truthy
|
47
|
+
format.invoke(my_library, sort_by_date_desc, outfile)
|
51
48
|
rows = load_rows_from_csv
|
52
|
-
rows.
|
53
|
-
expect(
|
54
|
-
DATE = 5
|
55
|
-
comparisons = rows.size - 1
|
56
|
-
comparisons.times do |index|
|
57
|
-
expect(rows[index][DATE]).to be >= rows[index + 1][DATE]
|
58
|
-
end
|
49
|
+
dates = rows.map { |it| it["Year Published"] }
|
50
|
+
expect(dates).to eq dates.sort.reverse
|
59
51
|
end
|
60
52
|
end
|
61
53
|
|
62
|
-
describe
|
54
|
+
describe "#export_as_html" do
|
63
55
|
let(:message) { :export_as_html }
|
64
|
-
let(:index) { File.join(outfile, 'index.html') }
|
65
56
|
|
66
|
-
it
|
67
|
-
format.invoke(
|
57
|
+
it "can export unsorted" do
|
58
|
+
format.invoke(my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
|
59
|
+
index = File.join(outfile, "index.html")
|
60
|
+
|
68
61
|
aggregate_failures do
|
69
62
|
expect(File.exist?(outfile)).to be_truthy
|
70
63
|
expect(File.exist?(index)).to be_truthy
|
@@ -73,11 +66,11 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
73
66
|
end
|
74
67
|
end
|
75
68
|
|
76
|
-
describe
|
69
|
+
describe "#export_as_onix_xml_archive" do
|
77
70
|
let(:message) { :export_as_onix_xml_archive }
|
78
71
|
|
79
|
-
it
|
80
|
-
format.invoke(
|
72
|
+
it "can export unsorted" do
|
73
|
+
format.invoke(my_library, unsorted, outfile)
|
81
74
|
aggregate_failures do
|
82
75
|
expect(File.exist?(outfile)).to be_truthy
|
83
76
|
expect(File.size(outfile)).to be_nonzero
|
@@ -85,11 +78,11 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
85
78
|
end
|
86
79
|
end
|
87
80
|
|
88
|
-
describe
|
81
|
+
describe "#export_as_tellico_xml_archive" do
|
89
82
|
let(:message) { :export_as_tellico_xml_archive }
|
90
83
|
|
91
|
-
it
|
92
|
-
format.invoke(
|
84
|
+
it "can export unsorted" do
|
85
|
+
format.invoke(my_library, unsorted, outfile)
|
93
86
|
aggregate_failures do
|
94
87
|
expect(File.exist?(outfile)).to be_truthy
|
95
88
|
expect(File.size(outfile)).to be_nonzero
|
@@ -97,11 +90,11 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
97
90
|
end
|
98
91
|
end
|
99
92
|
|
100
|
-
describe
|
93
|
+
describe "#export_as_bibtex" do
|
101
94
|
let(:message) { :export_as_bibtex }
|
102
95
|
|
103
|
-
it
|
104
|
-
format.invoke(
|
96
|
+
it "can export unsorted" do
|
97
|
+
format.invoke(my_library, unsorted, outfile)
|
105
98
|
aggregate_failures do
|
106
99
|
expect(File.exist?(outfile)).to be_truthy
|
107
100
|
expect(File.size(outfile)).to be_nonzero
|
@@ -109,11 +102,11 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
109
102
|
end
|
110
103
|
end
|
111
104
|
|
112
|
-
describe
|
105
|
+
describe "#export_as_isbn_list" do
|
113
106
|
let(:message) { :export_as_isbn_list }
|
114
107
|
|
115
|
-
it
|
116
|
-
format.invoke(
|
108
|
+
it "can export unsorted" do
|
109
|
+
format.invoke(my_library, unsorted, outfile)
|
117
110
|
aggregate_failures do
|
118
111
|
expect(File.exist?(outfile)).to be_truthy
|
119
112
|
expect(File.size(outfile)).to be_nonzero
|
@@ -121,21 +114,17 @@ RSpec.describe Alexandria::ExportLibrary do
|
|
121
114
|
end
|
122
115
|
end
|
123
116
|
|
124
|
-
describe
|
117
|
+
describe "#export_as_ipod_notes" do
|
125
118
|
let(:message) { :export_as_ipod_notes }
|
126
|
-
let(:index) { File.join(outfile, 'index.linx') }
|
127
119
|
|
128
|
-
it
|
129
|
-
format.invoke(
|
120
|
+
it "can export unsorted" do
|
121
|
+
format.invoke(my_library, unsorted, outfile, nil)
|
122
|
+
index = File.join(outfile, "index.linx")
|
123
|
+
|
130
124
|
aggregate_failures do
|
131
125
|
expect(File.exist?(outfile)).to be_truthy
|
132
126
|
expect(File.size(index)).to be_nonzero
|
133
127
|
end
|
134
128
|
end
|
135
129
|
end
|
136
|
-
|
137
|
-
after(:each) do
|
138
|
-
FileUtils.rm_rf(TESTDIR)
|
139
|
-
FileUtils.rm_rf(outfile) if File.exist? outfile
|
140
|
-
end
|
141
130
|
end
|