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.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -25
  3. data/.rubocop_todo.yml +87 -67
  4. data/CHANGELOG.md +12 -1
  5. data/Gemfile +4 -3
  6. data/README.md +16 -6
  7. data/Rakefile +71 -72
  8. data/alexandria-book-collection-manager.gemspec +44 -44
  9. data/bin/alexandria +12 -12
  10. data/lib/alexandria.rb +22 -22
  11. data/lib/alexandria/about.rb +50 -50
  12. data/lib/alexandria/book_providers.rb +50 -50
  13. data/lib/alexandria/book_providers/adlibris.rb +28 -44
  14. data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
  15. data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
  16. data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
  17. data/lib/alexandria/book_providers/douban.rb +21 -37
  18. data/lib/alexandria/book_providers/proxis.rb +24 -24
  19. data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
  20. data/lib/alexandria/book_providers/renaud.rb +44 -57
  21. data/lib/alexandria/book_providers/siciliano.rb +39 -39
  22. data/lib/alexandria/book_providers/thalia.rb +33 -33
  23. data/lib/alexandria/book_providers/web.rb +5 -5
  24. data/lib/alexandria/book_providers/worldcat.rb +44 -69
  25. data/lib/alexandria/book_providers/z3950.rb +94 -109
  26. data/lib/alexandria/config.rb +1 -1
  27. data/lib/alexandria/console.rb +3 -3
  28. data/lib/alexandria/export_format.rb +8 -8
  29. data/lib/alexandria/export_library.rb +112 -113
  30. data/lib/alexandria/import_library.rb +45 -45
  31. data/lib/alexandria/import_library_csv.rb +30 -30
  32. data/lib/alexandria/library_collection.rb +4 -4
  33. data/lib/alexandria/library_sort_order.rb +1 -1
  34. data/lib/alexandria/library_store.rb +14 -14
  35. data/lib/alexandria/logging.rb +5 -5
  36. data/lib/alexandria/models/book.rb +1 -1
  37. data/lib/alexandria/models/library.rb +36 -36
  38. data/lib/alexandria/net.rb +5 -5
  39. data/lib/alexandria/preferences.rb +32 -32
  40. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
  41. data/lib/alexandria/scanners/keyboard.rb +5 -5
  42. data/lib/alexandria/smart_library.rb +53 -53
  43. data/lib/alexandria/ui.rb +15 -15
  44. data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
  45. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
  46. data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
  47. data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
  48. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
  49. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
  50. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
  51. data/lib/alexandria/ui/builder_base.rb +1 -1
  52. data/lib/alexandria/ui/callbacks.rb +95 -91
  53. data/lib/alexandria/ui/completion_models.rb +7 -21
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  56. data/lib/alexandria/ui/dndable.rb +7 -7
  57. data/lib/alexandria/ui/error_dialog.rb +25 -0
  58. data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
  59. data/lib/alexandria/ui/icons.rb +6 -6
  60. data/lib/alexandria/ui/iconview.rb +7 -7
  61. data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
  62. data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
  63. data/lib/alexandria/ui/init.rb +16 -29
  64. data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
  65. data/lib/alexandria/ui/libraries_combo.rb +7 -7
  66. data/lib/alexandria/ui/listview.rb +40 -40
  67. data/lib/alexandria/ui/main_app.rb +22 -24
  68. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  69. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
  70. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
  71. data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
  72. data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
  73. data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
  74. data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
  75. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
  76. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  77. data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
  78. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
  79. data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
  80. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
  81. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
  82. data/lib/alexandria/ui/sound.rb +8 -8
  83. data/lib/alexandria/ui/ui_manager.rb +136 -135
  84. data/lib/alexandria/version.rb +4 -19
  85. data/lib/alexandria/web_themes.rb +8 -8
  86. data/po/cs.po +97 -97
  87. data/po/cy.po +97 -97
  88. data/po/de.po +97 -97
  89. data/po/el.po +97 -97
  90. data/po/es.po +97 -97
  91. data/po/fr.po +97 -97
  92. data/po/ga.po +97 -97
  93. data/po/gl.po +97 -97
  94. data/po/it.po +97 -97
  95. data/po/ja.po +97 -97
  96. data/po/mk.po +97 -97
  97. data/po/nb.po +97 -97
  98. data/po/nl.po +97 -97
  99. data/po/pl.po +97 -97
  100. data/po/pt.po +97 -97
  101. data/po/pt_BR.po +97 -97
  102. data/po/ru.po +97 -97
  103. data/po/sk.po +97 -97
  104. data/po/sv.po +97 -97
  105. data/po/uk.po +97 -97
  106. data/po/zh_TW.po +97 -97
  107. data/schemas/alexandria.schemas +24 -2
  108. data/spec/alexandria/book_providers_spec.rb +65 -82
  109. data/spec/alexandria/book_spec.rb +12 -10
  110. data/spec/alexandria/console_spec.rb +9 -9
  111. data/spec/alexandria/export_library_spec.rb +31 -31
  112. data/spec/alexandria/library_spec.rb +86 -86
  113. data/spec/alexandria/library_store_spec.rb +8 -8
  114. data/spec/alexandria/preferences_spec.rb +18 -17
  115. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  116. data/spec/alexandria/smart_library_spec.rb +15 -15
  117. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  118. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  119. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  120. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  121. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  122. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  123. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  124. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  125. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  126. data/spec/alexandria/ui/iconview_spec.rb +7 -21
  127. data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
  128. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  129. data/spec/alexandria/ui/main_app_spec.rb +6 -6
  130. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  131. data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
  132. data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
  133. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
  134. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  135. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
  136. data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
  137. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  138. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  139. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
  140. data/spec/alexandria/ui/sound_spec.rb +2 -2
  141. data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
  142. data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
  143. data/spec/alexandria/utilities_spec.rb +6 -6
  144. data/spec/end_to_end/basic_run_spec.rb +24 -36
  145. data/spec/spec_helper.rb +9 -9
  146. data/tasks/dogtail.rake +1 -1
  147. data/tasks/setup.rb +2 -2
  148. data/tasks/spec.rake +11 -11
  149. data/util/rake/fileinstall.rb +25 -25
  150. data/util/rake/gettextgenerate.rb +7 -7
  151. data/util/rake/omfgenerate.rb +7 -7
  152. metadata +59 -33
  153. data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
  154. data/spec/alexandria/ui/dialogs_spec.rb +0 -162
  155. data/spec/alexandria/ui/sidepane_spec.rb +0 -29
