rfc-reader 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b42f53e0145a5153d21e1f555c006e2081c43c126b60c581f5687567530f00b
4
- data.tar.gz: cb3d545f31ebba48757242e003e9f3ef2d9960c1a6277256cfc6dfcc389af38c
3
+ metadata.gz: f626967d7919c641d14227967a9e863a2c4eaedfd5f97dc5ecde994349725cd5
4
+ data.tar.gz: 303d9bf3449ac2122f27f36f3053dfdbb7350b1f8900662517055aadfe8a6c42
5
5
  SHA512:
6
- metadata.gz: 3337413fc3634c92bf8ec4ff3f347749de4b4cff385e6b29184fa63a641e8456f9cfd21142e07d125b09e320aa38bbab57e90c7f64cc2f75d516c7fa3307d81a
7
- data.tar.gz: 557038fda98a3ea623ea128cd99aa4423ff2befb1493f4f0e7313807a60273bf2c14007df1d818b90ce5e33bdd6de08a8d5814e69227104ede1eaa21cb4349e8
6
+ metadata.gz: 1c29a80e008410ed0924921850c70ad84b8a8bf99e341725a6164757204db8469e7f4eab9c725e04557098251e9d22c23861eb1fbe9a0a9c1cd75603392d9aff
7
+ data.tar.gz: 3351a9b4447a38eabf3eb9ba5f0fd50415e9502af6db5fadd236ee1ab848ff57bde6b959b0a6ceaafb337387310f7ca656b9214b7ec063879df51daa275415f7
data/exe/rfc-reader CHANGED
@@ -4,4 +4,4 @@
4
4
  $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
5
5
  require "rfc_reader"
6
6
 
7
- RfcReader::Command.start
7
+ exit RfcReader::Command.start
@@ -4,10 +4,17 @@ require "thor"
4
4
 
5
5
  module RfcReader
6
6
  class Command < Thor
7
+ SUCCESS = 0
8
+ private_constant :SUCCESS
9
+
10
+ FAILURE = 1
11
+ private_constant :FAILURE
12
+
7
13
  # @return [Boolean]
8
14
  def self.exit_on_failure? = true
9
15
 
10
16
  # @param command [String, nil]
17
+ # @return [Integer] exit code
11
18
  def help(command = nil)
12
19
  unless command
13
20
  puts <<~DESCRIPTION
@@ -23,6 +30,8 @@ module RfcReader
23
30
  end
24
31
 
25
32
  super
33
+
34
+ SUCCESS
26
35
  end
27
36
 
28
37
  desc "search [TERM]", "Search for RFCs by TERM for reading"
@@ -33,12 +42,18 @@ module RfcReader
33
42
  it will get downloaded so that you can read it in your terminal.
34
43
  LONGDESC
35
44
  # @param term [String]
45
+ # @return [Integer] exit code
36
46
  def search(term)
37
47
  search_results = Search.search_by(term: term)
48
+ if search_results.empty?
49
+ warn "No search results for: #{term}"
50
+ return FAILURE
51
+ end
38
52
  title = Terminal.choose("Choose an RFC to read:", search_results.keys)
39
53
  url = search_results.fetch(title)
40
54
  content = Library.download_document(title: title, url: url)
41
55
  Terminal.page(content)
56
+ SUCCESS
42
57
  end
43
58
 
44
59
  desc "recent", "List recent RFC releases for reading"
@@ -48,12 +63,18 @@ module RfcReader
48
63
  Choose any RFC from the list that seems interesting and
49
64
  it will get downloaded so that you can read it in your terminal.
50
65
  LONGDESC
66
+ # @return [Integer] exit code
51
67
  def recent
52
68
  recent_results = Recent.list
69
+ if recent_results.empty?
70
+ warn "Error: Empty recent RFC list from rfc-editor.org RSS feed"
71
+ return FAILURE
72
+ end
53
73
  title = Terminal.choose("Choose an RFC to read:", recent_results.keys)
54
74
  url = recent_results.fetch(title)
55
75
  content = Library.download_document(title: title, url: url)
56
76
  Terminal.page(content)
77
+ SUCCESS
57
78
  end
58
79
 
59
80
  desc "library", "List already downloaded RFCs for reading"
@@ -63,18 +84,29 @@ module RfcReader
63
84
  Choose any RFC from the list that seems interesting and
64
85
  you can read it offline in your terminal.
65
86
  LONGDESC
87
+ # @return [Integer] exit code
66
88
  def library
67
89
  rfc_catalog = Library.catalog
90
+ if rfc_catalog.empty?
91
+ warn <<~MESSAGE
92
+ No RFCs are currently saved in the library. Try using the
93
+ `search` or `recent` commands to download some RFCs first.
94
+ MESSAGE
95
+ return FAILURE
96
+ end
68
97
  all_titles = rfc_catalog.map { _1[:title] }
69
98
  title = Terminal.choose("Choose an RFC to read:", all_titles)
70
99
  rfc = rfc_catalog.find { _1[:title] == title }
71
100
  content = Library.load_document(**rfc)
72
101
  Terminal.page(content)
102
+ SUCCESS
73
103
  end
74
104
 
75
105
  desc "version", "Print the program version"
106
+ # @return [Integer] exit code
76
107
  def version
77
108
  puts VERSION
109
+ SUCCESS
78
110
  end
79
111
  end
80
112
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RfcReader
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfc-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Robell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-24 00:00:00.000000000 Z
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri