alexandria-book-collection-manager 0.7.5 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/ruby.yml +72 -0
  4. data/.gitignore +4 -1
  5. data/.rubocop.yml +65 -30
  6. data/.rubocop_todo.yml +49 -165
  7. data/.simplecov +5 -2
  8. data/CHANGELOG.md +64 -0
  9. data/ChangeLog.0 +19 -19
  10. data/INSTALL.md +26 -16
  11. data/README.md +31 -35
  12. data/Rakefile +18 -16
  13. data/alexandria-book-collection-manager.gemspec +35 -29
  14. data/doc/FAQ +2 -2
  15. data/doc/dependency_decisions.yml +22 -3
  16. data/lib/alexandria/about.rb +1 -1
  17. data/lib/alexandria/book_providers/bl_provider.rb +88 -0
  18. data/lib/alexandria/book_providers/douban.rb +2 -2
  19. data/lib/alexandria/book_providers/loc_provider.rb +38 -0
  20. data/lib/alexandria/book_providers/pseudomarc.rb +61 -71
  21. data/lib/alexandria/book_providers/sbn_provider.rb +108 -0
  22. data/lib/alexandria/book_providers/{thalia.rb → thalia_provider.rb} +37 -74
  23. data/lib/alexandria/book_providers/web.rb +2 -2
  24. data/lib/alexandria/book_providers/worldcat.rb +34 -38
  25. data/lib/alexandria/book_providers/z3950_provider.rb +199 -0
  26. data/lib/alexandria/book_providers.rb +48 -65
  27. data/lib/alexandria/default_preferences.rb +2 -1
  28. data/lib/alexandria/execution_queue.rb +13 -12
  29. data/lib/alexandria/export_library.rb +21 -22
  30. data/lib/alexandria/image_fetcher.rb +25 -0
  31. data/lib/alexandria/import_library.rb +46 -70
  32. data/lib/alexandria/import_library_csv.rb +16 -16
  33. data/lib/alexandria/library_sort_order.rb +3 -1
  34. data/lib/alexandria/library_store.rb +19 -20
  35. data/lib/alexandria/logging.rb +5 -9
  36. data/lib/alexandria/models/book.rb +15 -2
  37. data/lib/alexandria/models/library.rb +31 -35
  38. data/lib/alexandria/net.rb +1 -2
  39. data/lib/alexandria/preferences.rb +27 -33
  40. data/lib/alexandria/scanners/cue_cat.rb +6 -6
  41. data/lib/alexandria/scanners/keyboard.rb +1 -1
  42. data/lib/alexandria/scanners.rb +2 -2
  43. data/lib/alexandria/smart_library.rb +22 -26
  44. data/lib/alexandria/ui/about_dialog.rb +1 -1
  45. data/lib/alexandria/ui/acquire_dialog.rb +15 -19
  46. data/lib/alexandria/ui/alert_dialog.rb +36 -19
  47. data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
  48. data/lib/alexandria/ui/barcode_animation.rb +6 -6
  49. data/lib/alexandria/ui/book_properties_dialog.rb +2 -3
  50. data/lib/alexandria/ui/book_properties_dialog_base.rb +35 -137
  51. data/lib/alexandria/ui/calendar_popup.rb +58 -0
  52. data/lib/alexandria/ui/callbacks.rb +144 -123
  53. data/lib/alexandria/ui/completion_models.rb +2 -6
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +2 -2
  56. data/lib/alexandria/ui/error_dialog.rb +1 -1
  57. data/lib/alexandria/ui/export_dialog.rb +19 -18
  58. data/lib/alexandria/ui/icons.rb +34 -40
  59. data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
  60. data/lib/alexandria/ui/import_dialog.rb +49 -48
  61. data/lib/alexandria/ui/init.rb +14 -12
  62. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
  63. data/lib/alexandria/ui/libraries_combo.rb +10 -9
  64. data/lib/alexandria/ui/listview.rb +6 -7
  65. data/lib/alexandria/ui/main_app.rb +2 -2
  66. data/lib/alexandria/ui/multi_drag_treeview.rb +5 -7
  67. data/lib/alexandria/ui/new_book_dialog.rb +63 -65
  68. data/lib/alexandria/ui/new_book_dialog_manual.rb +1 -1
  69. data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
  70. data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
  71. data/lib/alexandria/ui/preferences_dialog.rb +25 -84
  72. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +10 -6
  73. data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
  74. data/lib/alexandria/ui/really_delete_dialog.rb +2 -2
  75. data/lib/alexandria/ui/sidepane_manager.rb +38 -38
  76. data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
  77. data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
  78. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +61 -244
  79. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  80. data/lib/alexandria/ui/sound.rb +4 -6
  81. data/lib/alexandria/ui/ui_manager.rb +80 -83
  82. data/lib/alexandria/ui.rb +7 -7
  83. data/lib/alexandria/version.rb +2 -2
  84. data/lib/alexandria/web_themes.rb +15 -15
  85. data/lib/alexandria.rb +2 -2
  86. data/po/cs.po +947 -865
  87. data/po/cy.po +913 -864
  88. data/po/de.po +961 -865
  89. data/po/el.po +956 -861
  90. data/po/es.po +952 -857
  91. data/po/fr.po +950 -865
  92. data/po/ga.po +866 -819
  93. data/po/gl.po +946 -861
  94. data/po/it.po +945 -858
  95. data/po/ja.po +921 -836
  96. data/po/mk.po +953 -858
  97. data/po/nb.po +932 -847
  98. data/po/nl.po +955 -849
  99. data/po/pl.po +999 -963
  100. data/po/pt.po +946 -850
  101. data/po/pt_BR.po +944 -859
  102. data/po/ru.po +959 -868
  103. data/po/sk.po +950 -863
  104. data/po/sv.po +944 -859
  105. data/po/uk.po +925 -846
  106. data/po/zh_TW.po +926 -841
  107. data/schemas/alexandria.schemas +1 -1
  108. data/share/alexandria/glade/main_app__builder.glade +6 -21
  109. data/share/gnome/help/alexandria/C/adding-books.xml +3 -4
  110. data/share/gnome/help/alexandria/C/introduction.xml +0 -16
  111. data/share/gnome/help/alexandria/C/searching.xml +1 -4
  112. data/share/gnome/help/alexandria/C/settings.xml +0 -30
  113. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  114. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  115. data/share/gnome/help/alexandria/fr/alexandria.xml +5 -160
  116. data/share/gnome/help/alexandria/ja/adding-books.xml +1 -1
  117. data/share/gnome/help/alexandria/ja/introduction.xml +0 -15
  118. data/share/gnome/help/alexandria/ja/searching.xml +3 -7
  119. data/share/gnome/help/alexandria/ja/settings.xml +0 -27
  120. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  121. data/spec/alexandria/book_providers/bl_provider_spec.rb +13 -0
  122. data/spec/alexandria/book_providers/loc_provider_spec.rb +17 -0
  123. data/spec/alexandria/book_providers/sbn_provider_spec.rb +13 -0
  124. data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
  125. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  126. data/spec/alexandria/book_providers_spec.rb +0 -154
  127. data/spec/alexandria/console_spec.rb +0 -5
  128. data/spec/alexandria/export_library_spec.rb +27 -38
  129. data/spec/alexandria/library_spec.rb +76 -46
  130. data/spec/alexandria/preferences_spec.rb +29 -3
  131. data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
  132. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  133. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  134. data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
  135. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  136. data/spec/alexandria/ui/book_properties_dialog_spec.rb +47 -5
  137. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
  138. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  139. data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
  140. data/spec/alexandria/ui/export_dialog_spec.rb +25 -4
  141. data/spec/alexandria/ui/icons_spec.rb +26 -0
  142. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  143. data/spec/alexandria/ui/import_dialog_spec.rb +35 -3
  144. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  145. data/spec/alexandria/ui/main_app_spec.rb +1 -1
  146. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +39 -3
  147. data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
  148. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
  149. data/spec/alexandria/ui/preferences_dialog_spec.rb +2 -2
  150. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
  151. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  152. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  153. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
  154. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +37 -6
  155. data/spec/alexandria/ui/ui_manager_spec.rb +116 -2
  156. data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +2 -0
  157. data/spec/end_to_end/basic_run_spec.rb +3 -8
  158. data/spec/fixtures/cover.jpg +0 -0
  159. data/spec/spec_helper.rb +47 -3
  160. data/tasks/spec.rake +3 -5
  161. data/util/rake/fileinstall.rb +16 -15
  162. data/util/rake/omfgenerate.rb +1 -1
  163. metadata +141 -52
  164. data/.travis.yml +0 -39
  165. data/lib/alexandria/book_providers/adlibris.rb +0 -196
  166. data/lib/alexandria/book_providers/amazon_aws.rb +0 -252
  167. data/lib/alexandria/book_providers/amazon_ecs_util.rb +0 -388
  168. data/lib/alexandria/book_providers/barnes_and_noble.rb +0 -209
  169. data/lib/alexandria/book_providers/proxis.rb +0 -175
  170. data/lib/alexandria/book_providers/siciliano.rb +0 -257
  171. data/lib/alexandria/book_providers/z3950.rb +0 -415
  172. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  173. data/spec/alexandria/utilities_spec.rb +0 -52