@@ -4,88 +4,92 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'spec_helper'
7
+ require "spec_helper"
8
8
 
9
9
  describe Alexandria::Library do
10
10
  let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
11
11
 
12
- describe '::EXT' do
13
- it 'has symbolic references to file extensions' do
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 '#valid_isbn?' do
21
- it 'returns a true value for valid isbns' do
22
- for x in ['014143984X', '0-345-43192-8']
23
- expect(Alexandria::Library.valid_isbn?(x)).to be_truthy
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 '#valid_ean?' do
29
- it 'returns a true value for valid EANs' do
30
- expect(Alexandria::Library.valid_ean?('9780345431929')).to be_truthy
31
- expect(Alexandria::Library.valid_ean?('978034543192912345')).to be_truthy
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(Alexandria::Library.valid_ean?('9784047041790')).to be_truthy
35
+ expect(described_class.valid_ean?("9784047041790")).to be_truthy
36
36
  end
37
37
 
38
- it 'returns a false value for invalid EANs' do
39
- expect(Alexandria::Library.valid_ean?('780345431929')).to be_falsey
40
- expect(Alexandria::Library.valid_ean?('97803454319290')).to be_falsey
41
- expect(Alexandria::Library.valid_ean?('97803454319291234')).to be_falsey
42
- expect(Alexandria::Library.valid_ean?('9780345431929123456')).to be_falsey
43
- expect(Alexandria::Library.valid_ean?('9780345431928')).to be_falsey
44
- expect(Alexandria::Library.valid_ean?('9780345431929A')).to be_falsey
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(Alexandria::Library.valid_ean?('9784047041791')).to be_falsey
46
+ expect(described_class.valid_ean?("9784047041791")).to be_falsey
47
47
  end
48
48
  end
49
49
 
