alexandria-book-collection-manager 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +6 -6
  3. data/.rubocop_todo.yml +13 -26
  4. data/.simplecov +2 -2
  5. data/CHANGELOG.md +8 -0
  6. data/Rakefile +3 -3
  7. data/alexandria-book-collection-manager.gemspec +18 -18
  8. data/lib/alexandria/book_providers/z3950_provider.rb +1 -1
  9. data/lib/alexandria/console.rb +2 -2
  10. data/lib/alexandria/export_library.rb +4 -4
  11. data/lib/alexandria/import_library.rb +1 -1
  12. data/lib/alexandria/library_store.rb +1 -1
  13. data/lib/alexandria/models/library.rb +2 -2
  14. data/lib/alexandria/{book_providers/pseudomarc.rb → pseudo_marc_parser.rb} +1 -1
  15. data/lib/alexandria/smart_library.rb +2 -2
  16. data/lib/alexandria/ui/alert_dialog.rb +2 -2
  17. data/lib/alexandria/ui/book_properties_dialog_base.rb +3 -3
  18. data/lib/alexandria/ui/icons.rb +2 -2
  19. data/lib/alexandria/ui/init.rb +10 -4
  20. data/lib/alexandria/ui/ui_manager.rb +4 -4
  21. data/lib/alexandria/version.rb +1 -1
  22. data/lib/alexandria/web_themes.rb +1 -1
  23. data/lib/alexandria.rb +6 -5
  24. data/spec/alexandria/book_providers/bl_provider_spec.rb +1 -1
  25. data/spec/alexandria/book_providers/loc_provider_spec.rb +2 -2
  26. data/spec/alexandria/book_providers/sbn_provider_spec.rb +1 -1
  27. data/spec/alexandria/book_providers/thalia_provider_spec.rb +1 -1
  28. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +22 -10
  29. data/spec/alexandria/book_spec.rb +5 -3
  30. data/spec/alexandria/export_library_spec.rb +8 -8
  31. data/spec/alexandria/library_spec.rb +67 -53
  32. data/spec/alexandria/library_store_spec.rb +1 -1
  33. data/spec/alexandria/preferences_spec.rb +7 -7
  34. data/spec/alexandria/pseudo_marc_parser_spec.rb +71 -0
  35. data/spec/alexandria/scanners/cue_cat_spec.rb +11 -4
  36. data/spec/alexandria/smart_library_spec.rb +7 -5
  37. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  38. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  39. data/spec/alexandria/ui/alert_dialog_spec.rb +5 -3
  40. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  41. data/spec/alexandria/ui/book_properties_dialog_spec.rb +4 -4
  42. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +18 -2
  43. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  44. data/spec/alexandria/ui/error_dialog_spec.rb +13 -2
  45. data/spec/alexandria/ui/export_dialog_spec.rb +3 -3
  46. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  47. data/spec/alexandria/ui/import_dialog_spec.rb +3 -3
  48. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  49. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +4 -4
  50. data/spec/alexandria/ui/new_book_dialog_spec.rb +2 -2
  51. data/spec/alexandria/ui/new_provider_dialog_spec.rb +3 -3
  52. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +9 -7
  53. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  54. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +2 -2
  55. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  56. data/spec/alexandria/ui/sidepane_manager_spec.rb +1 -1
  57. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +18 -2
  58. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +2 -2
  59. data/spec/alexandria/ui/ui_manager_spec.rb +5 -3
  60. data/spec/spec_helper.rb +23 -32
  61. data/util/rake/fileinstall.rb +8 -8
  62. data/util/rake/gettextgenerate.rb +1 -1
  63. metadata +15 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 680cc4d6ee5efa35b819f163452593c352c9323efcd06baad69458e46ac16dfc
4
- data.tar.gz: a1153041ada7d8641d84d5b118209c05247d9651bcddc5f92164745f62f7289c
3
+ metadata.gz: 829e1e63ffab2d61ef2a83a75ac56bf393e503f45ef4ba6d7914ce1c5a38e845
4
+ data.tar.gz: 5732456488a3f7ad93a3ec2d35c0011a2155f32496397740f3262bfb7dadd463
5
5
  SHA512:
