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
@@ -18,8 +18,8 @@
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 'logger'
22
- require 'forwardable'
21
+ require "logger"
22
+ require "forwardable"
23
23
 
24
24
  module Alexandria
25
25
  # A Logger subclass which accepts a source for log messages
@@ -82,9 +82,9 @@ module Alexandria
82
82
 
83
83
  def <<(msg)
84
84
  if msg.respond_to? :backtrace
85
- msg.backtrace.each { |line|
85
+ msg.backtrace.each do |line|
86
86
  @logger << " #{line} \n"
87
- }
87
+ end
88
88
  else
89
89
  @logger << msg + "\n"
90
90
  end
@@ -137,7 +137,7 @@ module Alexandria
137
137
  def self.create_logger
138
138
  logger = Alexandria::Logger.new(STDERR)
139
139
 
140
- level = ENV['LOGLEVEL'] ? ENV['LOGLEVEL'].intern : nil
140
+ level = ENV["LOGLEVEL"] ? ENV["LOGLEVEL"].intern : nil
141
141
  if [:FATAL, :ERROR, :WARN, :INFO, :DEBUG].include? level
142
142
  logger.level = Logger.const_get(level)
143
143
  else
@@ -24,7 +24,7 @@ module Alexandria
24
24
  @isbn = isbn
25
25
  @publisher = publisher
26
26
  @edition = edition # actually used for binding! (i.e. paperback or hardback)
27
- @notes = ''
27
+ @notes = ""
28
28
  @saved_ident = ident
29
29
  @publishing_year = publishing_year
30
30
  @redd = false
@@ -4,12 +4,12 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'yaml'
8
- require 'fileutils'
9
- require 'rexml/document'
10
- require 'tempfile'
11
- require 'etc'
12
- require 'alexandria/library_store'
7
+ require "yaml"
8
+ require "fileutils"
9
+ require "rexml/document"
10
+ require "tempfile"
11
+ require "etc"
12
+ require "alexandria/library_store"
13
13
 
14
14
  module Alexandria
15
15
  class Library < Array
@@ -17,12 +17,12 @@ module Alexandria
17
17
 
18
18
  attr_reader :name
19
19
  attr_accessor :ruined_books, :updating, :deleted_books
20
- DEFAULT_DIR = File.join(ENV['HOME'], '.alexandria')
21
- EXT = { book: '.yaml', cover: '.cover' }.freeze
20
+ DEFAULT_DIR = File.join(ENV["HOME"], ".alexandria")
21
+ EXT = { book: ".yaml", cover: ".cover" }.freeze
22
22
 
23
23
  include GetText
24
24
  extend GetText
25
- bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
25
+ bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
26
26
 
27
27
  BOOK_ADDED, BOOK_UPDATED, BOOK_REMOVED = (0..3).to_a
28
28
  include Observable
@@ -36,7 +36,7 @@ module Alexandria
36
36
  end
37
37
 
38
38
  def self.generate_new_name(existing_libraries,
39
- from_base = _('Untitled'))
39
+ from_base = _("Untitled"))
40
40
  i = 1
41
41
  name = nil
42
42
  all_libraries = existing_libraries + @@deleted_libraries
@@ -71,11 +71,11 @@ module Alexandria
71
71
  def self.extract_numbers(entry)
72
72
  return [] if entry.nil? || entry.empty?
73
73
 
74
- normalized = entry.delete('- ').upcase
75
- return [] unless normalized =~ /\A[\dX]*\Z/
74
+ normalized = entry.delete("- ").upcase
75
+ return [] unless /\A[\dX]*\Z/.match?(normalized)
76
76
 
77
- normalized.split('').map do |char|
78
- char == 'X' ? 10 : char.to_i
77
+ normalized.split("").map do |char|
78
+ char == "X" ? 10 : char.to_i
79
79
  end
80
80
  end
81
81
 
@@ -84,7 +84,7 @@ module Alexandria
84
84
  accumulator + numbers[i] * (i + 1)
85
85
  end % 11
86
86
 