50
- describe '#valid_upc?' do
51
- it 'returns a true value for valid UPCs' do
52
- expect(Alexandria::Library.valid_upc?('97803454319312356')).to be_truthy
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 'returns a false value for invalid UPCs' do
56
- expect(Alexandria::Library.valid_upc?('978034543193123567')).to be_falsey
57
- expect(Alexandria::Library.valid_upc?('9780345431931235')).to be_falsey
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(Alexandria::Library.valid_upc?('97803454319412356')).to be_falsey
60
- expect(Alexandria::Library.valid_upc?('97803454319212356')).to be_falsey
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 '#canonicalise_isbn' do
65
- it 'returns the correct value for several examples' do
66
- expect(Alexandria::Library.canonicalise_isbn('014143984X')).to eq '014143984X'
67
- expect(Alexandria::Library.canonicalise_isbn('0-345-43192-8')).to eq '0345431928'
68
- expect(Alexandria::Library.canonicalise_isbn('3522105907')).to eq '3522105907'
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(Alexandria::Library.canonicalise_isbn('9780345431929')).to eq '0345431928'
70
+ expect(described_class.canonicalise_isbn("9780345431929")).to eq "0345431928"
71
71
  end
72
72
  end
73
73
 
74
- context 'with an empty library' do
75
- let(:my_library) { loader.load_library('Empty') }
74
+ context "with an empty library" do
75
+ let(:my_library) { loader.load_library("Empty") }
76
76
 
77
- before(:each) do
77
+ before do
78
78
  FileUtils.mkdir(TESTDIR) unless File.exist? TESTDIR
79
79
  end
80
80
 
81
- it 'disallows multiple deletion of the same copy of a book' do
81
+ after do
82
+ FileUtils.rm_rf(TESTDIR)
83
+ end
84
+
85
+ it "disallows multiple deletion of the same copy of a book" do
82
86
  first_copy = an_artist_of_the_floating_world
83
87
  my_library << first_copy
84
88
  my_library.delete(first_copy)
85
89
  expect { my_library.delete(first_copy) }.to raise_error ArgumentError
86
90
  end
87
91
 
88
- it 'allows multiple copies of a book to be added and deleted in turn' do
92
+ it "allows multiple copies of a book to be added and deleted in turn" do
89
93
  first_copy = an_artist_of_the_floating_world
90
94
  my_library << first_copy
91
95
  my_library.delete(first_copy)
@@ -97,16 +101,12 @@ describe Alexandria::Library do
97
101
 
98
102
  expect { my_library.delete(second_copy) }.not_to raise_error
99
103
  end
100
-
101
- after(:each) do
102
- FileUtils.rm_rf(TESTDIR)
103
- end
104
104
  end
105
105
 
106
- describe '.import_as_isbn_list' do
106
+ describe ".import_as_isbn_list" do
107
107
  def __test_fake_import_isbns
108
108
  libraries = Alexandria::LibraryCollection.instance
109
- library = Alexandria::Library.new('Test Library')
109
+ library = Alexandria::Library.new("Test Library")
110
110
  libraries.add_library(library)
111
111
  [library, libraries]
112
112
  end
@@ -117,59 +117,63 @@ describe Alexandria::Library do
117
117
  on_iterate_cb = proc {}
118
118
  on_error_cb = proc {}
119
119
  library, _libraries = __test_fake_import_isbns
120
- test_file = 'data/isbns.txt'
121
- library.import_as_isbn_list('Test Library', test_file, on_iterate_cb, on_error_cb)
120
+ test_file = "data/isbns.txt"
121
+ library.import_as_isbn_list("Test Library", test_file, on_iterate_cb, on_error_cb)
122
122
  end
123
123
  end
124
124
 
125
- context 'imported from 0.6.1 data files' do
126
- before(:each) do
127
- lib_version = File.join(LIBDIR, '0.6.1')
125
+ context "when importing from 0.6.1 data files" do
126
+ before do
127
+ lib_version = File.join(LIBDIR, "0.6.1")
128
128
  FileUtils.cp_r(lib_version, TESTDIR)
129
129
  end
130
130
 
131
- it 'imports cleanly from version 0.6.1 data format' do
131
+ after do
132
+ FileUtils.rm_rf(TESTDIR)
133
+ end
134
+
135
+ it "imports cleanly from version 0.6.1 data format" do
132
136
  libs = loader.load_all_libraries
133
137
  expect(libs.size).to eq(1)
134
138
  my_library = libs[0]
