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
@@ -4,88 +4,88 @@
|
|
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
|
describe Alexandria::Library do
|
10
10
|
let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe "::EXT" do
|
13
|
+
it "has symbolic references to file extensions" do
|
14
14
|
extensions = Alexandria::Library::EXT
|
15
15
|
expect(extensions[:book]).not_to be_nil
|
16
16
|
expect(extensions[:cover]).not_to be_nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
21
|
-
it
|
22
|
-
|
23
|
-
expect(
|
20
|
+
describe "#valid_isbn?" do
|
21
|
+
it "returns a true value for valid isbns" do
|
22
|
+
["014143984X", "0-345-43192-8"].each do |x|
|
23
|
+
expect(described_class.valid_isbn?(x)).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
30
|
-
expect(
|
31
|
-
expect(
|
28
|
+
describe "#valid_ean?" do
|
29
|
+
it "returns a true value for valid EANs" do
|
30
|
+
expect(described_class.valid_ean?("9780345431929")).to be_truthy
|
31
|
+
expect(described_class.valid_ean?("978034543192912345")).to be_truthy
|
32
32
|
|
33
33
|
# Regression test: this EAN has a checksum of 10, which should be
|
34
34
|
# treated like a checksum of 0.
|
35
|
-
expect(
|
35
|
+
expect(described_class.valid_ean?("9784047041790")).to be_truthy
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
38
|
+
it "returns a false value for invalid EANs" do
|
39
|
+
expect(described_class.valid_ean?("780345431929")).to be_falsey
|
40
|
+
expect(described_class.valid_ean?("97803454319290")).to be_falsey
|
41
|
+
expect(described_class.valid_ean?("97803454319291234")).to be_falsey
|
42
|
+
expect(described_class.valid_ean?("9780345431929123456")).to be_falsey
|
43
|
+
expect(described_class.valid_ean?("9780345431928")).to be_falsey
|
44
|
+
expect(described_class.valid_ean?("9780345431929A")).to be_falsey
|
45
45
|
|
46
|
-
expect(
|
46
|
+
expect(described_class.valid_ean?("9784047041791")).to be_falsey
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it
|
52
|
-
expect(
|
50
|
+
describe "#valid_upc?" do
|
51
|
+
it "returns a true value for valid UPCs" do
|
52
|
+
expect(described_class.valid_upc?("97803454319312356")).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
expect(
|
57
|
-
expect(
|
55
|
+
it "returns a false value for invalid UPCs" do
|
56
|
+
expect(described_class.valid_upc?("978034543193123567")).to be_falsey
|
57
|
+
expect(described_class.valid_upc?("9780345431931235")).to be_falsey
|
58
58
|
|
59
|
-
expect(
|
60
|
-
expect(
|
59
|
+
expect(described_class.valid_upc?("97803454319412356")).to be_falsey
|
60
|
+
expect(described_class.valid_upc?("97803454319212356")).to be_falsey
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
65
|
-
it
|
66
|
-
expect(
|
67
|
-
expect(
|
68
|
-
expect(
|
64
|
+
describe "#canonicalise_isbn" do
|
65
|
+
it "returns the correct value for several examples" do
|
66
|
+
expect(described_class.canonicalise_isbn("014143984X")).to eq "014143984X"
|
67
|
+
expect(described_class.canonicalise_isbn("0-345-43192-8")).to eq "0345431928"
|
68
|
+
expect(described_class.canonicalise_isbn("3522105907")).to eq "3522105907"
|
69
69
|
# EAN number
|
70
|
-
expect(
|
70
|
+
expect(described_class.canonicalise_isbn("9780345431929")).to eq "0345431928"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
context
|
75
|
-
let(:my_library) { loader.load_library(
|
74
|
+
context "with an empty library" do
|
75
|
+
let(:my_library) { loader.load_library("Empty") }
|
76
76
|
|
77
|
-
before
|
77
|
+
before do
|
78
78
|
FileUtils.mkdir(TESTDIR) unless File.exist? TESTDIR
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it "disallows multiple deletion of the same copy of a book" do
|
82
82
|
first_copy = an_artist_of_the_floating_world
|
83
83
|
my_library << first_copy
|
84
84
|
my_library.delete(first_copy)
|
85
85
|
expect { my_library.delete(first_copy) }.to raise_error ArgumentError
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "allows multiple copies of a book to be added and deleted in turn" do
|
89
89
|
first_copy = an_artist_of_the_floating_world
|
90
90
|
my_library << first_copy
|
91
91
|
my_library.delete(first_copy)
|
@@ -97,125 +97,137 @@ describe Alexandria::Library do
|
|
97
97
|
|
98
98
|
expect { my_library.delete(second_copy) }.not_to raise_error
|
99
99
|
end
|
100
|
-
|
101
|
-
after(:each) do
|
102
|
-
FileUtils.rm_rf(TESTDIR)
|
103
|
-
end
|
104
100
|
end
|
105
101
|
|
106
|
-
describe
|
107
|
-
|
102
|
+
describe ".import_as_isbn_list" do
|
103
|
+
before do
|
108
104
|
libraries = Alexandria::LibraryCollection.instance
|
109
|
-
library =
|
105
|
+
library = described_class.new("Test Library")
|
110
106
|
libraries.add_library(library)
|
111
|
-
|
107
|
+
|
108
|
+
allow(Alexandria::BookProviders)
|
109
|
+
.to receive(:isbn_search)
|
110
|
+
.and_raise Alexandria::BookProviders::SearchEmptyError
|
111
|
+
allow(Alexandria::BookProviders)
|
112
|
+
.to receive(:isbn_search).with("0595371086")
|
113
|
+
.and_return(an_artist_of_the_floating_world)
|
112
114
|
end
|
113
115
|
|
114
|
-
it "
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
116
|
+
it "imports books with correct isbn and search result" do
|
117
|
+
library, bad_isbns, failed_lookup_isbns =
|
118
|
+
described_class.import_as_isbn_list("Test Library", "spec/data/isbns.txt",
|
119
|
+
proc {}, proc {})
|
120
|
+
|
121
|
+
aggregate_failures do
|
122
|
+
expect(library.to_a).to eq [an_artist_of_the_floating_world]
|
123
|
+
expect(bad_isbns).to eq ["0911826449"]
|
124
|
+
expect(failed_lookup_isbns).to eq ["0740704923"]
|
125
|
+
end
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
125
|
-
context
|
126
|
-
|
127
|
-
|
129
|
+
context "when importing from 0.6.1 data files" do
|
130
|
+
let(:libs) { loader.load_all_libraries }
|
131
|
+
let(:my_library) { libs[0] }
|
132
|
+
|
133
|
+
before do
|
134
|
+
lib_version = File.join(LIBDIR, "0.6.1")
|
128
135
|
FileUtils.cp_r(lib_version, TESTDIR)
|
129
136
|
end
|
130
137
|
|
131
|
-
it
|
132
|
-
libs = loader.load_all_libraries
|
138
|
+
it "can be loaded" do
|
133
139
|
expect(libs.size).to eq(1)
|
134
|
-
my_library = libs[0]
|
135
140
|
expect(my_library.size).to eq(3)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "imports cleanly from version 0.6.1 data format" do
|
136
144
|
# Malory
|
137
|
-
malory_book = my_library.
|
138
|
-
expect(malory_book.publisher).to eq(
|
139
|
-
expect(malory_book.authors.include?(
|
145
|
+
malory_book = my_library.find { |b| b.isbn == "9780192812179" }
|
146
|
+
expect(malory_book.publisher).to eq("Oxford University Press")
|
147
|
+
expect(malory_book.authors.include?("Vinaver")).to be_truthy
|
140
148
|
expect(malory_book.version).to eq(Alexandria::DATA_VERSION)
|
141
149
|
|
142
150
|
# Guide to LaTeX
|
143
|
-
latex_book = my_library.
|
144
|
-
expect(latex_book.isbn).to eq(
|
145
|
-
expect(latex_book.publisher).to eq(
|
146
|
-
end
|
147
|
-
|
148
|
-
after(:each) do
|
149
|
-
FileUtils.rm_rf(TESTDIR)
|
151
|
+
latex_book = my_library.find { |b| b.title.include? "Latex" }
|
152
|
+
expect(latex_book.isbn).to eq("9780201398250")
|
153
|
+
expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
|
-
context
|
154
|
-
|
155
|
-
|
157
|
+
context "when importing from 0.6.1 with books without an ISBN" do
|
158
|
+
let(:libs) { loader.load_all_libraries }
|
159
|
+
let(:my_library) { libs[0] }
|
160
|
+
|
161
|
+
before do
|
162
|
+
lib_version = File.join(LIBDIR, "0.6.1-noisbn")
|
156
163
|
FileUtils.cp_r(lib_version, TESTDIR)
|
157
164
|
end
|
158
165
|
|
159
|
-
|
160
|
-
|
166
|
+
after do
|
167
|
+
FileUtils.rm_rf(TESTDIR)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "can be loaded" do
|
161
171
|
expect(libs.size).to eq(1)
|
162
|
-
my_library = libs[0]
|
163
172
|
expect(my_library.size).to eq(2)
|
173
|
+
end
|
164
174
|
|
175
|
+
it "loads a book with ISBN" do
|
165
176
|
# Guide to LaTeX
|
166
|
-
latex_book = my_library.
|
167
|
-
expect(latex_book.isbn).to eq(
|
168
|
-
expect(latex_book.publisher).to eq(
|
177
|
+
latex_book = my_library.find { |b| b.title.include? "Latex" }
|
178
|
+
expect(latex_book.isbn).to eq("9780201398250")
|
179
|
+
expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
|
169
180
|
expect(latex_book.version).to eq(Alexandria::DATA_VERSION)
|
181
|
+
end
|
170
182
|
|
183
|
+
it "loads a book without ISBN" do
|
171
184
|
# Lex and Yacc
|
172
|
-
lex_and_yacc_book = my_library.
|
185
|
+
lex_and_yacc_book = my_library.find { |b| b.title.include? "Lex" }
|
173
186
|
expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
|
187
|
+
end
|
174
188
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
libraries_reloaded = loader.load_all_libraries
|
180
|
-
my_library_reloaded = libraries_reloaded[0]
|
181
|
-
|
189
|
+
it "saves loaded books properly" do
|
190
|
+
my_library.each { |book| my_library.save(book, true) }
|
191
|
+
my_library_reloaded = loader.load_all_libraries[0]
|
182
192
|
expect(my_library_reloaded.size).to eq(2)
|
183
193
|
|
184
|
-
latex_book = my_library_reloaded.
|
185
|
-
expect(latex_book).
|
186
|
-
expect(latex_book.publisher).to eq('Addison Wesley')
|
194
|
+
latex_book = my_library_reloaded.find { |b| b.title.include? "Latex" }
|
195
|
+
expect(latex_book.publisher).to eq("Addison Wesley")
|
187
196
|
|
188
|
-
lex_and_yacc_book = my_library_reloaded.
|
189
|
-
expect(lex_and_yacc_book).not_to be_nil
|
197
|
+
lex_and_yacc_book = my_library_reloaded.find { |b| b.title.include? "Lex" }
|
190
198
|
expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
|
191
199
|
end
|
192
|
-
|
193
|
-
after(:each) do
|
194
|
-
FileUtils.rm_rf(TESTDIR)
|
195
|
-
end
|
196
200
|
end
|
197
201
|
|
198
|
-
describe
|
199
|
-
|
200
|
-
|
202
|
+
describe ".move" do
|
203
|
+
let(:source) { loader.load_library("My Library") }
|
204
|
+
let(:target) { loader.load_library("Target") }
|
205
|
+
let(:book) { source.first }
|
206
|
+
|
207
|
+
before do
|
208
|
+
lib_version = File.join(LIBDIR, "0.6.2")
|
201
209
|
FileUtils.cp_r(lib_version, TESTDIR)
|
202
210
|
end
|
203
211
|
|
204
|
-
it
|
205
|
-
source = loader.load_library('My Library')
|
212
|
+
it "changes the number of books in the source and target libraries" do
|
206
213
|
count = source.count
|
207
|
-
book = source.first
|
208
|
-
target = loader.load_library('Target')
|
209
214
|
|
210
|
-
described_class.move(source, target,
|
215
|
+
described_class.move(source, target, book)
|
211
216
|
|
212
217
|
aggregate_failures do
|
213
218
|
expect(source.count).to eq count - 1
|
214
219
|
expect(target.count).to eq 1
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
it "moves the book files from source to target" do
|
224
|
+
described_class.move(source, target, book)
|
225
|
+
|
226
|
+
aggregate_failures do
|
227
|
+
expect(File.exist?(source.yaml(book))).to be_falsey
|
228
|
+
expect(File.exist?(source.cover(book))).to be_falsey
|
229
|
+
expect(File.exist?(target.yaml(book))).to be_truthy
|
230
|
+
expect(File.exist?(target.cover(book))).to be_truthy
|
219
231
|
end
|
220
232
|
end
|
221
233
|
end
|
@@ -4,27 +4,27 @@
|
|
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::LibraryStore do
|
10
10
|
let(:loader) { described_class.new(TESTDIR) }
|
11
11
|
|
12
|
-
describe
|
13
|
-
context
|
14
|
-
it
|
12
|
+
describe "#load_all_smart_libraries" do
|
13
|
+
context "when none exist" do
|
14
|
+
it "creates and saves some" do
|
15
15
|
smart_libs = loader.load_all_smart_libraries
|
16
16
|
aggregate_failures do
|
17
17
|
expect(smart_libs.size).to eq 5
|
18
18
|
smart_libs.each do |lib|
|
19
|
-
expect(File.exist?
|
19
|
+
expect(File.exist?(lib.yaml)).to be_truthy
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
context
|
26
|
-
it
|
27
|
-
existing = Alexandria::SmartLibrary.new(
|
25
|
+
context "when one exists" do
|
26
|
+
it "returns the existing smart library" do
|
27
|
+
existing = Alexandria::SmartLibrary.new("Hi", [], :all, loader)
|
28
28
|
existing.save
|
29
29
|
smart_libs = loader.load_all_smart_libraries
|
30
30
|
aggregate_failures do
|
@@ -1,24 +1,51 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# This file is part of Alexandria.
|
4
4
|
#
|
5
|
-
#
|
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.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
19
6
|
|
20
|
-
|
7
|
+
require_relative "../spec_helper"
|
21
8
|
|
22
9
|
describe Alexandria::Preferences do
|
23
|
-
|
10
|
+
let(:instance) { described_class.instance }
|
11
|
+
|
12
|
+
describe "#get_variable" do
|
13
|
+
it "returns nil fetching unknown setting" do
|
14
|
+
expect(instance.get_variable("does_not_exist")).to eq nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "allows fetching by string" do
|
18
|
+
instance.toolbar_visible = false
|
19
|
+
expect(instance.get_variable("toolbar_visible")).to eq false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "allows fetching by symbol" do
|
23
|
+
instance.toolbar_visible = true
|
24
|
+
expect(instance.get_variable(:toolbar_visible)).to eq true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#set_variable" do
|
29
|
+
it "allows setting by string" do
|
30
|
+
instance.toolbar_visible = false
|
31
|
+
instance.set_variable("toolbar_visible", true)
|
32
|
+
expect(instance.toolbar_visible).to eq true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "allows setting by symbol" do
|
36
|
+
instance.toolbar_visible = false
|
37
|
+
instance.set_variable(:toolbar_visible, true)
|
38
|
+
expect(instance.toolbar_visible).to eq true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "allows setting known setting to false" do
|
43
|
+
instance.toolbar_visible = false
|
44
|
+
expect(instance.toolbar_visible).to eq false
|
45
|
+
end
|
46
|
+
|
47
|
+
it "resets known setting by setting to nil" do
|
48
|
+
instance.toolbar_visible = nil
|
49
|
+
expect(instance.toolbar_visible).to eq true
|
50
|
+
end
|
24
51
|
end
|
@@ -0,0 +1,52 @@
|
|
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
|
+
require_relative "../../spec_helper"
|
8
|
+
|
9
|
+
describe Alexandria::Scanners::CueCat do
|
10
|
+
let(:cuecat) { described_class.new }
|
11
|
+
let(:partials) do
|
12
|
+
[".",
|
13
|
+
".C3nZC3nZC3n2ChnWENz7DxnY",
|
14
|
+
".C3nZC3nZC3n2ChnWENz7DxnY.",
|
15
|
+
".C3nZC3nZC3n2ChnWENz7DxnY.cGen",
|
16
|
+
".C3nZC3nZC3n2ChnWENz7DxnY.cGen.",
|
17
|
+
".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3z0CNj3Dhj1EW"]
|
18
|
+
end
|
19
|
+
let(:scans) do
|
20
|
+
{
|
21
|
+
isbn: ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3z0CNj3Dhj1EW.",
|
22
|
+
ib5: ".C3nZC3nZC3n2ChnWENz7DxnY.cGf2.ENr7C3z0DNn0ENnWE3nZDhP6."
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is called CueCat" do
|
27
|
+
expect(cuecat.name).to match(/CueCat/i)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "detects a complete scan only" do
|
31
|
+
partials.each { |scan| expect(cuecat.match?(scan)).not_to be_truthy }
|
32
|
+
expect(cuecat.match?(scans[:isbn])).to be_truthy
|
33
|
+
expect(cuecat.match?(scans[:ib5])).to be_truthy
|
34
|
+
end
|
35
|
+
|
36
|
+
it "decodes ISBN barcodes" do
|
37
|
+
expect(cuecat.decode(scans[:isbn])).to eq("9780571147168")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "decodes ISBN+5 barcodes" do
|
41
|
+
expect(cuecat.decode(scans[:ib5])).to eq("9780575079038") # 00799
|
42
|
+
# TODO are we supposed to keep the +5 bit?
|
43
|
+
end
|
44
|
+
|
45
|
+
it "decodes ISSN barcodes" do
|
46
|
+
skip "Test scan ISSN"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "decodes UPC barcodes" do
|
50
|
+
skip "Test scan UPC"
|
51
|
+
end
|
52
|
+
end
|