@@ -0,0 +1,119 @@
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::BookProviders::ThaliaProvider do
10
+ let(:normal_people_main) do
11
+ +<<~HTML
12
+ <!DOCTYPE html>
13
+ <html lang="de" data-environment="prod">
14
+ <head>
15
+ <title>Artikel von 0571334652 ansehen | Thalia</title>
16
+ </head>
17
+ <body data-mandant="2" data-version="20201112100740_528b0df" data-environment="prod">
18
+ <main class="suche-grid--main nur-suchergebnis">
19
+ <section class="suchergebnis">
20
+ <ul class="suchergebnis-liste no-bullets">
21
+ <li class="suchergebnis" data-seite="1"
22
+ data-ean="9780571334650"
23
+ data-id="134292338"
24
+ data-preis="9.49"
25
+ data-preis-reduziert="false"
26
+ data-alterpreis="">
27
+ <a href="/shop/home/artikeldetails/ID134292338.html" class="layered-link">Normal People von Sally Rooney</a>
28
+
29
+ <ul class="weitere-formate no-bullets" impression="product-variant">
30
+ <li class="format aktiv">
31
+ <a href="/shop/home/artikeldetails/ID134292338.html">Buch (Taschenbuch)</a>
32
+ </li>
33
+ <li class="format">
34
+ <a href="/shop/home/artikeldetails/ID95227195.html">Weitere: Buch (Taschenbuch)</a>
35
+ </li>
36
+ </ul>
37
+ </li>
38
+ </ul>
39
+ </section>
40
+ </main>
41
+ </body>
42
+ </html>
43
+ HTML
44
+ end
45
+ let(:normal_people_details) do
46
+ +<<~HTML
47
+ <!DOCTYPE html>
48
+ <html class="no-js" id="ID-2" lang="de">
49
+ <head>
50
+ <title>Normal People von Sally Rooney - Taschenbuch - 978-0-571-33465-0 | Thalia</title>
51
+ </head>
52
+ <body>
53
+ <section class="artikel-medien imagesPreview">
54
+ <img src="https://assets.thalia.media/img/artikel/ae9934c90f2c7d595146807ea6253c99532043ec-00-00.jpeg" class='largeImg'>
55
+ </section>
56
+
57
+ <section class="artikel-infos" id="sbe-product-details"
58
+ data-shopid="2"
59
+ data-id="A1051452169"
60
+ data-id-alt="134292338"
61
+ data-titel="Normal People"
62
+ data-verfuegbarkeit="Sofort lieferbar"
63
+ data-preis-netto="9.02"
64
+ data-preis-brutto="9.49"
65
+ data-ean="9780571334650"
66
+ data-reduziert="false"
67
+ data-waehrung="EUR"
68
+ data-preis-liste="9.49"
69
+ data-hersteller="Faber &amp; Faber"
70
+ data-form="Taschenbuch"
71
+ data-verkaufsrang="5"
72
+ data-anzahlbewertungen="19"
73
+ data-durchschnittsbewertung="4.5"
74
+ data-preisbindung="false"
75
+ data-mandant="2"
76
+ data-environment="prod"
77
+ component="artikeldetails-produktdetails">
78
+
79
+ <h1 class="ncTitle">
80
+ Normal People
81
+ </h1>
82
+
83
+ <p class="aim-author">
84
+ <a href="https://www.thalia.de/shop/home/mehr-von-suche/ANY/sp/suche.html?mehrVon=Sally%20Rooney" interaction="autor-klick">Sally Rooney</a>
85
+ </p>
86
+ </section>
87
+
88
+ <section class="artikeldetails">
89
+ <table>
90
+ <tr> <th> Einband </th> <td> Taschenbuch </td> </tr>
91
+ <tr> <th> Erscheinungsdatum </th> <td> 02.05.2019 </td> </tr>
92
+ <tr> <th> ISBN </th> <td> 978-0-571-33465-0 </td> </tr>
93
+ </table>
94
+ <table>
95
+ <tr>
96
+ <th> Verlag </th>
97
+ <td>
98
+ <a href="https://www.thalia.de/shop/home/mehr-von-suche/ANY/sv/suche.html?mehrVon=Faber%20%26%20Faber" interaction="auswahl">
99
+ Faber &amp; Faber
100
+ </a>
101
+ </td>
102
+ </tr>
103
+ </table>
104
+ </section>
105
+ </body>
106
+ </html>
107
+ HTML
108
+ end
109
+
110
+ it "works when searching by ISBN" do
111
+ stub_request(:get,
112
+ "https://www.thalia.de/shop/bde_bu_hg_startseite/suche/?sq=0571334652")
113
+ .to_return(status: 200, body: normal_people_main, headers: {})
114
+ stub_request(:get, "https://www.thalia.de/shop/home/artikeldetails/ID134292338.html")
115
+ .to_return(status: 200, body: normal_people_details, headers: {})
116
+
117
+ assert_correct_search_result(described_class, "9780571334650")
118
+ end
119
+ end
@@ -0,0 +1,160 @@
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::BookProviders::WorldCatProvider do
10
+ let(:sky_catalog_main) do
11
+ <<~XHTML
12
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
13
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
14
+ <head></head>
15
+ <body id="worldcat">
16
+ <table class="table-results">
17
+ <tr class="menuElem">
18
+ <td class="result details">
19
+ <div class="name">
20
+ <a id="result-1" href="/title/sky-catalogue-20000-ed-by-alan-hirshfeld-and-roger-w-sinnott/oclc/476534140&referer=brief_results"><strong>Sky catalogue 2000.0 ed. by Alan Hirshfeld and Roger W. Sinnott</strong></a>
21
+ </div>
22
+ <div class="type">
23
+ <img class='icn' src='https://static1.worldcat.org/wcpa/rel20201014/images/icon-bks.gif' alt=' ' height='16' width='16' />&nbsp;<span class='itemType'>Print book</span>
24
+ </div>
25
+ </td>
26
+ </tr>
27
+ <tr class="menuElem">
28
+ <td class="result details">
29
+ <div class="name">
30
+ <a id="result-2" href="/title/sky-catalogue-20000/oclc/7978015&referer=brief_results"><strong>Sky catalogue 2000.0</strong></a>
31
+ </div>
32
+ <div class="type">
33
+ <img class='icn' src='https://static1.worldcat.org/wcpa/rel20201014/images/icon-bks.gif' alt=' ' height='16' width='16' />&nbsp;<span class='itemType'>Print book</span>
34
+ </div>
35
+ </td>
36
+ </tr>
37
+ </table>
38
+ </body>
39
+ </html>
40
+ XHTML
41
+ end
42
+
43
+ let(:sky_catalog_details) do
44
+ <<~XHTML
45
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
46
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
47
+ <head></head>
48
+ <body id="worldcat">
49
+ <div id="bibdata">
50
+ <h1 class="title">Sky catalogue 2000.0 ed. by Alan Hirshfeld and Roger W. Sinnott</h1>
51
+ <table border="0" cellspacing="0" cellpadding="0">
52
+ <tr id="bib-author-row">
53
+ <th>Author:</th>
54
+ <td id="bib-author-cell">
55
+ <a href='/search?q=au%3AHirshfeld+Alan&amp;qt=hot_author' title='Search for more by this author'>Hirshfeld Alan</a>;
56
+ <a href='/search?q=au%3ASinnott+Roger+W.&amp;qt=hot_author' title='Search for more by this author'>Sinnott Roger W.</a>;
57
+ <a href='/search?q=au%3ACambridge+Cambridge+University+Press+1982-&amp;qt=hot_author' title='Search for more by this author'>Cambridge Cambridge University Press 1982-</a>
58
+ </td>
59
+ </tr>
60
+ <tr id="bib-publisher-row">
61
+ <th>Publisher:</th>
62
+ <td id="bib-publisher-cell">1982</td>
63
+ </tr>
64
+ </table>
65
+ </div>
66
+ <table border="0" cellspacing="0">
67
+ <tr id="details-allauthors">
68
+ <th>All Authors / Contributors:</th>
69
+ <td>
70
+ <a href='/search?q=au%3AHirshfeld+Alan&amp;qt=hot_author' title='Search for more by this author'>Hirshfeld Alan</a>;
71
+ <a href='/search?q=au%3ASinnott+Roger+W.&amp;qt=hot_author' title='Search for more by this author'>Sinnott Roger W.</a>;
72
+ <a href='/search?q=au%3ACambridge+Cambridge+University+Press+1982-&amp;qt=hot_author' title='Search for more by this author'>Cambridge Cambridge University Press 1982-</a>
73
+ </td>
74
+ </tr>
75
+ <tr id="details-standardno">
76
+ <th>ISBN:</th>
77
+ <td>0521247101 9780521247108 0521289130 9780521289139 0521258189 9780521258180</td>
78
+ </tr>
79
+ </table>
80
+ </body>
81
+ </html>
82
+ XHTML
83
+ end
84
+
85
+ let(:florence_ru_details) do
86
+ <<~XHTML
87
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
89
+ <head></head>
90
+ <body id="worldcat">
91
+ <div id="bibdata">
92
+ <h1 class="title">
93
+ <div class="vernacular" lang="ru">Флоренс Аравийская : роман /</div>
94
+ Florens Araviĭskai︠a︡ : roman
95
+ </h1>
96
+ <table border="0" cellspacing="0" cellpadding="0">
97
+ <tr id="bib-author-row">
98
+ <th>Author:</th>
99
+ <td id="bib-author-cell">
100
+ <span class="vernacular" lang="ru">Кристофер Бакли ; перевод с английского Андрея Геласимова.</span>
101
+ <span class="vernacular" lang="ru">Геласимов, Андрей.</span> ;
102
+ <a href="/search?q=au%3ABuckley%2C+Christopher%2C&amp;qt=hot_author" title="Search for more by this author">Christopher Buckley</a>;
103
+ <a href="/search?q=au%3AGelasimov%2C+Andrei%CC%86.&amp;qt=hot_author" title="Search for more by this author">Andreĭ Gelasimov</a>
104
+ </td>
105
+ </tr>
106
+ <tr id="bib-publisher-row">
107
+ <th>Publisher:</th>
108
+ <td id="bib-publisher-cell"><span class="vernacular" lang="ru">Иностранка,</span>
109
+ Moskva : Inostranka, 2006.
110
+ </td>
111
+ </tr>
112
+ </table>
113
+ </div>
114
+ <table border="0" cellspacing="0">
115
+ <tr id="details-allauthors">
116
+ <th>All Authors / Contributors:</th>
117
+ <td>
118
+ <span class="vernacular" lang="ru">Кристофер Бакли ; перевод с английского Андрея Геласимова.</span>
119
+ <span class="vernacular" lang="ru">Геласимов, Андрей.</span> ;
120
+ <a href="/search?q=au%3ABuckley%2C+Christopher%2C&amp;qt=hot_author" title="Search for more by this author">Christopher Buckley</a>;
121
+ <a href="/search?q=au%3AGelasimov%2C+Andrei%CC%86.&amp;qt=hot_author" title="Search for more by this author">Andreĭ Gelasimov</a>
122
+ </td>
123
+ </tr>
124
+ <tr id="details-standardno">
125
+ <th>ISBN:</th>
126
+ <td>5941454139 9785941454136</td>
127
+ </tr>
128
+ </table>
129
+ </body>
130
+ </html>
131
+ XHTML
132
+ end
133
+
134
+ it "works for an isbn with multiple results" do
135
+ stub_request(:get, "https://www.worldcat.org/search?q=isbn:9780521247108&qt=advanced")
136
+ .to_return(status: 200, body: +sky_catalog_main, headers: {})
137
+ stub_request(:get,
138
+ "https://www.worldcat.org/title/" \
139
+ "sky-catalogue-20000-ed-by-alan-hirshfeld-and-roger-w-sinnott" \
140
+ "/oclc/476534140&referer=brief_results")
141
+ .to_return(status: 200, body: +sky_catalog_details, headers: {})
142
+ assert_correct_search_result(described_class, "9780521247108")
143
+ end
144
+
145
+ it "works with vernacular" do
146
+ stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced")
147
+ .to_return(status: 200, body: +florence_ru_details, headers: {})
148
+ assert_correct_search_result(described_class, "9785941454136")
149
+ end
150
+
151
+ it "works with multiple authors" do
152
+ stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced")
153
+ .to_return(status: 200, body: +florence_ru_details, headers: {})
154
+ results = assert_correct_search_result(described_class,
155
+ "9785941454136")
156
+ this_book = results.first
157
+ expect(this_book.authors).to be_instance_of(Array), "Not an array!"
158
+ expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!"
159
+ end
160
+ end
@@ -8,158 +8,4 @@ require "spec_helper"
8
8
 
