alexandria-book-collection-manager 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +4 -4
- data/.rubocop_todo.yml +55 -82
- data/CHANGELOG.md +17 -0
- data/INSTALL.md +3 -3
- data/README.md +1 -2
- data/Rakefile +14 -33
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +4 -3
- data/bin/alexandria +21 -34
- data/doc/FAQ +2 -5
- data/lib/alexandria.rb +4 -16
- data/lib/alexandria/book_providers.rb +5 -7
- data/lib/alexandria/book_providers/adlibris.rb +5 -3
- data/lib/alexandria/book_providers/amazon_aws.rb +3 -1
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +8 -0
- data/lib/alexandria/book_providers/barnes_and_noble.rb +7 -4
- data/lib/alexandria/book_providers/douban.rb +1 -1
- data/lib/alexandria/book_providers/proxis.rb +11 -27
- data/lib/alexandria/book_providers/renaud.rb +9 -3
- data/lib/alexandria/book_providers/siciliano.rb +7 -4
- data/lib/alexandria/book_providers/thalia.rb +5 -3
- data/lib/alexandria/book_providers/web.rb +11 -29
- data/lib/alexandria/book_providers/worldcat.rb +7 -5
- data/lib/alexandria/book_providers/z3950.rb +10 -7
- data/lib/alexandria/console.rb +5 -18
- data/lib/alexandria/execution_queue.rb +2 -1
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +72 -180
- data/lib/alexandria/import_library.rb +14 -23
- data/lib/alexandria/import_library_csv.rb +3 -6
- data/lib/alexandria/library_collection.rb +78 -0
- data/lib/alexandria/library_sort_order.rb +43 -0
- data/lib/alexandria/library_store.rb +222 -0
- data/lib/alexandria/logging.rb +2 -0
- data/lib/alexandria/models/book.rb +8 -16
- data/lib/alexandria/models/library.rb +26 -308
- data/lib/alexandria/preferences.rb +7 -24
- data/lib/alexandria/scanners/cuecat.rb +3 -1
- data/lib/alexandria/smart_library.rb +32 -67
- data/lib/alexandria/ui/builder_base.rb +6 -26
- data/lib/alexandria/ui/callbacks.rb +8 -34
- data/lib/alexandria/ui/completion_models.rb +2 -1
- data/lib/alexandria/ui/dialogs/about_dialog.rb +35 -47
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +14 -30
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +8 -17
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -24
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +17 -18
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +25 -41
- data/lib/alexandria/ui/dialogs/export_dialog.rb +48 -56
- data/lib/alexandria/ui/dialogs/import_dialog.rb +31 -51
- data/lib/alexandria/ui/dialogs/keep_bad_isbn_dialog.rb +33 -0
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +12 -25
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +57 -94
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +24 -42
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +9 -21
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +27 -32
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +5 -3
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +15 -12
- data/lib/alexandria/ui/icons.rb +11 -22
- data/lib/alexandria/ui/init.rb +3 -3
- data/lib/alexandria/ui/libraries_combo.rb +1 -0
- data/lib/alexandria/ui/listview.rb +5 -21
- data/lib/alexandria/ui/multi_drag_treeview.rb +20 -32
- data/lib/alexandria/ui/sidepane.rb +9 -24
- data/lib/alexandria/ui/ui_manager.rb +36 -60
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +2 -2
- data/lib/alexandria/web_themes.rb +1 -0
- data/po/cs.po +0 -4
- data/po/cy.po +0 -4
- data/po/de.po +0 -4
- data/po/el.po +0 -4
- data/po/es.po +0 -4
- data/po/fr.po +0 -4
- data/po/ga.po +0 -4
- data/po/gl.po +0 -4
- data/po/it.po +0 -4
- data/po/ja.po +0 -4
- data/po/mk.po +0 -4
- data/po/nb.po +0 -4
- data/po/nl.po +0 -4
- data/po/pl.po +0 -4
- data/po/pt.po +0 -4
- data/po/pt_BR.po +0 -4
- data/po/ru.po +0 -4
- data/po/sk.po +0 -4
- data/po/sv.po +0 -4
- data/po/uk.po +0 -4
- data/po/zh_TW.po +0 -4
- data/schemas/alexandria.schemas +1 -1
- data/share/alexandria/glade/acquire_dialog__builder.glade +14 -11
- data/share/alexandria/glade/book_properties_dialog__builder.glade +170 -298
- data/share/alexandria/glade/main_app__builder.glade +22 -16
- data/share/alexandria/glade/new_book_dialog__builder.glade +26 -58
- data/share/alexandria/glade/preferences_dialog__builder.glade +249 -289
- data/share/gnome/help/alexandria/C/introduction.xml +0 -4
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
- data/spec/alexandria/book_providers_spec.rb +1 -20
- data/spec/alexandria/console_spec.rb +32 -0
- data/spec/alexandria/export_library_spec.rb +141 -0
- data/spec/alexandria/library_spec.rb +24 -80
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/smart_library_spec.rb +27 -22
- data/spec/alexandria/ui/dialogs/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/dialogs_spec.rb +104 -38
- data/spec/end_to_end/basic_run_spec.rb +69 -0
- data/spec/spec_helper.rb +13 -25
- data/tasks/spec.rake +15 -2
- data/util/rake/fileinstall.rb +1 -0
- metadata +38 -16
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
@@ -44,10 +44,6 @@
|
|
44
44
|
<para><ulink url="http://www.barnesandnoble.com">Barnes and Noble</ulink></para>
|
45
45
|
</listitem>
|
46
46
|
|
47
|
-
<listitem>
|
48
|
-
<para><ulink url="http://www.mcu.es">Spanish Ministry of Culture</ulink></para>
|
49
|
-
</listitem>
|
50
|
-
|
51
47
|
<listitem>
|
52
48
|
<para><ulink url="http://www.thalia.de">Thalia</ulink></para>
|
53
49
|
</listitem>
|
@@ -36,10 +36,6 @@
|
|
36
36
|
<para><ulink url="http://www.barnesandnoble.com">Barnes and Noble</ulink></para>
|
37
37
|
</listitem>
|
38
38
|
|
39
|
-
<listitem>
|
40
|
-
<para><ulink url="http://www.mcu.es">Spanish Ministry of Culture</ulink></para>
|
41
|
-
</listitem>
|
42
|
-
|
43
39
|
<listitem>
|
44
40
|
<para><ulink url="http://www.thalia.de">Thalia</ulink></para>
|
45
41
|
</listitem>
|
@@ -96,16 +96,6 @@ describe Alexandria::BookProviders do
|
|
96
96
|
'Confederacy Dunces', Alexandria::BookProviders::SEARCH_BY_KEYWORD)
|
97
97
|
end
|
98
98
|
|
99
|
-
it 'dea should work' do
|
100
|
-
skip 'DEAStore is not operational at the moment'
|
101
|
-
assert_correct_search_result(Alexandria::BookProviders::DeaStoreProvider,
|
102
|
-
'9788817012980')
|
103
|
-
assert_correct_search_result(Alexandria::BookProviders::DeaStoreProvider,
|
104
|
-
'9788806134747')
|
105
|
-
end
|
106
|
-
|
107
|
-
# Right? Don't test if dependency isn't present.
|
108
|
-
|
109
99
|
it 'LOC should work' do
|
110
100
|
assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
|
111
101
|
'9780805335583')
|
@@ -115,6 +105,7 @@ describe Alexandria::BookProviders do
|
|
115
105
|
end
|
116
106
|
|
117
107
|
it 'BL should work' do
|
108
|
+
skip 'Not working: connect failed'
|
118
109
|
assert_correct_search_result(Alexandria::BookProviders::BLProvider,
|
119
110
|
'9781853260803')
|
120
111
|
end
|
@@ -130,16 +121,6 @@ describe Alexandria::BookProviders do
|
|
130
121
|
'9780961328917') # see #1433
|
131
122
|
end
|
132
123
|
|
133
|
-
it 'MCU should work' do
|
134
|
-
skip 'Needs fixing'
|
135
|
-
# this book is without binding information, see bug [#2533]
|
136
|
-
assert_correct_search_result(Alexandria::BookProviders::MCUProvider,
|
137
|
-
'9788487982033')
|
138
|
-
# this book is "agotado" (out of print), see bug [#2518]
|
139
|
-
assert_correct_search_result(Alexandria::BookProviders::MCUProvider,
|
140
|
-
'9788496075856')
|
141
|
-
end
|
142
|
-
|
143
124
|
it 'Proxis should work' do
|
144
125
|
skip 'Needs fixing'
|
145
126
|
assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
|
@@ -0,0 +1,32 @@
|
|
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 'spec_helper'
|
8
|
+
|
9
|
+
RSpec.describe Alexandria do
|
10
|
+
let(:lib_version) { File.join(LIBDIR, '0.6.2') }
|
11
|
+
|
12
|
+
before do
|
13
|
+
FileUtils.rm_rf(TESTDIR)
|
14
|
+
FileUtils.cp_r(lib_version, TESTDIR)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.list_books_on_console' do
|
18
|
+
it 'returns a string containing a list of all books' do
|
19
|
+
expect(Alexandria.list_books_on_console).to eq <<~LIST
|
20
|
+
The Dispossessed, Ursula Le Guin
|
21
|
+
Pattern Recognition, William Gibson
|
22
|
+
Bonjour Tristesse, Francoise Sagan & Irene Ash
|
23
|
+
An Artist of the Floating World, Kazuo Ishiguro
|
24
|
+
Neverwhere, Neil Gaiman
|
25
|
+
LIST
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
after do
|
30
|
+
FileUtils.rm_rf(TESTDIR)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,141 @@
|
|
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 'spec_helper'
|
8
|
+
|
9
|
+
RSpec.describe Alexandria::ExportLibrary do
|
10
|
+
let(:lib_version) { File.join(LIBDIR, '0.6.2') }
|
11
|
+
|
12
|
+
let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
|
13
|
+
|
14
|
+
let(:format) { Alexandria::ExportFormat.all.find { |it| it.message == message } }
|
15
|
+
let(:outfile_base) { format.ext ? "my-library.#{format.ext}" : 'my-library' }
|
16
|
+
let(:outfile) { File.join(Dir.tmpdir, outfile_base) }
|
17
|
+
|
18
|
+
let(:unsorted) { Alexandria::LibrarySortOrder::Unsorted.new }
|
19
|
+
|
20
|
+
before do
|
21
|
+
FileUtils.cp_r(lib_version, TESTDIR)
|
22
|
+
@my_library = loader.load_library('My Library')
|
23
|
+
expect(@my_library.size).to eq 5
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#export_as_csv_list' do
|
27
|
+
let(:message) { :export_as_csv_list }
|
28
|
+
|
29
|
+
def load_rows_from_csv
|
30
|
+
CSV.read(outfile, col_sep: ';')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can sort by title' do
|
34
|
+
sort_by_title = Alexandria::LibrarySortOrder.new(:title)
|
35
|
+
format.invoke(@my_library, sort_by_title, outfile)
|
36
|
+
expect(File.exist?(outfile)).to be_truthy
|
37
|
+
rows = load_rows_from_csv
|
38
|
+
rows.shift
|
39
|
+
expect(rows.size).to eq(@my_library.size)
|
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
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'can sort in descending order' do
|
48
|
+
sort_by_date_desc = Alexandria::LibrarySortOrder.new(:publishing_year, false)
|
49
|
+
format.invoke(@my_library, sort_by_date_desc, outfile)
|
50
|
+
expect(File.exist?(outfile)).to be_truthy
|
51
|
+
rows = load_rows_from_csv
|
52
|
+
rows.shift
|
53
|
+
expect(rows.size).to eq(@my_library.size)
|
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
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#export_as_html' do
|
63
|
+
let(:message) { :export_as_html }
|
64
|
+
let(:index) { File.join(outfile, 'index.html') }
|
65
|
+
|
66
|
+
it 'can export unsorted' do
|
67
|
+
format.invoke(@my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
|
68
|
+
aggregate_failures do
|
69
|
+
expect(File.exist?(outfile)).to be_truthy
|
70
|
+
expect(File.exist?(index)).to be_truthy
|
71
|
+
expect(File.size(index)).to be_nonzero
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#export_as_onix_xml_archive' do
|
77
|
+
let(:message) { :export_as_onix_xml_archive }
|
78
|
+
|
79
|
+
it 'can export unsorted' do
|
80
|
+
format.invoke(@my_library, unsorted, outfile)
|
81
|
+
aggregate_failures do
|
82
|
+
expect(File.exist?(outfile)).to be_truthy
|
83
|
+
expect(File.size(outfile)).to be_nonzero
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#export_as_tellico_xml_archive' do
|
89
|
+
let(:message) { :export_as_tellico_xml_archive }
|
90
|
+
|
91
|
+
it 'can export unsorted' do
|
92
|
+
format.invoke(@my_library, unsorted, outfile)
|
93
|
+
aggregate_failures do
|
94
|
+
expect(File.exist?(outfile)).to be_truthy
|
95
|
+
expect(File.size(outfile)).to be_nonzero
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#export_as_bibtex' do
|
101
|
+
let(:message) { :export_as_bibtex }
|
102
|
+
|
103
|
+
it 'can export unsorted' do
|
104
|
+
format.invoke(@my_library, unsorted, outfile)
|
105
|
+
aggregate_failures do
|
106
|
+
expect(File.exist?(outfile)).to be_truthy
|
107
|
+
expect(File.size(outfile)).to be_nonzero
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#export_as_isbn_list' do
|
113
|
+
let(:message) { :export_as_isbn_list }
|
114
|
+
|
115
|
+
it 'can export unsorted' do
|
116
|
+
format.invoke(@my_library, unsorted, outfile)
|
117
|
+
aggregate_failures do
|
118
|
+
expect(File.exist?(outfile)).to be_truthy
|
119
|
+
expect(File.size(outfile)).to be_nonzero
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#export_as_ipod_notes' do
|
125
|
+
let(:message) { :export_as_ipod_notes }
|
126
|
+
let(:index) { File.join(outfile, 'index.linx') }
|
127
|
+
|
128
|
+
it 'can export unsorted' do
|
129
|
+
format.invoke(@my_library, unsorted, outfile, nil)
|
130
|
+
aggregate_failures do
|
131
|
+
expect(File.exist?(outfile)).to be_truthy
|
132
|
+
expect(File.size(index)).to be_nonzero
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
after(:each) do
|
138
|
+
FileUtils.rm_rf(TESTDIR)
|
139
|
+
FileUtils.rm_rf(outfile) if File.exist? outfile
|
140
|
+
end
|
141
|
+
end
|
@@ -1,28 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# Copyright (C) 2004-2006 Dafydd Harries
|
5
|
-
# Copyright (C) 2007 Cathal Mc Ginley
|
6
|
-
# Copyright (C) 2011, 2014-2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
7
4
|
#
|
8
|
-
#
|
9
|
-
# modify it under the terms of the GNU General Public License as
|
10
|
-
# published by the Free Software Foundation; either version 2 of the
|
11
|
-
# License, or (at your option) any later version.
|
12
|
-
#
|
13
|
-
# Alexandria is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
-
# General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU General Public
|
19
|
-
# License along with Alexandria; see the file COPYING. If not,
|
20
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
21
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
22
6
|
|
23
7
|
require 'spec_helper'
|
24
8
|
|
25
9
|
describe Alexandria::Library do
|
10
|
+
let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
|
11
|
+
|
26
12
|
describe '::EXT' do
|
27
13
|
it 'has symbolic references to file extensions' do
|
28
14
|
extensions = Alexandria::Library::EXT
|
@@ -86,12 +72,13 @@ describe Alexandria::Library do
|
|
86
72
|
end
|
87
73
|
|
88
74
|
context 'with an empty library' do
|
75
|
+
let(:my_library) { loader.load_library('Empty') }
|
76
|
+
|
89
77
|
before(:each) do
|
90
78
|
FileUtils.mkdir(TESTDIR) unless File.exist? TESTDIR
|
91
79
|
end
|
92
80
|
|
93
81
|
it 'disallows multiple deletion of the same copy of a book' do
|
94
|
-
my_library = Alexandria::Library.loadall[0]
|
95
82
|
first_copy = an_artist_of_the_floating_world
|
96
83
|
my_library << first_copy
|
97
84
|
my_library.delete(first_copy)
|
@@ -99,9 +86,7 @@ describe Alexandria::Library do
|
|
99
86
|
end
|
100
87
|
|
101
88
|
it 'allows multiple copies of a book to be added and deleted in turn' do
|
102
|
-
my_library = Alexandria::Library.loadall[0]
|
103
89
|
first_copy = an_artist_of_the_floating_world
|
104
|
-
# puts "first_copy #{first_copy.object_id}"
|
105
90
|
my_library << first_copy
|
106
91
|
my_library.delete(first_copy)
|
107
92
|
|
@@ -110,13 +95,7 @@ describe Alexandria::Library do
|
|
110
95
|
third_copy = an_artist_of_the_floating_world
|
111
96
|
my_library << third_copy
|
112
97
|
|
113
|
-
# puts "AAA my_library.size #{my_library.size}"
|
114
|
-
|
115
|
-
# puts "second_copy #{second_copy.object_id}"
|
116
98
|
expect { my_library.delete(second_copy) }.not_to raise_error
|
117
|
-
|
118
|
-
# puts "BBB my_library.size #{my_library.size}"
|
119
|
-
# my_library.size.should == 1 # not yet an established feature...
|
120
99
|
end
|
121
100
|
|
122
101
|
after(:each) do
|
@@ -125,12 +104,8 @@ describe Alexandria::Library do
|
|
125
104
|
end
|
126
105
|
|
127
106
|
describe '.import_as_isbn_list' do
|
128
|
-
before :all do
|
129
|
-
require 'alexandria/import_library'
|
130
|
-
end
|
131
|
-
|
132
107
|
def __test_fake_import_isbns
|
133
|
-
libraries = Alexandria::
|
108
|
+
libraries = Alexandria::LibraryCollection.instance
|
134
109
|
library = Alexandria::Library.new('Test Library')
|
135
110
|
libraries.add_library(library)
|
136
111
|
[library, libraries]
|
@@ -154,7 +129,7 @@ describe Alexandria::Library do
|
|
154
129
|
end
|
155
130
|
|
156
131
|
it 'imports cleanly from version 0.6.1 data format' do
|
157
|
-
libs =
|
132
|
+
libs = loader.load_all_libraries
|
158
133
|
expect(libs.size).to eq(1)
|
159
134
|
my_library = libs[0]
|
160
135
|
expect(my_library.size).to eq(3)
|
@@ -182,7 +157,7 @@ describe Alexandria::Library do
|
|
182
157
|
end
|
183
158
|
|
184
159
|
it 'allows books to have no ISBN' do
|
185
|
-
libs =
|
160
|
+
libs = loader.load_all_libraries
|
186
161
|
expect(libs.size).to eq(1)
|
187
162
|
my_library = libs[0]
|
188
163
|
expect(my_library.size).to eq(2)
|
@@ -197,13 +172,11 @@ describe Alexandria::Library do
|
|
197
172
|
lex_and_yacc_book = my_library.select { |b| b.title.include? 'Lex' }[0]
|
198
173
|
expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
|
199
174
|
|
200
|
-
# puts "ident -> " + lex_and_yacc_book.ident
|
201
|
-
|
202
175
|
my_library.each do |book|
|
203
176
|
my_library.save(book, true)
|
204
177
|
end
|
205
178
|
|
206
|
-
libraries_reloaded =
|
179
|
+
libraries_reloaded = loader.load_all_libraries
|
207
180
|
my_library_reloaded = libraries_reloaded[0]
|
208
181
|
|
209
182
|
expect(my_library_reloaded.size).to eq(2)
|
@@ -211,12 +184,10 @@ describe Alexandria::Library do
|
|
211
184
|
latex_book = my_library_reloaded.select { |b| b.title.include? 'Latex' }[0]
|
212
185
|
expect(latex_book).not_to be_nil
|
213
186
|
expect(latex_book.publisher).to eq('Addison Wesley')
|
214
|
-
# puts latex_book.title
|
215
187
|
|
216
188
|
lex_and_yacc_book = my_library_reloaded.select { |b| b.title.include? 'Lex' }[0]
|
217
189
|
expect(lex_and_yacc_book).not_to be_nil
|
218
190
|
expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
|
219
|
-
# puts lex_and_yacc_book.title
|
220
191
|
end
|
221
192
|
|
222
193
|
after(:each) do
|
@@ -224,55 +195,28 @@ describe Alexandria::Library do
|
|
224
195
|
end
|
225
196
|
end
|
226
197
|
|
227
|
-
|
228
|
-
before(:all) do
|
229
|
-
require 'tmpdir'
|
230
|
-
require 'csv'
|
231
|
-
end
|
232
|
-
|
198
|
+
describe '.move' do
|
233
199
|
before(:each) do
|
234
200
|
lib_version = File.join(LIBDIR, '0.6.2')
|
235
201
|
FileUtils.cp_r(lib_version, TESTDIR)
|
236
|
-
@format = Alexandria::ExportFormat.new('CSV list', 'csv', :export_as_csv_list)
|
237
|
-
@outfile = File.join(Dir.tmpdir, 'my_library-0.6.2.csv')
|
238
|
-
@my_library = Alexandria::Library.loadall[0]
|
239
202
|
end
|
240
203
|
|
241
|
-
|
242
|
-
|
243
|
-
|
204
|
+
it 'moves the given book from source to target' do
|
205
|
+
source = loader.load_library('My Library')
|
206
|
+
count = source.count
|
207
|
+
book = source.first
|
208
|
+
target = loader.load_library('Target')
|
244
209
|
|
245
|
-
|
246
|
-
sort_by_title = Alexandria::LibrarySortOrder.new(:title)
|
247
|
-
@format.invoke(@my_library, sort_by_title, @outfile)
|
248
|
-
expect(File.exist?(@outfile)).to be_truthy
|
249
|
-
rows = load_rows_from_csv
|
250
|
-
rows.shift
|
251
|
-
expect(rows.size).to eq(@my_library.size)
|
252
|
-
TITLE = 0
|
253
|
-
comparisons = rows.size - 1
|
254
|
-
comparisons.times do |index|
|
255
|
-
expect(rows[index][TITLE]).to be <= rows[index + 1][TITLE]
|
256
|
-
end
|
257
|
-
end
|
210
|
+
described_class.move(source, target, source.first)
|
258
211
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
DATE = 5
|
267
|
-
comparisons = rows.size - 1
|
268
|
-
comparisons.times do |index|
|
269
|
-
expect(rows[index][DATE]).to be >= rows[index + 1][DATE]
|
212
|
+
aggregate_failures do
|
213
|
+
expect(source.count).to eq count - 1
|
214
|
+
expect(target.count).to eq 1
|
215
|
+
expect(File.exist? source.yaml(book)).to be_falsey
|
216
|
+
expect(File.exist? source.cover(book)).to be_falsey
|
217
|
+
expect(File.exist? target.yaml(book)).to be_truthy
|
218
|
+
expect(File.exist? target.cover(book)).to be_truthy
|
270
219
|
end
|
271
220
|
end
|
272
|
-
|
273
|
-
after(:each) do
|
274
|
-
FileUtils.rm_rf(TESTDIR)
|
275
|
-
File.unlink @outfile if File.exist? @outfile
|
276
|
-
end
|
277
221
|
end
|
278
222
|
end
|
@@ -0,0 +1,37 @@
|
|
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 'spec_helper'
|
8
|
+
|
9
|
+
RSpec.describe Alexandria::LibraryStore do
|
10
|
+
let(:loader) { described_class.new(TESTDIR) }
|
11
|
+
|
12
|
+
describe '#load_all_smart_libraries' do
|
13
|
+
context 'when none exist' do
|
14
|
+
it 'creates and saves some' do
|
15
|
+
smart_libs = loader.load_all_smart_libraries
|
16
|
+
aggregate_failures do
|
17
|
+
expect(smart_libs.size).to eq 5
|
18
|
+
smart_libs.each do |lib|
|
19
|
+
expect(File.exist? lib.yaml).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when one exists' do
|
26
|
+
it 'returns the existing smart library' do
|
27
|
+
existing = Alexandria::SmartLibrary.new('Hi', [], :all, loader)
|
28
|
+
existing.save
|
29
|
+
smart_libs = loader.load_all_smart_libraries
|
30
|
+
aggregate_failures do
|
31
|
+
expect(smart_libs.size).to eq 1
|
32
|
+
expect(smart_libs.first.yaml).to eq existing.yaml
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|