6
- metadata.gz: c7b860e3c6726fcda6877d44a84d88a62daebdc768a4d4acc6756f2a712257b1eebc783a9a1f7d3ad81219c85f2b4c4a4a84d6e8cc4126bb6847109fa9da7020
7
- data.tar.gz: 99e777a212dcad283f0e9722b2836b41c51442cb6153b5f76a0cd03ec87977733112bffc73899ca1c8081e32f68da50bace883b5c7eb0410174b8a0e05e2a6fe
6
+ metadata.gz: 128ded6fe79d486802a8790f557cd0a94cd32f6345a996827b7acd8171067be0146f5bdeec10c015c331b2e6b73cfdff877295c3dbfde60d726b53c6241d941c
7
+ data.tar.gz: 87675903b9ef31770693a072e832b798d4512d5f0ce9aac59d0dab3421f8974919d1ce4b67673f2fa5841da8e35d665ea83c04928befaa6b7b305a102c89e917
@@ -4,11 +4,11 @@
4
4
 
5
5
  name: CI
6
6
 
7
- on:
7
+ "on":
8
8
  push:
9
- branches: [ master ]
9
+ branches: [master]
10
10
  pull_request:
11
- branches: [ master ]
11
+ branches: [master]
12
12
  schedule:
13
13
  - cron: '16 4 12 * *'
14
14
 
@@ -19,10 +19,10 @@ jobs:
19
19
 
20
20
  strategy:
21
21
  matrix:
22
- ruby: [2.6, 2.7, "3.0", "3.1"]
22
+ ruby: [2.6, 2.7, "3.0", "3.1", "3.2.0-preview2"]
23
23
 
24
24
  steps:
25
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v3
26
26
  - name: Install non-ruby dependencies
27
27
  run: |
28
28
  sudo apt-get update
@@ -53,7 +53,7 @@ jobs:
53
53
  runs-on: ubuntu-latest
54
54
 
55
55
  steps:
56
- - uses: actions/checkout@v2
56
+ - uses: actions/checkout@v3
57
57
  - name: Install non-ruby dependencies
58
58
  run: |