9
9
  describe Alexandria::BookProviders do
10
10
  it "should be less clever"
11
-
12
- def assert_correct_search_result(provider, query,
13
- search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
14
- begin
15
- results = provider.instance.search(query, search_type)
16
- rescue SocketError
17
- skip "Service is offline"
18
- end
19
-
20
- puts results.inspect if $DEBUG
21
-
22
- expect(results).to be_instance_of(Array), "Results are not an array for #{provider}"
23
- expect(results).not_to be_empty, "Results are empty for #{provider}"
24
-
25
- if search_type == Alexandria::BookProviders::SEARCH_BY_ISBN
26
- expect(results.length).to be <= 2, "Results are greater than 2 for #{provider}"
27
-
28
- book = results.first
29
-
30
- expect(book).to be_instance_of(Alexandria::Book),
31
- "Result is not a Book for #{provider}"
32
-
33
- canonical_query = Alexandria::Library.canonicalise_ean(query)
34
- canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
35
- expect(canonical_query)
36
- .to eq(canonical_result),
37
- "Result's isbn #{book.isbn} is not equivalent" \
38
- " to the requested isbn #{query} for #{provider}"
39
-
40
- if results.length == 2
41
- cover_url = results.last
42
- if cover_url
43
- expect(cover_url)
44
- .to be_instance_of(String),
45
- "Unexpected cover_url #{cover_url.inspect} for #{provider}"
46
- end
47
- end
48
- else
49
- expect(results.first.first)
50
- .to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
51
- end
52
- results
53
- end
54
-
55
- it "does not piss off Rich Burridge" do
56
- skip "Amazon requires an API key. Remove it altogether as a provider?"
57
- assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
58
- "033025068X")
59
- end
60
-
61
- it "amazon should work" do
62
- skip "Amazon requires an API key. Remove it altogether as a provider?"
63
- assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
64
- "9780385504201")
65
- end
66
-
67
- it "amazon title should work" do
68
- skip "Amazon requires an API key. Remove it altogether as a provider?"
69
- assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
70
- "A Confederacy of Dunces",
71
- Alexandria::BookProviders::SEARCH_BY_TITLE)
72
- end
73
-
74
- it "amazon authors should work" do
75
- skip "Amazon requires an API key. Remove it altogether as a provider?"
76
- assert_correct_search_result(Alexandria::BookProviders::AmazonProvider,
77
- "John Kennedy Toole",
78
- Alexandria::BookProviders::SEARCH_BY_AUTHORS)
79
- end
80
-
81
- it "amazon keyword 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
- "Confederacy Dunces",
85
- Alexandria::BookProviders::SEARCH_BY_KEYWORD)
86
- end
87
-
88
- it "LOC should work" do
89
- assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
90
- "9780805335583")
91
- # this book has non-ASCII letters
92
- assert_correct_search_result(Alexandria::BookProviders::LOCProvider,
93
- "9782070379248")
94
- end
95
-
96
- it "BL should work" do
97
- skip "Not working: connect failed"
98
- assert_correct_search_result(Alexandria::BookProviders::BLProvider,
99
- "9781853260803")
100
- end
101
-
102
- it "SBN should work" do
103
- assert_correct_search_result(Alexandria::BookProviders::SBNProvider,
104
- "9788835926436")
105
- end
106
-
107
- it "Barnes and Noble should work" do
108
- skip "Barnes and Noble is not operational at the moment"
109
- assert_correct_search_result(Alexandria::BookProviders::BarnesAndNobleProvider,
110
- "9780961328917") # see #1433
111
- end
112
-
113
- it "Proxis should work" do
114
- skip "Needs fixing"
115
- assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
116
- "9789026965746")
117
- assert_correct_search_result(Alexandria::BookProviders::ProxisProvider,
118
- "9780586071403")
119
- end
120
-
121
- it "Thalia should work" do
122
- skip "Needs fixing"
123
- # german book
124
- assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
125
- "9783896673305")
126
- # international book
127
- assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
128
- "9780440241904")
129
- # movie dvd
130
- assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
131
- "4010232037824")
132
- # music cd
133
- assert_correct_search_result(Alexandria::BookProviders::ThaliaProvider,
134
- "0094638203520")
135
- end
136
-
137
- it "AdLibris should work" do
138
- skip "Needs fixing: site has changed"
139
- assert_correct_search_result(Alexandria::BookProviders::AdLibrisProvider,
140
- "9789100109332")
141
- end
142
-
143
- it "Siciliano should work" do
144
- skip "Needs fixing: no results found"
145
- assert_correct_search_result(Alexandria::BookProviders::SicilianoProvider,
146
- "9788599170380")
147
- end
148
-
149
- it "Worldcat should work" do
150
- assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
151
- "9780521247108")
152
- # this one is with <div class=vernacular lang="[^"]+">)
153
- assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
154
- "9785941454136")
155
- end
156
-
157
- it "Worldcat should work with multiple authors" do
158
- results = assert_correct_search_result(Alexandria::BookProviders::WorldCatProvider,
159
- "9785941454136")
160
- this_book = results.first
161
- expect(this_book.authors).to be_instance_of(Array), "Not an array!"
162
- # puts this_book.authors
163
- expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!"
164
- end
165
11
  end
@@ -10,14 +10,9 @@ RSpec.describe Alexandria do
10
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
- after do
18
- FileUtils.rm_rf(TESTDIR)
19
- end
20
-
21
16
  describe ".list_books_on_console" do
22
17
  it "returns a string containing a list of all books" do
23
18
  expect(described_class.list_books_on_console).to eq <<~LIST
@@ -7,24 +7,23 @@
7
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
24
  end
25
25
 
26
26
  after do
27
- FileUtils.rm_rf(TESTDIR)
28
27
  FileUtils.rm_rf(outfile) if File.exist? outfile
29
28
  end
30
29
 
@@ -32,44 +31,33 @@ RSpec.describe Alexandria::ExportLibrary do
32
31
  let(:message) { :export_as_csv_list }
33
32
 
34
33
  def load_rows_from_csv
35
- CSV.read(outfile, col_sep: ";")
34
+ CSV.read(outfile, col_sep: ";", headers: true)
36
35
  end
37
36
 
38
37
  it "can sort by title" do
39
38
  sort_by_title = Alexandria::LibrarySortOrder.new(:title)
40
- format.invoke(@my_library, sort_by_title, outfile)
41
- expect(File.exist?(outfile)).to be_truthy
39
+ format.invoke(my_library, sort_by_title, outfile)
42
40
  rows = load_rows_from_csv
