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