135
139
  expect(my_library.size).to eq(3)
136
140
  # Malory
137
- malory_book = my_library.select { |b| b.isbn == '9780192812179' }[0]
138
- expect(malory_book.publisher).to eq('Oxford University Press')
139
- expect(malory_book.authors.include?('Vinaver')).to be_truthy
141
+ malory_book = my_library.select { |b| b.isbn == "9780192812179" }[0]
142
+ expect(malory_book.publisher).to eq("Oxford University Press")
143
+ expect(malory_book.authors.include?("Vinaver")).to be_truthy
140
144
  expect(malory_book.version).to eq(Alexandria::DATA_VERSION)
141
145
 
142
146
  # Guide to LaTeX
143
- latex_book = my_library.select { |b| b.title.include? 'Latex' }[0]
144
- expect(latex_book.isbn).to eq('9780201398250')
145
- expect(latex_book.publisher).to eq('Addison Wesley') # note, no Ruby-Amazon cruft
146
- end
147
-
148
- after(:each) do
149
- FileUtils.rm_rf(TESTDIR)
147
+ latex_book = my_library.select { |b| b.title.include? "Latex" }[0]
148
+ expect(latex_book.isbn).to eq("9780201398250")
149
+ expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
150
150
  end
151
151
  end
152
152
 
153
- context 'imported from 0.6.1 with books without an ISBN' do
154
- before(:each) do
155
- lib_version = File.join(LIBDIR, '0.6.1-noisbn')
153
+ context "when importing from 0.6.1 with books without an ISBN" do
154
+ before do
155
+ lib_version = File.join(LIBDIR, "0.6.1-noisbn")
156
156
  FileUtils.cp_r(lib_version, TESTDIR)
157
157
  end
158
158
 
159
- it 'allows books to have no ISBN' do
159
+ after do
160
+ FileUtils.rm_rf(TESTDIR)
161
+ end
162
+
163
+ it "allows books to have no ISBN" do
160
164
  libs = loader.load_all_libraries
161
165
  expect(libs.size).to eq(1)
162
166
  my_library = libs[0]
163
167
  expect(my_library.size).to eq(2)
164
168
 
165
169
  # Guide to LaTeX
166
- latex_book = my_library.select { |b| b.title.include? 'Latex' }[0]
167
- expect(latex_book.isbn).to eq('9780201398250')
168
- expect(latex_book.publisher).to eq('Addison Wesley') # note, no Ruby-Amazon cruft
170
+ latex_book = my_library.select { |b| b.title.include? "Latex" }[0]
171
+ expect(latex_book.isbn).to eq("9780201398250")
172
+ expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
169
173
  expect(latex_book.version).to eq(Alexandria::DATA_VERSION)
170
174
 
171
175
  # Lex and Yacc
172
- lex_and_yacc_book = my_library.select { |b| b.title.include? 'Lex' }[0]
176
+ lex_and_yacc_book = my_library.select { |b| b.title.include? "Lex" }[0]
173
177
  expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
174
178
 
175
179
  my_library.each do |book|
@@ -181,41 +185,37 @@ describe Alexandria::Library do
181
185
 
182
186
  expect(my_library_reloaded.size).to eq(2)
183
187
 
184
- latex_book = my_library_reloaded.select { |b| b.title.include? 'Latex' }[0]
188
+ latex_book = my_library_reloaded.select { |b| b.title.include? "Latex" }[0]
185
189
  expect(latex_book).not_to be_nil
186
- expect(latex_book.publisher).to eq('Addison Wesley')
190
+ expect(latex_book.publisher).to eq("Addison Wesley")
187
191
 
188
- lex_and_yacc_book = my_library_reloaded.select { |b| b.title.include? 'Lex' }[0]
192
+ lex_and_yacc_book = my_library_reloaded.select { |b| b.title.include? "Lex" }[0]
189
193
  expect(lex_and_yacc_book).not_to be_nil
190
194
  expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
191
195
  end
192
-
193
- after(:each) do
194
- FileUtils.rm_rf(TESTDIR)
195
- end
196
196
  end
197
197
 
198
- describe '.move' do
199
- before(:each) do
200
- lib_version = File.join(LIBDIR, '0.6.2')
198
+ describe ".move" do
199
+ before do
200
+ lib_version = File.join(LIBDIR, "0.6.2")
201
201
  FileUtils.cp_r(lib_version, TESTDIR)