43
- rows.shift
44
- expect(rows.size).to eq(@my_library.size)
45
- title_index = 0
46
- comparisons = rows.size - 1
47
- comparisons.times do |index|
48
- expect(rows[index][title_index]).to be <= rows[index + 1][title_index]
49
- end
41
+ titles = rows.map { |it| it["Title"] }
42
+ expect(titles).to eq titles.sort
50
43
  end
51
44
 
52
45
  it "can sort in descending order" do
53
46
  sort_by_date_desc = Alexandria::LibrarySortOrder.new(:publishing_year, false)
54
- format.invoke(@my_library, sort_by_date_desc, outfile)
55
- expect(File.exist?(outfile)).to be_truthy
47
+ format.invoke(my_library, sort_by_date_desc, outfile)
56
48
  rows = load_rows_from_csv
57
- rows.shift
58
- expect(rows.size).to eq(@my_library.size)
59
- date_index = 5
60
- comparisons = rows.size - 1
61
- comparisons.times do |index|
62
- expect(rows[index][date_index]).to be >= rows[index + 1][date_index]
63
- end
49
+ dates = rows.map { |it| it["Year Published"] }
50
+ expect(dates).to eq dates.sort.reverse
64
51
  end
65
52
  end
66
53
 
67
54
  describe "#export_as_html" do