87
- sum == 10 ? 'X' : sum
87
+ sum == 10 ? "X" : sum
88
88
  end
89
89
 
90
90
  def self.valid_isbn?(isbn)
@@ -117,18 +117,18 @@ module Alexandria
117
117
  end
118
118
 
119
119
  AMERICAN_UPC_LOOKUP = {
120
- '014794' => '08041', '018926' => '0445', '02778' => '0449',
121
- '037145' => '0812', '042799' => '0785', '043144' => '0688',
122
- '044903' => '0312', '045863' => '0517', '046594' => '0064',
123
- '047132' => '0152', '051487' => '08167', '051488' => '0140',
124
- '060771' => '0002', '065373' => '0373', '070992' => '0523',
125
- '070993' => '0446', '070999' => '0345', '071001' => '0380',
126
- '071009' => '0440', '071125' => '088677', '071136' => '0451',
127
- '071149' => '0451', '071152' => '0515', '071162' => '0451',
128
- '071268' => '08217', '071831' => '0425', '071842' => '08439',
129
- '072742' => '0441', '076714' => '0671', '076783' => '0553',
130
- '076814' => '0449', '078021' => '0872', '079808' => '0394',
131
- '090129' => '0679', '099455' => '0061', '099769' => '0451'
120
+ "014794" => "08041", "018926" => "0445", "02778" => "0449",
121
+ "037145" => "0812", "042799" => "0785", "043144" => "0688",
122
+ "044903" => "0312", "045863" => "0517", "046594" => "0064",
123
+ "047132" => "0152", "051487" => "08167", "051488" => "0140",
124
+ "060771" => "0002", "065373" => "0373", "070992" => "0523",
125
+ "070993" => "0446", "070999" => "0345", "071001" => "0380",
126
+ "071009" => "0440", "071125" => "088677", "071136" => "0451",
127
+ "071149" => "0451", "071152" => "0515", "071162" => "0451",
128
+ "071268" => "08217", "071831" => "0425", "071842" => "08439",
129
+ "072742" => "0441", "076714" => "0671", "076783" => "0553",
130
+ "076814" => "0449", "078021" => "0872", "079808" => "0394",
131
+ "090129" => "0679", "099455" => "0061", "099769" => "0451"
132
132
  }.freeze
133
133
 
134
134
  def self.upc_convert(upc)
@@ -137,15 +137,15 @@ module Alexandria
137
137
  end
138
138
 
139
139
  def self.canonicalise_ean(code)
140
- code = code.to_s.delete('- ')
140
+ code = code.to_s.delete("- ")
141
141
  if valid_ean?(code)
142
142
  code
143
143
  elsif valid_isbn?(code)
144
- code = '978' + code[0..8]
144
+ code = "978" + code[0..8]
145
145
  code + String(ean_checksum(extract_numbers(code)))
146
146
  elsif valid_upc?(code)
147
147
  isbn10 = canonicalise_isbn
148
- code = '978' + isbn10[0..8]
148
+ code = "978" + isbn10[0..8]
149
149
  code + String(ean_checksum(extract_numbers(code)))
150
150
  end
151
151
  end
@@ -185,8 +185,8 @@ module Alexandria
185
185
  end
186
186
  book.saved_ident = book.ident
187
187
 
188
- filename = book.saved_ident.to_s + '.yaml'
189
- File.open(filename, 'w') { |io| io.puts book.to_yaml }
188
+ filename = book.saved_ident.to_s + ".yaml"
189
+ File.open(filename, "w") { |io| io.puts book.to_yaml }
190
190
  filename
191
191
  end
192
192
 
@@ -212,7 +212,7 @@ module Alexandria
212
212
 
213
213
  temp_book = book.dup
214
214
  temp_book.library = nil
215
- File.open(yaml(temp_book), 'w') { |io| io.puts temp_book.to_yaml }
215
+ File.open(yaml(temp_book), "w") { |io| io.puts temp_book.to_yaml }
216
216
 
217
217
  # Do not notify twice.
218
218
  if changed?
@@ -231,7 +231,7 @@ module Alexandria
231
231
  Dir.chdir(path) do
