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
@@ -203,7 +203,7 @@
203
203
  <long>Whether the publisher column should be visible in the list view.</long>
204
204
  </locale>
205
205
  </schema>
206
- <schema>
206
+ <schema>
207
207
  <key>/schemas/apps/alexandria/col_publish_date_visible</key>
208
208
  <applyto>/apps/alexandria/col_publish_date_visible</applyto>
209
209
  <owner>alexandria</owner>
@@ -214,6 +214,17 @@
214
214
  <long>Whether the publish date column should be visible in the list view.</long>
215
215
  </locale>
216
216
  </schema>
217
+ <schema>
218
+ <key>/schemas/apps/alexandria/col_loaned_to_visible</key>
219
+ <applyto>/apps/alexandria/col_loaned_to_visible</applyto>
220
+ <owner>alexandria</owner>
221
+ <type>bool</type>
222
+ <default>true</default>
223
+ <locale name="C">
224
+ <short>Loaned to visibility</short>
225
+ <long>Whether the loaned to column should be visible in the list view.</long>
226
+ </locale>
227
+ </schema>
217
228
  <schema>
218
229
  <key>/schemas/apps/alexandria/col_rating_visible</key>
219
230
  <applyto>/apps/alexandria/col_rating_visible</applyto>
@@ -247,7 +258,7 @@
247
258
  <long>Whether the own column should be visible in the list view.</long>
248
259
  </locale>
249
260
  </schema>
250
- <schema>
261
+ <schema>
251
262
  <key>/schemas/apps/alexandria/col_want_visible</key>
252
263
  <applyto>/apps/alexandria/col_want_visible</applyto>
253
264
  <owner>alexandria</owner>
@@ -258,6 +269,17 @@
258
269
  <long>Whether the want column should be visible in the list view.</long>
259
270
  </locale>
260
271
  </schema>
272
+ <schema>
273
+ <key>/schemas/apps/alexandria/col_tags_visible</key>
274
+ <applyto>/apps/alexandria/col_tags_visible</applyto>
275
+ <owner>alexandria</owner>
276
+ <type>bool</type>
277
+ <default>true</default>
278
+ <locale name="C">
279
+ <short>Tags column visibility</short>
280
+ <long>Whether the tags column should be visible in the list view.</long>
281
+ </locale>
282
+ </schema>
261
283
  <schema>
262
284
  <key>/schemas/apps/alexandria/cols_width</key>
263
285
  <applyto>/apps/alexandria/cols_width</applyto>
@@ -1,37 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2005-2006 Laurent Sansonetti
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
- # This file is part of Alexandria, a GNOME book collection manager.
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 'spec_helper'
7
+ require "spec_helper"
25
8
 
26
9
  describe Alexandria::BookProviders do
27
- it 'should be less clever'
10
+ it "should be less clever"
28
11
 
29
12
  def assert_correct_search_result(provider, query,
30
13
  search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
31
14
  begin
32
15
  results = provider.instance.search(query, search_type)
33
16
  rescue SocketError
34
- skip 'Service is offline'
17
+ skip "Service is offline"
35
18
  end
36
19
 
37
20
  puts results.inspect if $DEBUG
@@ -48,139 +31,139 @@ describe Alexandria::BookProviders do
48
31
 
49
32
  canonical_query = Alexandria::Library.canonicalise_ean(query)
50
33
  canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
51
- expect(canonical_query).
52
- to eq(canonical_result),
53
- "Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
34
+ expect(canonical_query)
35
+ .to eq(canonical_result),
36
+ "Result's isbn #{book.isbn} is not equivalent to the requested isbn #{query} for #{provider}"
54
37
 
55
38
  if results.length == 2
56
39
  cover_url = results.last
57
40
  if cover_url
58
- expect(cover_url).
59
- to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
41
+ expect(cover_url)
42
+ .to be_instance_of(String), "Unexpected cover_url #{cover_url.inspect} for #{provider}"
60
43
  end
61
44
  end
62
45
  else
63
- expect(results.first.first).
64
- to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
46
+ expect(results.first.first)
47
+ .to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
65
48
  end
66
49
  results
67
50
  end
68
51
 
69
- it 'should not piss off Rich Burridge' do
70
- skip 'Amazon requires an API key. Remove it altogether as a provider?'
52
+ it "does not piss off Rich Burridge" do
53
+ skip "Amazon requires an API key. Remove it altogether as a provider?"
71
54
  assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
72
- '033025068X')
55
+ "033025068X")
73
56
  end
