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 +4 -4
- data/bin/glibrary +5 -5
- data/lib/user_library.rb +1 -1
- data/modules/command_line_parse.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44cd9100df73ac3cbb065f25f97dff3d9662a9b298290f36b85ff815f1961135
|
4
|
+
data.tar.gz: 0af9aaa3e89a54b9af2e70fbaa859e4aeddaba8a0164bb08168ce5bdf06fd15a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = "
|
21
|
+
DEFAULT_FILENAME = File.join File.expand_path("..", CURRENT_DIR), "saved_libraries", "library.json"
|
22
22
|
|
23
|
-
|
23
|
+
process_args!
|
24
24
|
|
25
25
|
options = {}
|
26
|
-
filename =
|
26
|
+
filename = DEFAULT_FILENAME
|
27
27
|
filename, options = CommandLineParse::command_line_parse!(filename, options)
|
28
28
|
|
29
|
-
|
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
|
-
|
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.
|
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
|
-
|
46
|
-
handle_nonexistent_file(
|
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!(
|
50
|
+
prepare_filename_for_os!(filename)
|
51
51
|
unless suppress
|
52
|
-
(l = UserLibrary.new(filename:
|
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
|