232
232
  # Fetch the cover picture.
233
233
  cover_file = cover(book)
234
- File.open(cover_file, 'w') do |io|
234
+ File.open(cover_file, "w") do |io|
235
235
  uri = URI.parse(cover_uri)
236
236
  if uri.scheme.nil?
237
237
  # Regular filename.
@@ -388,12 +388,12 @@ module Alexandria
388
388
  end
389
389
 
390
390
  def self.jpeg?(file)
391
- IO.read(file, 10)[6..9] == 'JFIF'
391
+ IO.read(file, 10)[6..9] == "JFIF"
392
392
  end
393
393
 
394
394
  def final_cover(book)
395
395
  # TODO: what about PNG?
396
- book.ident + (Library.jpeg?(cover(book)) ? '.jpg' : '.gif')
396
+ book.ident + (Library.jpeg?(cover(book)) ? ".jpg" : ".gif")
397
397
  end
398
398
 
399
399
  protected
@@ -24,7 +24,7 @@ module Alexandria
24
24
  class WWWAgent
25
25
  def initialize
26
26
  user_agent = "Ruby #{RUBY_VERSION} #{Alexandria::TITLE}/#{Alexandria::VERSION}"
27
- @extra_request_headers = { 'User-Agent' => user_agent }
27
+ @extra_request_headers = { "User-Agent" => user_agent }
28
28
  end
29
29
 
30
30
  def self.transport
@@ -38,18 +38,18 @@ module Alexandria
38
38
  @extra_request_headers.each_pair do |header_name, value|
39
39
  req.add_field(header_name, value)
40
40
  end
41
- res = WWWAgent.transport.start(uri.host, uri.port) { |http|
41
+ res = WWWAgent.transport.start(uri.host, uri.port) do |http|
42
42
  http.request(req)
43
- }
43
+ end
44
44
  res
45
45
  end
46
46
 
47
47
  def language=(lang)
48
- @extra_request_headers['Accept-Language'] = lang.to_s
48
+ @extra_request_headers["Accept-Language"] = lang.to_s
49
49
  end
50
50
 
51
51
  def user_agent=(agent_string)
52
- @extra_request_headers['User-Agent'] = agent_string
52
+ @extra_request_headers["User-Agent"] = agent_string
53
53
  end
54
54
  end
55
55
  end
@@ -4,21 +4,21 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'singleton'
8
- require 'set'
9
- require 'alexandria/default_preferences'
7
+ require "singleton"
8
+ require "set"
9
+ require "alexandria/default_preferences"
10
10
 
11
11
  module Alexandria
12
12
  class Preferences
13
13
  include Singleton
14
14
  include Logging
15
15
 
16
- APP_DIR = '/apps/alexandria'
17
- HTTP_PROXY_DIR = '/system/http_proxy'
18
- HTTP_PROXY_MODE = '/system/proxy/mode'
19
- URL_HANDLERS_DIR = '/desktop/gnome/url-handlers'
16
+ APP_DIR = "/apps/alexandria"
17
+ HTTP_PROXY_DIR = "/system/http_proxy"
18
+ HTTP_PROXY_MODE = "/system/proxy/mode"
19
+ URL_HANDLERS_DIR = "/desktop/gnome/url-handlers"
20
20
 
21
- GCONFTOOL = 'gconftool-2'
21
+ GCONFTOOL = "gconftool-2"
22
22
 
23
23
  def initialize
24
24
  @alexandria_settings = {}
@@ -46,7 +46,7 @@ module Alexandria
46
46
  end
47
47
 
48
48
  def save!
49
- log.debug { 'preferences save!' }
49
+ log.debug { "preferences save!" }
50
50
  @changed_settings.each do |variable_name|
51
51
  log.debug { "saving preference #{variable_name} / #{@alexandria_settings[variable_name].class}" }
52
52
  generic_save_setting(variable_name, @alexandria_settings[variable_name])
@@ -107,7 +107,7 @@ module Alexandria
107
107
  end
108
108
 
109
109
  def generic_save_setting(variable_name, new_value)