74
57
 
75
- it 'amazon should work' do
76
- skip 'Amazon requires an API key. Remove it altogether as a provider?'
58
+ it "amazon should work" do
59
+ skip "Amazon requires an API key. Remove it altogether as a provider?"
77
60
  assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
78
- '9780385504201')
61
+ "9780385504201")
79
62
  end
80
63
 
81
- it 'amazon title should work' do
82
- skip 'Amazon requires an API key. Remove it altogether as a provider?'
64
+ it "amazon title should work" do
65
+ skip "Amazon requires an API key. Remove it altogether as a provider?"
83
66
  assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
84
- 'A Confederacy of Dunces', Alexandria::BookProviders::SEARCH_BY_TITLE)
67
+ "A Confederacy of Dunces", Alexandria::BookProviders::SEARCH_BY_TITLE)
85
68
  end
86
69
 
87
- it 'amazon authors should work' do
88
- skip 'Amazon requires an API key. Remove it altogether as a provider?'
70
+ it "amazon authors should work" do
71
+ skip "Amazon requires an API key. Remove it altogether as a provider?"
89
72
  assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
90
- 'John Kennedy Toole', Alexandria::BookProviders::SEARCH_BY_AUTHORS)
73
+ "John Kennedy Toole", Alexandria::BookProviders::SEARCH_BY_AUTHORS)
91
74
  end
92
75
 
93
- it 'amazon keyword should work' do
94
- skip 'Amazon requires an API key. Remove it altogether as a provider?'
76
+ it "amazon keyword should work" do
77
+ skip "Amazon requires an API key. Remove it altogether as a provider?"
95
78
  assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
96
- 'Confederacy Dunces', Alexandria::BookProviders::SEARCH_BY_KEYWORD)
79
+ "Confederacy Dunces", Alexandria::BookProviders::SEARCH_BY_KEYWORD)
97
80
  end
98
81
 
99
- it 'LOC should work' do
82
+ it "LOC should work" do
100
83
  assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
101
- '9780805335583')
84
+ "9780805335583")
102
85
  # this book has non-ASCII letters
103
86
  assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
104
- '9782070379248')
87
+ "9782070379248")
105
88
  end
106
89
 
107
- it 'BL should work' do
108
- skip 'Not working: connect failed'
90
+ it "BL should work" do
91
+ skip "Not working: connect failed"
109
92
  assert_correct_search_result(Alexandria::BookProviders::BLProvider,
110
- '9781853260803')
93
+ "9781853260803")
111
94
  end
112
95
 
113
- it 'SBN should work' do
96
+ it "SBN should work" do
114
97
  assert_correct_search_result(Alexandria::BookProviders::SBNProvider,
115
- '9788835926436')
98
+ "9788835926436")
116
99
  end
117
100
 
118
- it 'Barnes and Noble should work' do
119
- skip 'Barnes and Noble is not operational at the moment'
101
+ it "Barnes and Noble should work" do
102
+ skip "Barnes and Noble is not operational at the moment"
120
103
  assert_correct_search_result(Alexandria::BookProviders::BarnesAndNobleProvider,
121
- '9780961328917') # see #1433
104
+ "9780961328917") # see #1433
122
105
  end
123
106
 
124
- it 'Proxis should work' do
125
- skip 'Needs fixing'
107
+ it "Proxis should work" do
108
+ skip "Needs fixing"
126
109
  assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
127
- '9789026965746')
110
+ "9789026965746")
128
111
  assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
129
- '9780586071403')
112
+ "9780586071403")
130
113
  end
131
114
 
132
- it 'Thalia should work' do
133
- skip 'Needs fixing'
115
+ it "Thalia should work" do
116
+ skip "Needs fixing"
134
117
  # german book