202
202
  end
203
203
 
204
- it 'moves the given book from source to target' do
205
- source = loader.load_library('My Library')
204
+ it "moves the given book from source to target" do
205
+ source = loader.load_library("My Library")
206
206
  count = source.count
207
207
  book = source.first
208
- target = loader.load_library('Target')
208
+ target = loader.load_library("Target")
209
209
 
210
210
  described_class.move(source, target, source.first)
211
211
 
212
212
  aggregate_failures do
213
213
  expect(source.count).to eq count - 1
214
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
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
219
219
  end
220
220
  end
221
221
  end
@@ -4,27 +4,27 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'spec_helper'
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 '#load_all_smart_libraries' do
13
- context 'when none exist' do
14
- it 'creates and saves some' do
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? lib.yaml).to be_truthy
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 'when one exists' do
26
- it 'returns the existing smart library' do
27
- existing = Alexandria::SmartLibrary.new('Hi', [], :all, loader)
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,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2007 Joseph Method
3
+ # This file is part of Alexandria.
4
4
  #
5
- # Alexandria is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License as
7
- # published by the Free Software Foundation; either version 2 of the
8
- # License, or (at your option) any later version.
9
- #
10
- # Alexandria is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public
16
- # License along with Alexandria; see the file COPYING. If not,
17
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
19
6
 
20
- require File.dirname(__FILE__) + '/../spec_helper'
7
+ require File.dirname(__FILE__) + "/../spec_helper"
21
8
 
22
9
  describe Alexandria::Preferences do
23
- it 'should work'
10
+ let(:instance) { described_class.instance }
11
+
12
+ it "returns nil fetching unknown setting" do
13
+ expect(instance.does_not_exist).to eq nil
14
+ end
15
+
16
+ it "allows setting known setting to false" do
17
+ instance.toolbar_visible = false
18
+ expect(instance.toolbar_visible).to eq false
19
+ end
20
+
21
+ it "resets known setting by setting to nil" do
22
+ instance.toolbar_visible = nil
23
+ expect(instance.toolbar_visible).to eq true
24
+ end
24
25
  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 File.dirname(__FILE__) + "/../../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
@@ -4,36 +4,36 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'spec_helper'
7
+ require "spec_helper"
8
8
 
9
9
  RSpec.describe Alexandria::SmartLibrary do
10
- it 'can be instantiated simply' do
11
- lib = described_class.new('Hello', [], :all)
12
- expect(lib.name).to eq 'Hello'
10
+ it "can be instantiated simply" do
11
+ lib = described_class.new("Hello", [], :all)
12
+ expect(lib.name).to eq "Hello"
13
13
  end
14
14
 
15
- describe '#name' do
16
- it 'normalizes the encoding' do
17
- bad_name = (+'Prêts').force_encoding('ascii')
15
+ describe "#name" do
16
+ it "normalizes the encoding" do
17
+ bad_name = (+"Prêts").force_encoding("ascii")
18
18
  lib = described_class.new(bad_name, [], :all)
19
- expect(lib.name.encoding.name).to eq 'UTF-8'
20
- expect(bad_name.encoding.name).to eq 'US-ASCII'
19
+ expect(lib.name.encoding.name).to eq "UTF-8"
20
+ expect(bad_name.encoding.name).to eq "US-ASCII"
21
21
  end
22
22
  end
23
23
 
24
- describe '#update' do
25
- let(:lib) { described_class.new('Hello', [], :all) }
24
+ describe "#update" do
25
+ let(:lib) { described_class.new("Hello", [], :all) }
26
26
 
27
- it 'works when given no parameters' do
27
+ it "works when given no parameters" do
28
28
  lib.update
29
29
  end
30
30
 
31
- it 'works when given a LibraryCollection' do
31
+ it "works when given a LibraryCollection" do
32
32
  lib.update Alexandria::LibraryCollection.instance
33
33
  end
34
34
 
35
- it 'works when given a Library' do
36
- lib.update Alexandria::Library.new('Hi')
35
+ it "works when given a Library" do
36
+ lib.update Alexandria::Library.new("Hi")
37
37
  end
38
38
  end
39
39
  end