110
- var_path = APP_DIR + '/' + variable_name
110
+ var_path = APP_DIR + "/" + variable_name
111
111
  if new_value.is_a?(Array)
112
112
  # when setting array, first remove nil elements (fixing #9007)
113
113
  new_value.compact!
@@ -136,13 +136,13 @@ module Alexandria
136
136
 
137
137
  def get_gconf_type(value)
138
138
  if value.is_a?(String)
139
- 'string'
139
+ "string"
140
140
  elsif value.is_a?(Integer)
141
- 'int'
141
+ "int"
142
142
  elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
143
- 'bool'
143
+ "bool"
144
144
  else
145
- 'string'
145
+ "string"
146
146
  end
147
147
  end
148
148
 
@@ -150,7 +150,7 @@ module Alexandria
150
150
  # NOTE we must check between list and pair...
151
151
 
152
152
  list_type = get_gconf_type(new_list.first)
153
- if list_type == 'int' && new_list.size == 2
153
+ if list_type == "int" && new_list.size == 2
154
154
  # treat this as a pair of int
155
155
  a = new_list[0]
156
156
  b = new_list[1]
@@ -163,13 +163,13 @@ module Alexandria
163
163
  end
164
164
 
165
165
  def make_list_string(list)
166
- list.map! { |x| x.gsub(/\"/, '\\"') } if get_gconf_type(list.first) == 'string'
167
- contents = list.join(',')
168
- '[' + contents + ']'
166
+ list.map! { |x| x.gsub(/\"/, '\\"') } if get_gconf_type(list.first) == "string"
167
+ contents = list.join(",")
168
+ "[" + contents + "]"
169
169
  end
170
170
 
171
171
  def exec_gconf_set(var_path, new_value)
172
- if /cols_width/ =~ var_path
172
+ if /cols_width/.match?(var_path)
173
173
  puts new_value
174
174
 
175
175
  # new_value = {}
@@ -180,12 +180,12 @@ module Alexandria
180
180
  new_value.gsub!(/\"/, '\\"')
181
181
  value_str = "\"#{new_value}\""
182
182
  end
183
- puts value_str if /cols_width/ =~ var_path
183
+ puts value_str if /cols_width/.match?(var_path)
184
184
  `gconftool-2 --type #{type} --set #{var_path} #{value_str}`
185
185
  end
186
186
 
187
187
  def exec_gconf_unset(variable_name)
188
- `#{GCONFTOOL} --unset #{APP_DIR + '/' + variable_name}`
188
+ `#{GCONFTOOL} --unset #{APP_DIR + "/" + variable_name}`
189
189
  end
190
190
 
191
191
  ##
@@ -205,14 +205,14 @@ module Alexandria
205
205
  def load_http_proxy_settings
206
206
  http_proxy_vars = `#{GCONFTOOL} --recursive-list #{HTTP_PROXY_DIR}`
207
207
  http_proxy = gconftool_values_to_hash(http_proxy_vars)
208
- if http_proxy['use_http_proxy']
208
+ if http_proxy["use_http_proxy"]
209
209
  proxy_mode = `#{GCONFTOOL} --get #{HTTP_PROXY_MODE}`.chomp
210
- if proxy_mode == 'manual'
210
+ if proxy_mode == "manual"
211
211
  @use_http_proxy = true
212
- @proxy_host = http_proxy['host']
213
- @proxy_port = http_proxy['port']
214
- @proxy_user = http_proxy['authentication_user']
215
- @proxy_password = http_proxy['authentication_n_password']
212
+ @proxy_host = http_proxy["host"]
213
+ @proxy_port = http_proxy["port"]
214
+ @proxy_user = http_proxy["authentication_user"]
215
+ @proxy_password = http_proxy["authentication_n_password"]
216
216
  end
217
217
  end
218
218
  @http_proxy_loaded = true
@@ -235,17 +235,17 @@ module Alexandria
235
235
  # gconftool. This is not fool-proof, but it *does* work for the
236
236
  # range of values used by Alexandria.
237
237
  def discriminate(value)
238
- if value == 'true' # bool
238
+ if value == "true" # bool
239
239
  true
240
- elsif value == 'false' # bool
240
+ elsif value == "false" # bool
241
241
  false
242
- elsif value =~ /^[0-9]+$/ # int
242
+ elsif /^[0-9]+$/.match?(value) # int
243
243
  value.to_i
244
244
  elsif value =~ /^\[(.*)\]$/ # list (assume of type String)
245
- Regexp.last_match[1].split(',')
245
+ Regexp.last_match[1].split(",")
246
246
  elsif value =~ /^\((.*)\)$/ # pair (assume of type int)
247
247
  begin
248
- pair = Regexp.last_match[1].split(',')
248
+ pair = Regexp.last_match[1].split(",")
249
249
  return [discriminate(pair.first), discriminate(pair.last)]
250
250
  rescue StandardError
251
251
  return [0, 0]
@@ -18,7 +18,7 @@
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 'alexandria/scanners'
21
+ require "alexandria/scanners"
22
22
 
23
23
  module Alexandria
24
24
  module Scanners
@@ -26,19 +26,19 @@ module Alexandria
26
26
  include Alexandria::Logging
27
27
 
28
28
  def name
29
- 'CueCat'
29
+ "CueCat"
30
30
  end
31
31
 
32
32
  def display_name
33
- 'CueCat'
33
+ "CueCat"
34
34
  end
35
35
 
36
36
  # Checks if data looks like cuecat input
37
37
  def match?(data)
38
38
  data = data.chomp
39
- return false if data[-1] != '.'
39
+ return false if data[-1] != "."
40
40
 
41
- fields = data.split('.')
41
+ fields = data.split(".")
42
42
  return false if fields.size != 4
43
43
  return false if fields[2].size != 4
44
44
 
@@ -50,13 +50,13 @@ module Alexandria
50
50
  # domain perl implementation.
51
51
  def decode(data)
52
52
  data = data.chomp
53
- fields = data.split('.')
53
+ fields = data.split(".")
54
54
  fields.shift # First part is gibberish
55
55
  fields.shift # Second part is cuecat serial number
56
56
  type, code = fields.map { |field| decode_field(field) }
57
57
 
58
- if type == 'IB5'
59
- type = 'IBN'
58
+ if type == "IB5"
59
+ type = "IBN"
60
60
  code = code[0, 13]
61
61
  end
62
62
 
@@ -64,13 +64,13 @@ module Alexandria
64
64
  if Library.valid_upc? code
65
65
  isbn13 = Library.canonicalise_ean(code)
66
66
  code = isbn13
67
- type = 'IBN'
67
+ type = "IBN"
68
68
  end
69
69
  rescue StandardError
70
70
  log.debug { "Cannot translate UPC (#{type}) code #{code} to ISBN" }
71
71
  end
72
72
 
73
- return code if type == 'IBN'
73
+ return code if type == "IBN"
74
74
 
75
75
  raise "Don't know how to handle type #{type} (barcode: #{code})"
76
76
  end
@@ -78,7 +78,7 @@ module Alexandria
78
78
  private
79
79
 
80
80
  def decode_field(encoded)
81
- seq = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-'
81
+ seq = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-"
82
82
 
83
83
  chars = encoded.split(//)
84
84
  values = chars.map { |c| seq.index(c) }
@@ -90,7 +90,7 @@ module Alexandria
90
90
  end
91
91
 
92
92
  def calc(values)
93
- result = ''
93
+ result = ""
94
94
  until values.empty?
95
95
  num = ((values[0] << 6 | values[1]) << 6 | values[2]) << 6 | values[3]
96
96
  result += ((num >> 16) ^ 67).chr
@@ -106,7 +106,7 @@ module Alexandria
106
106
  length = array.length % 4
107
107
 
108
108
  if length.nonzero?
109
- raise 'Error parsing CueCat input' if length == 1
109
+ raise "Error parsing CueCat input" if length == 1
110
110
 
111
111
  length = 4 - length
112
112
  length.times { array.push(0) }