135
118
  assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
136
- '9783896673305')
119
+ "9783896673305")
137
120
  # international book
138
121
  assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
139
- '9780440241904')
122
+ "9780440241904")
140
123
  # movie dvd
141
124
  assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
142
- '4010232037824')
125
+ "4010232037824")
143
126
  # music cd
144
127
  assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
145
- '0094638203520')
128
+ "0094638203520")
146
129
  end
147
130
 
148
- it 'AdLibris should work' do
149
- skip 'Needs fixing: site has changed'
131
+ it "AdLibris should work" do
132
+ skip "Needs fixing: site has changed"
150
133
  assert_correct_search_result(Alexandria::BookProviders::AdLibrisProvider,
151
- '9789100109332')
134
+ "9789100109332")
152
135
  end
153
136
 
154
- it 'Siciliano should work' do
155
- skip 'Needs fixing: no results found'
137
+ it "Siciliano should work" do
138
+ skip "Needs fixing: no results found"
156
139
  assert_correct_search_result(Alexandria::BookProviders::SicilianoProvider,
157
- '9788599170380')
140
+ "9788599170380")
158
141
  end
159
142
 
160
- it 'Renaud should work' do
161
- skip 'Marked in code as not working; remove implementation entirely.'
143
+ it "Renaud should work" do
144
+ skip "Marked in code as not working; remove implementation entirely."
162
145
  # adultes
163
146
  assert_correct_search_result(Alexandria::BookProviders::RENAUDProvider,
164
- '9782894723388')
147
+ "9782894723388")
165
148
  # jeunesse
166
149
  assert_correct_search_result(Alexandria::BookProviders::RENAUDProvider,
167
- '9782764605059')
150
+ "9782764605059")
168
151
  end
169
152
 
170
- it 'Worldcat should work' do
153
+ it "Worldcat should work" do
171
154
  assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
172
- '9780521247108')
155
+ "9780521247108")
173
156
  # this one is with <div class=vernacular lang="[^"]+">)
174
157
  assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
175
- '9785941454136')
158
+ "9785941454136")
176
159
  end
177
160
 
178
- it 'Worldcat should work with multiple authors' do
161
+ it "Worldcat should work with multiple authors" do
179
162
  results = assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
180
- '9785941454136')
163
+ "9785941454136")
181
164
  this_book = results.first
182
- expect(this_book.authors).to be_instance_of(Array), 'Not an array!'
165
+ expect(this_book.authors).to be_instance_of(Array), "Not an array!"
183
166
  # puts this_book.authors
184
- expect(this_book.authors.length).to eq(2), 'Wrong number of authors for this book!'
167
+ expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!"
185
168
  end
186
169
  end
@@ -18,41 +18,43 @@
18
18
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
19
  # Fifth Floor, Boston, MA 02110-1301 USA.
20
20
 
21
- require 'spec_helper'
21
+ require "spec_helper"
22
22
 
23
23
  describe Alexandria::Book do
24
- it 'should be a thing' do
24
+ it "is a thing" do
25
25
  an_artist_of_the_floating_world
26
26
  end
27
27
 
28
- it 'should establish equality only with books with the same identity' do
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 = '9780571147999'
33
+ different_book.isbn = "9780571147999"
34
34
  expect(different_book).not_to eq book
35
35
  end
36
36
 
37
- describe '#rating' do
37
+ describe "#rating" do
38
38
  let(:book) { an_artist_of_the_floating_world }
39
- it 'returns 0 by default' do
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 '#rating=' do
45
+ describe "#rating=" do
45
46
  let(:book) { an_artist_of_the_floating_world }
46
- it 'assigns rating' do
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 'does not allow higher rating than 5 to be assigned' do
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 'does not allow lower rating than 0 to be assigned' do
57
+ it "does not allow lower rating than 0 to be assigned" do
56
58
  expect { book.rating = -1 }.to raise_error ArgumentError
57
59
  end
58
60
  end
@@ -4,19 +4,23 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'spec_helper'
7
+ require "spec_helper"
8
8
 
9
9
  RSpec.describe Alexandria do
