matheus 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +42 -0
- data/exe/alert-me +7 -0
- data/lib/matheus/alert_me.rb +17 -0
- data/lib/matheus/q.rb +3 -1
- data/lib/matheus/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f58d7287ef588ecd9a19da562f85a0c94cecb1911b07c1b3e079b620c37d7de
|
4
|
+
data.tar.gz: f45c9ed2d4d192ead57a91562eecc52153c0dd35b6241fab31afcafa73050add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2ab16abdc86aedba2c0ef30f1614091e17165d11bad1d8c95d3170619104e7e6a62c33785cc34abe516e3d3929434a5eac7f77550f17b2c639174c1d23aba03
|
7
|
+
data.tar.gz: 0a241ef204280b9a5e08f379d82823bd670a9fd352e20fe633055e0a788ee1adaa15af5c7f8956c5c2bc1e032089eff502973e21839d6b318f166d7a455a0eba
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.3.4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,48 @@ A bunch of CLI tools I made for my own use.
|
|
6
6
|
|
7
7
|
$ gem install matheus
|
8
8
|
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
### `alert-me`
|
12
|
+
|
13
|
+
```sh
|
14
|
+
$ alert-me sleep 1 && echo "Done!"
|
15
|
+
Done!
|
16
|
+
# plays a sound after the command finishes
|
17
|
+
```
|
18
|
+
|
19
|
+
### `date-of-last`
|
20
|
+
|
21
|
+
Prints the date of the last week day.
|
22
|
+
|
23
|
+
```sh
|
24
|
+
$ date-of-last monday
|
25
|
+
2024-02-12
|
26
|
+
|
27
|
+
$ date-of-last sun
|
28
|
+
2024-02-11
|
29
|
+
```
|
30
|
+
|
31
|
+
### `q`
|
32
|
+
|
33
|
+
It expects a OPENAI_API_KEY environment variable to be set. It will try to load
|
34
|
+
it from a `.env` file at `~/.env`.
|
35
|
+
|
36
|
+
```sh
|
37
|
+
$ q "What is the capital of France?"
|
38
|
+
The capital of France is **Paris**
|
39
|
+
```
|
40
|
+
|
41
|
+
### `puts`
|
42
|
+
|
43
|
+
It evaluates the given Ruby code and prints the result. Active Support is
|
44
|
+
available.
|
45
|
+
|
46
|
+
```sh
|
47
|
+
$ puts 10.days.ago
|
48
|
+
2024-08-17 15:50:11 -0300
|
49
|
+
```
|
50
|
+
|
9
51
|
## Contributing
|
10
52
|
|
11
53
|
Probably not accepting contributions at the moment, but feel free to open an issue if you have any ideas or suggestions.
|
data/exe/alert-me
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Matheus
|
2
|
+
class AlertMe < Command
|
3
|
+
# Usage:
|
4
|
+
# $ alert-me sleep 1 && echo 'Done!'
|
5
|
+
# Runs the command and plays a sound based on its success or failure after it finishes.
|
6
|
+
def call(*args)
|
7
|
+
command = args.join(" ")
|
8
|
+
if system(command)
|
9
|
+
system("afplay /System/Library/Sounds/Glass.aiff")
|
10
|
+
else
|
11
|
+
system("afplay /System/Library/Sounds/Sosumi.aiff")
|
12
|
+
end
|
13
|
+
rescue => e
|
14
|
+
Failure(e.message)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/matheus/q.rb
CHANGED
@@ -21,7 +21,7 @@ module Matheus
|
|
21
21
|
|
22
22
|
response = client.chat(
|
23
23
|
parameters: {
|
24
|
-
model: "gpt-4o-mini",
|
24
|
+
model: "gpt-4o-mini",
|
25
25
|
messages: [{role: "user", content: "#{BASE_PROMPT}#{question}"}]
|
26
26
|
}
|
27
27
|
)
|
@@ -29,6 +29,8 @@ module Matheus
|
|
29
29
|
raise response["error"]["message"] if response.has_key?("error")
|
30
30
|
|
31
31
|
response.dig("choices", 0, "message", "content")
|
32
|
+
rescue Faraday::ClientError => error
|
33
|
+
raise error.response_body.dig("error", "message") || error
|
32
34
|
end
|
33
35
|
|
34
36
|
def print_markdown(text)
|
data/lib/matheus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Richard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -84,6 +84,7 @@ description: A bunch of CLI tools I made for my own use.
|
|
84
84
|
email:
|
85
85
|
- matheusrichardt@gmail.com
|
86
86
|
executables:
|
87
|
+
- alert-me
|
87
88
|
- date-of-last
|
88
89
|
- puts
|
89
90
|
- q
|
@@ -96,10 +97,12 @@ files:
|
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
100
|
+
- exe/alert-me
|
99
101
|
- exe/date-of-last
|
100
102
|
- exe/puts
|
101
103
|
- exe/q
|
102
104
|
- lib/matheus.rb
|
105
|
+
- lib/matheus/alert_me.rb
|
103
106
|
- lib/matheus/command.rb
|
104
107
|
- lib/matheus/date_of_last.rb
|
105
108
|
- lib/matheus/puts.rb
|
@@ -129,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
132
|
- !ruby/object:Gem::Version
|
130
133
|
version: '0'
|
131
134
|
requirements: []
|
132
|
-
rubygems_version: 3.5.
|
135
|
+
rubygems_version: 3.5.11
|
133
136
|
signing_key:
|
134
137
|
specification_version: 4
|
135
138
|
summary: A bunch of CLI tools I made for my own use.
|