68
55
  let(:message) { :export_as_html }
69
- let(:index) { File.join(outfile, "index.html") }
70
56
 
71
57
  it "can export unsorted" do
72
- format.invoke(@my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
58
+ format.invoke(my_library, unsorted, outfile, Alexandria::WebTheme.all.first)
59
+ index = File.join(outfile, "index.html")
60
+
73
61
  aggregate_failures do
74
62
  expect(File.exist?(outfile)).to be_truthy
75
63
  expect(File.exist?(index)).to be_truthy
@@ -82,7 +70,7 @@ RSpec.describe Alexandria::ExportLibrary do
82
70
  let(:message) { :export_as_onix_xml_archive }
83
71
 
84
72
  it "can export unsorted" do
85
- format.invoke(@my_library, unsorted, outfile)
73
+ format.invoke(my_library, unsorted, outfile)
86
74
  aggregate_failures do
87
75
  expect(File.exist?(outfile)).to be_truthy
88
76
  expect(File.size(outfile)).to be_nonzero
@@ -94,7 +82,7 @@ RSpec.describe Alexandria::ExportLibrary do
94
82
  let(:message) { :export_as_tellico_xml_archive }
95
83
 
96
84
  it "can export unsorted" do
97
- format.invoke(@my_library, unsorted, outfile)
85
+ format.invoke(my_library, unsorted, outfile)
98
86
  aggregate_failures do
99
87
  expect(File.exist?(outfile)).to be_truthy
100
88
  expect(File.size(outfile)).to be_nonzero
@@ -106,7 +94,7 @@ RSpec.describe Alexandria::ExportLibrary do
106
94
  let(:message) { :export_as_bibtex }
107
95
 
108
96
  it "can export unsorted" do
109
- format.invoke(@my_library, unsorted, outfile)
97
+ format.invoke(my_library, unsorted, outfile)
110
98
  aggregate_failures do
111
99
  expect(File.exist?(outfile)).to be_truthy
112
100
  expect(File.size(outfile)).to be_nonzero
@@ -118,7 +106,7 @@ RSpec.describe Alexandria::ExportLibrary do
118
106
  let(:message) { :export_as_isbn_list }
119
107
 
120
108
  it "can export unsorted" do
121
- format.invoke(@my_library, unsorted, outfile)
109
+ format.invoke(my_library, unsorted, outfile)
122
110
  aggregate_failures do
123
111
  expect(File.exist?(outfile)).to be_truthy
124
112
  expect(File.size(outfile)).to be_nonzero
@@ -128,10 +116,11 @@ RSpec.describe Alexandria::ExportLibrary do
128
116
 
129
117
  describe "#export_as_ipod_notes" do
130
118
  let(:message) { :export_as_ipod_notes }
131
- let(:index) { File.join(outfile, "index.linx") }
132
119
 
133
120
  it "can export unsorted" do
134
- format.invoke(@my_library, unsorted, outfile, nil)
121
+ format.invoke(my_library, unsorted, outfile, nil)
122
+ index = File.join(outfile, "index.linx")
123
+
135
124
  aggregate_failures do
136
125
  expect(File.exist?(outfile)).to be_truthy
137
126
  expect(File.size(index)).to be_nonzero