10
- let(:lib_version) { File.join(LIBDIR, '0.6.2') }
10
+ let(:lib_version) { File.join(LIBDIR, "0.6.2") }
11
11
 
12
12
  before do
13
13
  FileUtils.rm_rf(TESTDIR)
14
14
  FileUtils.cp_r(lib_version, TESTDIR)
15
15
  end
16
16
 
17
- 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
17
+ after do
18
+ FileUtils.rm_rf(TESTDIR)
19
+ end
20
+
21
+ describe ".list_books_on_console" do
22
+ it "returns a string containing a list of all books" do
23
+ expect(described_class.list_books_on_console).to eq <<~LIST
20
24
  The Dispossessed, Ursula Le Guin
21
25
  Pattern Recognition, William Gibson
22
26
  Bonjour Tristesse, Francoise Sagan & Irene Ash
@@ -25,8 +29,4 @@ RSpec.describe Alexandria do
25
29
  LIST
26
30
  end
27
31
  end
28
-
29
- after do
30
- FileUtils.rm_rf(TESTDIR)
31
- end
32
32
  end
@@ -4,66 +4,71 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'spec_helper'
7
+ require "spec_helper"
8
8
 
9
9
  RSpec.describe Alexandria::ExportLibrary do
10
- let(:lib_version) { File.join(LIBDIR, '0.6.2') }
10
+ let(:lib_version) { File.join(LIBDIR, "0.6.2") }
11
11
 
12
12
  let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
13
13
 
14
14
  let(:format) { Alexandria::ExportFormat.all.find { |it| it.message == message } }
15
- let(:outfile_base) { format.ext ? "my-library.#{format.ext}" : 'my-library' }
15
+ let(:outfile_base) { format.ext ? "my-library.#{format.ext}" : "my-library" }
16
16
  let(:outfile) { File.join(Dir.tmpdir, outfile_base) }
17
17
 
18
18
  let(:unsorted) { Alexandria::LibrarySortOrder::Unsorted.new }
19
19
 
20
20
  before do
21
21
  FileUtils.cp_r(lib_version, TESTDIR)
22
- @my_library = loader.load_library('My Library')
22
+ @my_library = loader.load_library("My Library")
23
23
  expect(@my_library.size).to eq 5
24
24
  end
25
25
 
26
- describe '#export_as_csv_list' do
26
+ after do
27
+ FileUtils.rm_rf(TESTDIR)
28
+ FileUtils.rm_rf(outfile) if File.exist? outfile
29
+ end
30
+
31
+ describe "#export_as_csv_list" do
27
32
  let(:message) { :export_as_csv_list }
28
33
 
29
34
  def load_rows_from_csv
30
- CSV.read(outfile, col_sep: ';')
35
+ CSV.read(outfile, col_sep: ";")
31
36
  end
32
37
 
33
- it 'can sort by title' do
38
+ it "can sort by title" do
34
39
  sort_by_title = Alexandria::LibrarySortOrder.new(:title)
35
40
  format.invoke(@my_library, sort_by_title, outfile)
36
41
  expect(File.exist?(outfile)).to be_truthy
37
42
  rows = load_rows_from_csv
38
43
  rows.shift
39
44
  expect(rows.size).to eq(@my_library.size)
40
- TITLE = 0
45
+ title_index = 0
41
46
  comparisons = rows.size - 1
42
47
  comparisons.times do |index|
43
- expect(rows[index][TITLE]).to be <= rows[index + 1][TITLE]
48
+ expect(rows[index][title_index]).to be <= rows[index + 1][title_index]
44
49
  end
45
50
  end
46
51
 
47
- it 'can sort in descending order' do
52
+ it "can sort in descending order" do
48
53
  sort_by_date_desc = Alexandria::LibrarySortOrder.new(:publishing_year, false)
49
54
  format.invoke(@my_library, sort_by_date_desc, outfile)
50
55
  expect(File.exist?(outfile)).to be_truthy
51
56
  rows = load_rows_from_csv
52
57
  rows.shift
53
58
  expect(rows.size).to eq(@my_library.size)
54
- DATE = 5
59
+ date_index = 5
55
60
  comparisons = rows.size - 1
56
61
  comparisons.times do |index|
57
- expect(rows[index][DATE]).to be >= rows[index + 1][DATE]
62
+ expect(rows[index][date_index]).to be >= rows[index + 1][date_index]
58
63
  end
59
64
  end
60
65
  end
61
66
 
62
- describe '#export_as_html' do
67
+ describe "#export_as_html" do
63
68
  let(:message) { :export_as_html }
64
- let(:index) { File.join(outfile, 'index.html') }
69
+ let(:index) { File.join(outfile, "index.html") }
65
70
 
66
- it 'can export unsorted' do
71
+ it "can export unsorted" do
67
72
  format.invoke(@my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
68
73
  aggregate_failures do
69
74
  expect(File.exist?(outfile)).to be_truthy
@@ -73,10 +78,10 @@ RSpec.describe Alexandria::ExportLibrary do
73
78
  end
74
79
  end
75
80
 
76
- describe '#export_as_onix_xml_archive' do
81
+ describe "#export_as_onix_xml_archive" do
77
82
  let(:message) { :export_as_onix_xml_archive }
78
83
 
79
- it 'can export unsorted' do
84
+ it "can export unsorted" do
80
85
  format.invoke(@my_library, unsorted, outfile)
81
86
  aggregate_failures do
82
87
  expect(File.exist?(outfile)).to be_truthy
@@ -85,10 +90,10 @@ RSpec.describe Alexandria::ExportLibrary do
85
90
  end
86
91
  end
87
92
 
88
- describe '#export_as_tellico_xml_archive' do
93
+ describe "#export_as_tellico_xml_archive" do
89
94
  let(:message) { :export_as_tellico_xml_archive }
90
95
 
91
- it 'can export unsorted' do
96
+ it "can export unsorted" do
92
97
  format.invoke(@my_library, unsorted, outfile)
93
98
  aggregate_failures do
94
99
  expect(File.exist?(outfile)).to be_truthy
@@ -97,10 +102,10 @@ RSpec.describe Alexandria::ExportLibrary do
97
102
  end
98
103
  end
99
104
 
100
- describe '#export_as_bibtex' do
105
+ describe "#export_as_bibtex" do
101
106
  let(:message) { :export_as_bibtex }
102
107
 
103
- it 'can export unsorted' do
108
+ it "can export unsorted" do
104
109
  format.invoke(@my_library, unsorted, outfile)
105
110
  aggregate_failures do
106
111
  expect(File.exist?(outfile)).to be_truthy
@@ -109,10 +114,10 @@ RSpec.describe Alexandria::ExportLibrary do
109
114
  end
110
115
  end
111
116
 
112
- describe '#export_as_isbn_list' do
117
+ describe "#export_as_isbn_list" do
113
118
  let(:message) { :export_as_isbn_list }
114
119
 
115
- it 'can export unsorted' do
120
+ it "can export unsorted" do
116
121
  format.invoke(@my_library, unsorted, outfile)
117
122
  aggregate_failures do
118
123
  expect(File.exist?(outfile)).to be_truthy
@@ -121,11 +126,11 @@ RSpec.describe Alexandria::ExportLibrary do
121
126
  end
122
127
  end
123
128
 
124
- describe '#export_as_ipod_notes' do
129
+ describe "#export_as_ipod_notes" do
125
130
  let(:message) { :export_as_ipod_notes }
126
- let(:index) { File.join(outfile, 'index.linx') }
131
+ let(:index) { File.join(outfile, "index.linx") }
127
132
 
128
- it 'can export unsorted' do
133
+ it "can export unsorted" do
129
134
  format.invoke(@my_library, unsorted, outfile, nil)
130
135
  aggregate_failures do
131
136
  expect(File.exist?(outfile)).to be_truthy
@@ -133,9 +138,4 @@ RSpec.describe Alexandria::ExportLibrary do
133
138
  end
134
139
  end
135
140
  end
136
-
137
- after(:each) do
138
- FileUtils.rm_rf(TESTDIR)
139
- FileUtils.rm_rf(outfile) if File.exist? outfile
140
- end
141
141
  end