glibrary 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b442b7e44fa855ceb010b7b91b1b986ac63d66e759413080b2130553e231586
4
- data.tar.gz: b3125e46eba448ea424c851e3e190133bdaf4a747ea6f11ed831a6815a2e31bf
3
+ metadata.gz: 44cd9100df73ac3cbb065f25f97dff3d9662a9b298290f36b85ff815f1961135
4
+ data.tar.gz: 0af9aaa3e89a54b9af2e70fbaa859e4aeddaba8a0164bb08168ce5bdf06fd15a
5
5
  SHA512:
6
- metadata.gz: 6e7c492065ea7d32f4367d1e4ebf7f49220ca165b7081104bc9b3debe06f96b7cdabd241166d68cf5600f2b42eb4546197d5211aea1a81db869c3331bf11f261
7
- data.tar.gz: f21cc6a1ace2374c2e5a4e558647aacfc8f668509c2f256d09ea07e5e8f54345822047cf36d9c7435ccc3c61356b6789e951a5261c6abc1ae4c6ffc50d8e2cd4
6
+ metadata.gz: 52e7d63b7dfa0ce3db690ccd000c8ff8ee1ed7cf8fe054c82a5e8aa7792fe99cc33239666dc6d7e738601f803e091ac3612b181db0f1c2dde0bb1375498d06f2
7
+ data.tar.gz: e65ad779eb048c5e8aec184d8fbfb9945cbae300eb2a834588ee00958256d2da400faf1bf6b7d8b74593c63f9793d0f898176bed08cb0e4883b5cd1005736fe0
data/bin/glibrary CHANGED
@@ -18,15 +18,15 @@ include UserPrompt
18
18
  include CommandLineParse
19
19
 
20
20
  CURRENT_DIR = File.join(File.dirname(__FILE__))
21
- DEFAULT_FILENAME = "../saved_libraries/library.json"
21
+ DEFAULT_FILENAME = File.join File.expand_path("..", CURRENT_DIR), "saved_libraries", "library.json"
22
22
 
23
- ExecHelper::process_args!
23
+ process_args!
24
24
 
25
25
  options = {}
26
- filename = File.join(CURRENT_DIR, DEFAULT_FILENAME)
26
+ filename = DEFAULT_FILENAME
27
27
  filename, options = CommandLineParse::command_line_parse!(filename, options)
28
28
 
29
- ExecHelper::prepare_filename_for_os!(filename)
29
+ prepare_filename_for_os!(filename)
30
30
 
31
31
  persistent_library = UserLibrary.new(filename: filename)
32
32
 
@@ -38,7 +38,7 @@ begin
38
38
 
39
39
  temp_booklist.pretty_print
40
40
 
41
- UserPrompt::search_user_prompt(temp_booklist, persistent_library)
41
+ search_user_prompt(temp_booklist, persistent_library)
42
42
 
43
43
  rescue UserQuits
44
44
  puts "\nThanks for browsing. Nothing has been added to the reading list."
data/lib/user_library.rb CHANGED
@@ -113,7 +113,7 @@ class UserLibrary
113
113
  def load_saved_library!
114
114
  if File.exist?(@filename)
115
115
  book_data_set = get_raw_JSON_data
116
- book_data_set.each { |info| add(UserBook.new(info)) }
116
+ @books = book_data_set.map { |info| UserBook.new(info) }
117
117
  raise ArgumentError unless books.all? { |b| valid?(b) }
118
118
  end
119
119
  end
@@ -26,7 +26,7 @@ module CommandLineParse
26
26
 
27
27
  OptionParser.new do |opts|
28
28
  opts.banner = "Usage: glibrary [options...] [query]"
29
- @library = opts.default_argv.include?("-l")
29
+ @library = library = opts.default_argv.include?("-l")
30
30
 
31
31
  opts.on("-t", "--title=TITLE", "Specify a title keyword") do |t|
32
32
  o[:title] = t
@@ -42,14 +42,14 @@ module CommandLineParse
42
42
 
43
43
  opts.on("-f", "--lib-file=LIBFILE",
44
44
  "Select a library save file. Otherwise, a default save file will be used.") do |libfile|
45
- @filename = File.absolute_path(libfile)
46
- handle_nonexistent_file(@filename, @library) unless File.exist?(@filename)
45
+ filename = File.absolute_path(libfile)
46
+ handle_nonexistent_file(filename, library) unless File.exist?(filename)
47
47
  end
48
48
 
49
49
  opts.on("-l", "--library", "See your library; ignores all search options") do
50
- prepare_filename_for_os!(@filename)
50
+ prepare_filename_for_os!(filename)
51
51
  unless suppress
52
- (l = UserLibrary.new(filename: @filename)).pretty_print
52
+ (l = UserLibrary.new(filename: filename)).pretty_print
53
53
  library_mode_user_prompt(l)
54
54
  exit
55
55
  end
@@ -61,6 +61,6 @@ module CommandLineParse
61
61
  end
62
62
 
63
63
  end.parse!
64
- return [@filename, o]
64
+ return [(@filename = filename), o]
65
65
  end
66
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glibrary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Engelbert