ram-tool 1.0.0
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 +7 -0
- data/bin/ram-tool +5 -0
- data/lib/ram_tool/version.rb +3 -0
- data/lib/ram_tool.rb +165 -0
- metadata +41 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d783f8883ca5cb9886da7636b8e8a29bbbfffc42b726530fd19dbeeb98d0ba6e
|
|
4
|
+
data.tar.gz: 87929acad132e5c264e8671b645d1dacfd7204b24adee4312ef06b6b60c0f8d5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 74c171735aa690c4e5ccd1e02aab477bfbdf42afb332b1aa19cfc79b43e69ff587d9b2e4539838aa6d2f385cb6840eb722ecdef4d927648d3ba2e2ea58d5507e
|
|
7
|
+
data.tar.gz: 501d8be3ec806bf405eb4ca511476ddda4a6f0e928d893346d9f0b4cef9e04f66c6732ee24803faeb643e0e3e5b98dc6838044c94a1d1119532abb572271e303
|
data/bin/ram-tool
ADDED
data/lib/ram_tool.rb
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "io/console"
|
|
6
|
+
require_relative "ram_tool/version"
|
|
7
|
+
|
|
8
|
+
module RamTool
|
|
9
|
+
PIN_FILE = File.expand_path("~/.ram_tool_pin")
|
|
10
|
+
SESSION_FILE = File.expand_path("~/.ram_tool_session")
|
|
11
|
+
URL = URI("https://jjjm03299-wq.github.io/supreme-octo-potato/api/get-ram.json")
|
|
12
|
+
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
def prompt_pin(prompt)
|
|
16
|
+
print prompt
|
|
17
|
+
STDIN.noecho(&:gets).to_s.strip.tap { puts }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def logged_in?
|
|
21
|
+
File.exist?(SESSION_FILE)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def help
|
|
25
|
+
puts <<~TEXT
|
|
26
|
+
ram-tool #{VERSION}
|
|
27
|
+
|
|
28
|
+
Usage:
|
|
29
|
+
ram-tool [command]
|
|
30
|
+
|
|
31
|
+
Commands:
|
|
32
|
+
auth register
|
|
33
|
+
auth login
|
|
34
|
+
auth logout
|
|
35
|
+
auth status
|
|
36
|
+
auth reset
|
|
37
|
+
get
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
-h, --help
|
|
41
|
+
-v, --version
|
|
42
|
+
TEXT
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def run(argv)
|
|
46
|
+
cmd = argv[0]
|
|
47
|
+
sub = argv[1]
|
|
48
|
+
|
|
49
|
+
case cmd
|
|
50
|
+
when "--version", "-v"
|
|
51
|
+
puts "ram-tool #{VERSION}"
|
|
52
|
+
|
|
53
|
+
when "--help", "-h", nil
|
|
54
|
+
help
|
|
55
|
+
|
|
56
|
+
when "auth"
|
|
57
|
+
auth(sub)
|
|
58
|
+
|
|
59
|
+
when "get"
|
|
60
|
+
get_ram
|
|
61
|
+
|
|
62
|
+
else
|
|
63
|
+
puts "Unknown command: #{cmd}"
|
|
64
|
+
help
|
|
65
|
+
exit 1
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def auth(sub)
|
|
70
|
+
case sub
|
|
71
|
+
when "register"
|
|
72
|
+
if File.exist?(PIN_FILE)
|
|
73
|
+
puts "PIN already registered."
|
|
74
|
+
return
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
pin1 = prompt_pin("Enter new PIN: ")
|
|
78
|
+
pin2 = prompt_pin("Confirm new PIN: ")
|
|
79
|
+
|
|
80
|
+
unless pin1 == pin2
|
|
81
|
+
puts "PINs do not match."
|
|
82
|
+
exit 1
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
File.write(PIN_FILE, pin1)
|
|
86
|
+
puts "Registration successful."
|
|
87
|
+
|
|
88
|
+
when "login"
|
|
89
|
+
unless File.exist?(PIN_FILE)
|
|
90
|
+
puts "No PIN registered."
|
|
91
|
+
exit 1
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
pin = prompt_pin("Enter PIN: ")
|
|
95
|
+
|
|
96
|
+
if pin == File.read(PIN_FILE).strip
|
|
97
|
+
File.write(SESSION_FILE, "logged_in")
|
|
98
|
+
puts "Login successful."
|
|
99
|
+
else
|
|
100
|
+
puts "Invalid PIN."
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
when "logout"
|
|
104
|
+
unless logged_in?
|
|
105
|
+
puts "Not logged in."
|
|
106
|
+
return
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
pin = prompt_pin("Enter PIN to logout: ")
|
|
110
|
+
|
|
111
|
+
if pin == File.read(PIN_FILE).strip
|
|
112
|
+
File.delete(SESSION_FILE)
|
|
113
|
+
puts "Logged out."
|
|
114
|
+
else
|
|
115
|
+
puts "Invalid PIN."
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
when "status"
|
|
119
|
+
puts(logged_in? ? "Status: Logged in" : "Status: Logged out")
|
|
120
|
+
|
|
121
|
+
when "reset"
|
|
122
|
+
unless File.exist?(PIN_FILE)
|
|
123
|
+
puts "No PIN registered."
|
|
124
|
+
exit 1
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
current = prompt_pin("Enter current PIN: ")
|
|
128
|
+
|
|
129
|
+
unless current == File.read(PIN_FILE).strip
|
|
130
|
+
puts "Invalid PIN."
|
|
131
|
+
exit 1
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
new_pin = prompt_pin("Enter new PIN: ")
|
|
135
|
+
confirm = prompt_pin("Confirm new PIN: ")
|
|
136
|
+
|
|
137
|
+
unless new_pin == confirm
|
|
138
|
+
puts "PINs do not match."
|
|
139
|
+
exit 1
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
File.write(PIN_FILE, new_pin)
|
|
143
|
+
puts "PIN reset successful."
|
|
144
|
+
|
|
145
|
+
else
|
|
146
|
+
help
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def get_ram
|
|
151
|
+
unless logged_in?
|
|
152
|
+
puts "Please login first."
|
|
153
|
+
exit 1
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
response = Net::HTTP.get_response(URL)
|
|
157
|
+
|
|
158
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
159
|
+
json = JSON.parse(response.body)
|
|
160
|
+
puts "RAM: #{json["ram_mb"]} MB"
|
|
161
|
+
else
|
|
162
|
+
puts "HTTP #{response.code}"
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ram-tool
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Your Name
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-08-07 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: CLI tool with PIN authentication and RAM API lookup.
|
|
13
|
+
executables:
|
|
14
|
+
- ram-tool
|
|
15
|
+
extensions: []
|
|
16
|
+
extra_rdoc_files: []
|
|
17
|
+
files:
|
|
18
|
+
- bin/ram-tool
|
|
19
|
+
- lib/ram_tool.rb
|
|
20
|
+
- lib/ram_tool/version.rb
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
rdoc_options: []
|
|
25
|
+
require_paths:
|
|
26
|
+
- lib
|
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '0'
|
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
requirements: []
|
|
38
|
+
rubygems_version: 3.6.2
|
|
39
|
+
specification_version: 4
|
|
40
|
+
summary: RAM API CLI tool
|
|
41
|
+
test_files: []
|