59
59
  sudo apt-get update
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp`
3
- # using RuboCop version 1.24.1.
3
+ # using RuboCop version 1.36.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -12,12 +12,12 @@ Lint/DuplicateBranch:
12
12
  - 'lib/alexandria/book_providers/sbn_provider.rb'
13
13
  - 'util/rake/fileinstall.rb'
14
14
 
15
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
15
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
16
16
  Metrics/AbcSize:
17
- Max: 111
17
+ Max: 109
18
18
 
19
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
20
- # IgnoredMethods: refine
19
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, inherit_mode.
20
+ # AllowedMethods: refine
21
21
  Metrics/BlockLength:
22
22
  Max: 64
23
23
 
@@ -29,11 +29,11 @@ Metrics/BlockNesting:
29
29
  Metrics/ClassLength:
30
30
  Max: 991
31
31
 
32
- # Configuration parameters: IgnoredMethods.
32
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
33
33
  Metrics/CyclomaticComplexity:
34
- Max: 22
34
+ Max: 21
35
35
 
36
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
36
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
37
37
  Metrics/MethodLength:
38
38
  Max: 98
39
39
 
@@ -45,7 +45,7 @@ Metrics/ModuleLength:
45
45
  Metrics/ParameterLists:
46
46
  Max: 7
47
47
 
48
- # Configuration parameters: IgnoredMethods.
48
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
49
49
  Metrics/PerceivedComplexity:
50
50
  Max: 27
51
51
 
@@ -76,20 +76,7 @@ RSpec/FilePath:
76
76
  - 'spec/alexandria/ui/iconview_spec.rb'
77
77
  - 'spec/alexandria/ui/sound_spec.rb'
78
78
 
79
- RSpec/MultipleExpectations:
80
- Max: 7
81
-
82
- # Cop supports --auto-correct.
83
- # Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
84
- # SupportedStyles: inflected, explicit
85
- RSpec/PredicateMatcher:
86
- Exclude:
87
- - 'spec/alexandria/export_library_spec.rb'
88
- - 'spec/alexandria/library_spec.rb'
89
- - 'spec/alexandria/library_store_spec.rb'
90
- - 'spec/alexandria/scanners/cue_cat_spec.rb'
91
-
92
- # Cop supports --auto-correct.
79
+ # This cop supports safe autocorrection (--autocorrect).
93
80
  Rake/Desc:
94
81
  Exclude:
95
82
  - 'Rakefile'
@@ -99,7 +86,7 @@ Rake/DuplicateTask:
99
86
  Exclude:
100
87
  - 'Rakefile'
101
88
 
102
- # Cop supports --auto-correct.
89
+ # This cop supports unsafe autocorrection (--autocorrect-all).
103
90
  # Configuration parameters: EnforcedStyle.
104
91
  # SupportedStyles: nested, compact
105
92
  Style/ClassAndModuleChildren:
@@ -121,7 +108,8 @@ Style/ClassVars:
121
108
  Style/Documentation:
122
109
  Enabled: false
123
110
 
124
- # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
111
+ # This cop supports safe autocorrection (--autocorrect).
112
+ # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods.
125
113
  # SupportedStyles: annotated, template, unannotated
126
114
  Style/FormatStringToken:
127
115
  Exclude:
@@ -133,7 +121,6 @@ Style/OptionalBooleanParameter:
133
121
  Exclude:
134
122
  - 'lib/alexandria/book_providers.rb'
135
123
  - 'lib/alexandria/book_providers/worldcat.rb'
136
- - 'lib/alexandria/console.rb'
137
124
  - 'lib/alexandria/execution_queue.rb'
138
125
  - 'lib/alexandria/export_format.rb'
139
126
  - 'lib/alexandria/library_sort_order.rb'
data/.simplecov CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  SimpleCov.start do
4
- add_group "Main", "lib"
5
- add_group "Specs", "spec"
4
+ add_group "Main", "lib/"
5
+ add_group "Specs", "spec/"
6
6
  enable_coverage :branch
7
7
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.10 / 2022-10-14
4
+
5
+ * Loosen dependency on the marc gem
6
+ * Update dependency on the gtk3 and gstreamer gems
7
+ * Make Alexandria's own MARC parser handle nil records ([#198] by [mvz])
8
+ * Support upcoming Ruby 3.2
9
+
3
10
  ## 0.7.9 / 2022-02-04
4
11
 
5
12
  * Drop support for Ruby 2.5
@@ -135,6 +142,7 @@
135
142
  [HappyFacade]: https://github.com/HappyFacade
136
143
 
137
144
  <!-- issues and pull requests -->
145
+ [#198]: https://github.com/mvz/alexandria-book-collection-manager/pull/198
138
146
  [#139]: https://github.com/mvz/alexandria-book-collection-manager/pull/139
139
147
  [#136]: https://github.com/mvz/alexandria-book-collection-manager/pull/136
140
148
  [#134]: https://github.com/mvz/alexandria-book-collection-manager/pull/134
data/Rakefile CHANGED
@@ -15,12 +15,12 @@ require "omfgenerate"
15
15
 
16
16
  require_relative "lib/alexandria/version"
17
17
 
18
- stage_dir = ENV["DESTDIR"] || "tmp"
19
- prefix_dir = ENV["PREFIX"] || "/usr"
18
+ stage_dir = ENV.fetch("DESTDIR", "tmp")
19
+ prefix_dir = ENV.fetch("PREFIX", "/usr")
20
20
 
21
21
  PROJECT = "alexandria"
22
22
  PREFIX = prefix_dir
23
- share_dir = ENV["SHARE"] || "#{PREFIX}/share"
23
+ share_dir = ENV.fetch("SHARE", "#{PREFIX}/share")
24
24
  SHARE = share_dir
25
25
 
26
26
  GettextGenerateTask.new(PROJECT) do |g|
@@ -47,23 +47,23 @@ Gem::Specification.new do |spec|
47
47
  spec.require_paths = ["lib"]
48
48
  spec.rdoc_options = ["--main", "README.md"]
49
49
 
50
- spec.add_runtime_dependency("gettext", ["~> 3.1"])
51
- spec.add_runtime_dependency("gstreamer", ["~> 3.5.0"])
52
- spec.add_runtime_dependency("gtk3", ["~> 3.5.0"])
53
- spec.add_runtime_dependency("htmlentities", ["~> 4.3"])
54
- spec.add_runtime_dependency("image_size", ["~> 3.0"])
55
- spec.add_runtime_dependency("marc", ">= 1.0", "< 1.2")
56
- spec.add_runtime_dependency("nokogiri", ["~> 1.11"])
57
- spec.add_runtime_dependency("psych", ">= 3.2", "< 4.1")
58
- spec.add_runtime_dependency("zoom", ["~> 0.5.0"])
50
+ spec.add_runtime_dependency "gettext", ["~> 3.1"]
51
+ spec.add_runtime_dependency "gstreamer", ["~> 4.0.2"]
52
+ spec.add_runtime_dependency "gtk3", ["~> 4.0.2"]
53
+ spec.add_runtime_dependency "htmlentities", ["~> 4.3"]
54
+ spec.add_runtime_dependency "image_size", ["~> 3.0"]
55
+ spec.add_runtime_dependency "marc", ">= 1.0", "< 1.3"
56
+ spec.add_runtime_dependency "nokogiri", ["~> 1.11"]
57
+ spec.add_runtime_dependency "psych", ">= 3.2", "< 4.1"
58
+ spec.add_runtime_dependency "zoom", ["~> 0.5.0"]
59
59
 
60
- spec.add_development_dependency("gnome_app_driver", "~> 0.3.0")
61
- spec.add_development_dependency("rake", ["~> 13.0"])
62
- spec.add_development_dependency("rspec", ["~> 3.0"])
63
- spec.add_development_dependency("rubocop", "~> 1.25")
64
- spec.add_development_dependency("rubocop-i18n", ["~> 3.0"])
65
- spec.add_development_dependency("rubocop-performance", "~> 1.13")
66
- spec.add_development_dependency("rubocop-rake", "~> 0.6.0")
67
- spec.add_development_dependency("rubocop-rspec", "~> 2.7")
68
- spec.add_development_dependency("webmock", "~> 3.9")
60
+ spec.add_development_dependency "gnome_app_driver", "~> 0.3.2"
61
+ spec.add_development_dependency "rake", ["~> 13.0"]
62
+ spec.add_development_dependency "rspec", ["~> 3.0"]
63
+ spec.add_development_dependency "rubocop", "~> 1.32"
64
+ spec.add_development_dependency "rubocop-i18n", ["~> 3.0"]
65
+ spec.add_development_dependency "rubocop-performance", "~> 1.13"
66
+ spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
67
+ spec.add_development_dependency "rubocop-rspec", "~> 2.7"
68
+ spec.add_development_dependency "webmock", "~> 3.9"
69
69
  end
@@ -5,7 +5,7 @@
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
7
  require "zoom"
8
- require "alexandria/book_providers/pseudomarc"
8
+ require "alexandria/pseudo_marc_parser"
9
9
  require "marc"
10
10
 
11
11
  module Alexandria
@@ -5,14 +5,14 @@
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
7
  module Alexandria
8
- def self.list_books_on_console(_title = true, authors = true)
8
+ def self.list_books_on_console
9
9
  collection = Alexandria::LibraryCollection.instance
10
10
  collection.reload
11
11
  libraries = collection.all_regular_libraries
12
12
  output_string = ""
13
13
  @books = libraries.flatten
14
14
  @books.each do |book|
15
- book_authors = book.authors.join(" & ") if authors
15
+ book_authors = book.authors.join(" & ")
16
16
  output_string += [book.title, book_authors].join(", ") + "\n"
17
17
  end
18
18
  output_string
@@ -73,7 +73,7 @@ module Alexandria
73
73
  end
74
74
 
75
75
  def export_as_html(filename, theme)
76
- FileUtils.mkdir(filename) unless File.exist?(filename)
76
+ FileUtils.mkdir_p(filename)
77
77
  Dir.chdir(filename) do
78
78
  copy_covers("pixmaps")
79
79
  FileUtils.cp_r(theme.pixmaps_directory, "pixmaps") if theme.has_pixmaps?
@@ -91,7 +91,7 @@ module Alexandria
91
91
  end
92
92
 
93
93
  def export_as_ipod_notes(filename, _theme)
94
- FileUtils.mkdir(filename) unless File.exist?(filename)
94
+ FileUtils.mkdir_p(filename)
95
95
  tempdir = Dir.getwd
96
96
  Dir.chdir(filename)
97
97
  copy_covers("pixmaps")
@@ -211,8 +211,8 @@ module Alexandria
211
211
  doc = REXML::Document.new
212
212
  doc << REXML::XMLDecl.new
213
213
  doc << REXML::DocType.new("tellico",
214
- 'PUBLIC "-//Robby Stephenson/DTD Tellico V7.0//EN"' \
215
- ' "http://periapsis.org/tellico/dtd/v7/tellico.dtd"')
214
+ 'PUBLIC "-//Robby Stephenson/DTD Tellico V7.0//EN" ' \
215
+ '"http://periapsis.org/tellico/dtd/v7/tellico.dtd"')
216
216
  tellico = doc.add_element("tellico")
217
217
  tellico.add_attribute("syntaxVersion", "7")
218
218
  tellico.add_namespace("http://periapsis.org/tellico/")
@@ -72,7 +72,7 @@ module Alexandria
72
72
  return nil unless system("unzip -qqt \"#{filename}\"")
73
73
 
74
74
  tmpdir = File.join(Dir.tmpdir, "tellico_export")
75
- FileUtils.rm_rf(tmpdir) if File.exist?(tmpdir)
75
+ FileUtils.rm_rf(tmpdir)
76
76
  Dir.mkdir(tmpdir)
77
77
  Dir.chdir(tmpdir) do
78
78
  system("unzip -qq \"#{filename}\"")
@@ -43,7 +43,7 @@ module Alexandria
43
43
  test = [0, nil]
44
44
  ruined_books = []
45
45
  library = Library.new(name, self)
46
- FileUtils.mkdir_p(library.path) unless File.exist?(library.path)
46
+ FileUtils.mkdir_p(library.path)
47
47
  Dir.chdir(library.path) do
48
48
  Dir["*" + Library::EXT[:book]].sort.each do |filename|
49
49
  test[1] = filename if (test[0]).zero?
@@ -20,7 +20,7 @@ module Alexandria
20
20
  attr_reader :name
21
21
  attr_accessor :ruined_books, :updating, :deleted_books
22
22
 
23
- DEFAULT_DIR = File.join(ENV["HOME"], ".alexandria")
23
+ DEFAULT_DIR = File.join(Dir.home, ".alexandria")
24
24
  EXT = { book: ".yaml", cover: ".cover" }.freeze
25
25
 
26
26
  include GetText
@@ -379,7 +379,7 @@ module Alexandria
379
379
  end
380
380
 
381
381
  def copy_covers(somewhere)
382
- FileUtils.rm_rf(somewhere) if File.exist?(somewhere)
382
+ FileUtils.rm_rf(somewhere)
383
383
  FileUtils.mkdir(somewhere)
384
384
  each do |book|
385
385
  next unless File.exist?(cover(book))
@@ -124,7 +124,7 @@ module Alexandria
124
124
 
125
125
  def self.marc_text_to_details(marc)
126
126
  details = {}
127
- marc.each_line do |line|
127
+ marc&.each_line do |line|
128
128
  if line =~ /(\d+)\s*(.+)/
129
129
  code = Regexp.last_match[1]
130
130
  data = Regexp.last_match[2]
@@ -148,7 +148,7 @@ module Alexandria
148
148
  if book
149
149
  @cache[book].save(book)
150
150
  else
151
- FileUtils.mkdir_p(base_dir) unless File.exist? base_dir
151
+ FileUtils.mkdir_p(base_dir)
152
152
  File.open(yaml, "w") { |io| io.puts to_hash.to_yaml }
153
153
  end
154
154
  end
@@ -162,7 +162,7 @@ module Alexandria
162
162
  end
163
163
 
164
164
  def copy_covers(somewhere)
165
- FileUtils.rm_rf(somewhere) if File.exist?(somewhere)
165
+ FileUtils.rm_rf(somewhere)
166
166
  FileUtils.mkdir(somewhere)
167
167
  each do |book|
168
168
  library = @cache[book]
@@ -34,6 +34,8 @@ module Alexandria
34
34
  @dialog.child.pack_start(hbox)
35
35
  end
36
36
 
37
+ attr_reader :dialog
38
+
37
39
  def show_all
38
40
  dialog.show_all
39
41
  end
@@ -52,8 +54,6 @@ module Alexandria
52
54
 
53
55
  private
54
56
 
55
- attr_reader :dialog
56
-
57
57
  def make_label(markup)
58
58
  label = Gtk::Label.new
59
59
  label.set_alignment(0, 0)
@@ -151,7 +151,7 @@ module Alexandria
151
151
 
152
152
  def want_toggled; end
153
153
 
154
- @@latest_filechooser_directory = ENV["HOME"]
154
+ @@latest_filechooser_directory = Dir.home
155
155
  def on_change_cover
156
156
  dialog = Gtk::FileChooserDialog.new(title: _("Select a cover image"),
157
157
  parent: @book_properties_dialog,
@@ -177,8 +177,8 @@ module Alexandria
177
177
  FileUtils.cp(dialog.filename, "#{@cover_file}.orig")
178
178
  new_width = cover.width / (cover.height / COVER_ABSOLUTE_MAXHEIGHT.to_f)
179
179
  log.info do
180
- "Scaling large cover image to" \
181
- " #{new_width.to_i} x #{COVER_ABSOLUTE_MAXHEIGHT}"
180
+ "Scaling large cover image to " \
181
+ "#{new_width.to_i} x #{COVER_ABSOLUTE_MAXHEIGHT}"
182
182
  end
183
183
  cover = cover.scale(new_width.to_i, COVER_ABSOLUTE_MAXHEIGHT)
184
184
  cover.save(@cover_file, "jpeg")
@@ -35,8 +35,8 @@ module Alexandria
35
35
  return GdkPixbuf::Pixbuf.new(file: filename) if File.exist?(filename)
36
36
  rescue GdkPixbuf::PixbufError
37
37
  log.error do
38
- "Failed to load GdkPixbuf::Pixbuf," \
39
- " please ensure that #{filename} is a valid image file"
38
+ "Failed to load GdkPixbuf::Pixbuf, " \
39
+ "please ensure that #{filename} is a valid image file"
40
40
  end
41
41
  end
42
42
  BOOK_ICON
@@ -25,22 +25,28 @@ class Gtk::ActionGroup
25
25
  end
26
26
 
27
27
  module Alexandria::UI::FreezeThaw
28
+ def self.included(base)
29
+ base.class_eval do
30
+ attr_accessor :old_model
31
+ end
32
+ end
33
+
28
34
  def frozen?
29
- @old_model && !model
35
+ old_model && !model
30
36
  end
31
37
 
32
38
  def freeze
33
39
  return if frozen?
34
40
 
35
- @old_model = model
41
+ self.old_model = model
36
42
  self.model = nil
37
43
  end
38
44
 
39
45
  def unfreeze
40
46
  return unless frozen?
41
47
 
42
- self.model = @old_model
43
- @old_model = nil
48
+ self.model = old_model
49
+ self.old_model = nil
44
50
  end
45
51
  end
46
52
 
@@ -609,8 +609,8 @@ module Alexandria
609
609
 
610
610
  def handle_ruined_books
611
611
  new_message = _(
612
- "The data files for the following books are malformed or empty. Do you wish to" \
613
- " attempt to download new information for them from the online book providers?\n")
612
+ "The data files for the following books are malformed or empty. Do you wish to " \
613
+ "attempt to download new information for them from the online book providers?\n")
614
614
 
615
615
  @libraries.ruined_books.each do |bi|
616
616
  new_message += "\n#{bi[1] || bi[1].inspect}"
@@ -654,8 +654,8 @@ module Alexandria
654
654
  end
655
655
 
656
656
  log.debug do
657
- "Trying to add #{book.title}, #{cover_uri}" \
658
- " in library ''#{library.name}'"
657
+ "Trying to add #{book.title}, #{cover_uri} " \
658
+ "in library ''#{library.name}'"
659
659
  end
660
660
  library.save_cover(book, cover_uri) unless cover_uri.nil?
661
661
  library << book
@@ -5,7 +5,7 @@
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
7
  module Alexandria
8
- VERSION = "0.7.9"
8
+ VERSION = "0.7.10"
9
9
  DATA_VERSION = "0.6.3"
10
10
  DISPLAY_VERSION = VERSION
11
11
  end
@@ -39,7 +39,7 @@ module Alexandria
39
39
  File.join(Alexandria::Config::DATA_DIR, "web-themes"),
40
40
 
41
41
  # User dir
42
- File.join(ENV["HOME"], ".alexandria", ".web-themes")
42
+ File.join(Dir.home, ".alexandria", ".web-themes")
43
43
  ]
44
44
  themes_dir.map { |x| load(x) }.flatten
45
45
  end
data/lib/alexandria.rb CHANGED
@@ -21,10 +21,11 @@ require "alexandria/logging"
21
21
  require "alexandria/about"
22
22
 
23
23
  module Alexandria
24
- def self.set_proxy
25
- if !ENV["http_proxy"].nil? && URI.parse(ENV["http_proxy"]).userinfo.nil?
26
- ENV["http_proxy"] = nil
27
- end
24
+ def self.clear_invalid_proxy
25
+ current_proxy = ENV.fetch("http_proxy", nil)
26
+ return if current_proxy.nil?
27
+
28
+ ENV["http_proxy"] = nil if URI.parse(current_proxy).userinfo.nil?
28
29
  end
29
30
 
30
31
  def self.set_log_level
@@ -33,7 +34,7 @@ module Alexandria
33
34
  end
34
35
 
35
36
  def self.main
36
- set_proxy
37
+ clear_invalid_proxy
37
38
  set_log_level
38
39
  Alexandria::UI.main
39
40
  end
@@ -8,6 +8,6 @@ require "spec_helper"
8
8
 
9
9
  describe Alexandria::BookProviders::BLProvider do
10
10
  it "works" do
11
- assert_correct_search_result(described_class, "9781853260803")
11
+ expect(described_class).to have_correct_search_result_for "9781853260803"
12
12
  end
13
13
  end
@@ -8,10 +8,10 @@ require "spec_helper"
8
8
 
9
9
  describe Alexandria::BookProviders::LOCProvider do
10
10
  it "works for a book with ASCII title" do
11
- assert_correct_search_result(described_class, "9780805335583")
11
+ expect(described_class).to have_correct_search_result_for "9780805335583"
12
12
  end
13
13
 
14
14
  it "works for a book with a title with non-ASCII letters" do
15
- assert_correct_search_result(described_class, "9782070379248")
15
+ expect(described_class).to have_correct_search_result_for "9782070379248"
16
16
  end
17
17
  end
@@ -8,6 +8,6 @@ require "spec_helper"
8
8
 
9
9
  describe Alexandria::BookProviders::SBNProvider do
10
10
  it "works" do
11
- assert_correct_search_result(described_class, "9788835926436")
11
+ expect(described_class).to have_correct_search_result_for "9788835926436"
12
12
  end
13
13
  end
@@ -114,6 +114,6 @@ RSpec.describe Alexandria::BookProviders::ThaliaProvider do
114
114
  stub_request(:get, "https://www.thalia.de/shop/home/artikeldetails/ID134292338.html")
115
115
  .to_return(status: 200, body: normal_people_details, headers: {})
116
116
 
117
- assert_correct_search_result(described_class, "9780571334650")
117
+ expect(described_class).to have_correct_search_result_for "9780571334650"
118
118
  end
119
119
  end
@@ -139,22 +139,34 @@ RSpec.describe Alexandria::BookProviders::WorldCatProvider do
139
139
  "sky-catalogue-20000-ed-by-alan-hirshfeld-and-roger-w-sinnott" \
140
140
  "/oclc/476534140&referer=brief_results")
141
141
  .to_return(status: 200, body: +sky_catalog_details, headers: {})
142
- assert_correct_search_result(described_class, "9780521247108")
142
+ expect(described_class).to have_correct_search_result_for "9780521247108"
143
143
  end
144
144
 
145
145
  it "works with vernacular" do
146
146
  stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced")
147
147
  .to_return(status: 200, body: +florence_ru_details, headers: {})
148
- assert_correct_search_result(described_class, "9785941454136")
148
+ expect(described_class).to have_correct_search_result_for "9785941454136"
149
149
  end
150
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!"
151
+ context "when book has multiple authors" do
152
+ let(:search_result) do
153
+ described_class.instance.search("9785941454136",
154
+ Alexandria::BookProviders::SEARCH_BY_ISBN)
155
+ rescue SocketError
156
+ skip "Service is offline"
157
+ end
158
+
159
+ before do
160
+ stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced")
161
+ .to_return(status: 200, body: +florence_ru_details, headers: {})
162
+ end
163
+
164
+ it "returns all authors" do
165
+ this_book, = search_result
166
+ aggregate_failures do
167
+ expect(this_book.authors).to be_instance_of(Array), "Not an array!"
168
+ expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!"
169
+ end
170
+ end
159
171
  end
160
172
  end
@@ -22,16 +22,18 @@ require "spec_helper"
22
22
 
23
23
  describe Alexandria::Book do
24
24
  it "is a thing" do
25
- an_artist_of_the_floating_world
25
+ expect(an_artist_of_the_floating_world).to be_a described_class
26
26
  end
27
27
 
28
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
- expect(same_book).to eq book
32
31
  different_book = an_artist_of_the_floating_world
33
32
  different_book.isbn = "9780571147999"
34
- expect(different_book).not_to eq book
33
+ aggregate_failures do
34
+ expect(same_book).to eq book
35
+ expect(different_book).not_to eq book
36
+ end
35
37
  end
36
38
 
37
39
  describe "#rating" do