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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72cfeba7ddd84ef4fd7c7c80144a1a8821eb4c3d03fd33f3d718109b08d39bae
4
- data.tar.gz: add8482702c9e6af603e6ea2ba5cb7cefa589c57bf133385f2682db7532b8324
3
+ metadata.gz: 0f58d7287ef588ecd9a19da562f85a0c94cecb1911b07c1b3e079b620c37d7de
4
+ data.tar.gz: f45c9ed2d4d192ead57a91562eecc52153c0dd35b6241fab31afcafa73050add
5
5
  SHA512:
6
- metadata.gz: 222e09a48119ad9aa15daa86b26f8159dd45dc9f7b1a8743e6bc8e1255399562e4a4ed2ee3a8ac2539b61c15d61b5d79532913cd2710b2a9f1657dae82de4a44
7
- data.tar.gz: c46798f32fc8a73cd99fb47372bdb61060718e1f0366f5d1623215e397bdb0ae5074666fc145a7957350f80bcdd4eeb459fe47809f4e656fa242423d07e28d9c
6
+ metadata.gz: c2ab16abdc86aedba2c0ef30f1614091e17165d11bad1d8c95d3170619104e7e6a62c33785cc34abe516e3d3929434a5eac7f77550f17b2c639174c1d23aba03
7
+ data.tar.gz: 0a241ef204280b9a5e08f379d82823bd670a9fd352e20fe633055e0a788ee1adaa15af5c7f8956c5c2bc1e032089eff502973e21839d6b318f166d7a455a0eba
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.0
1
+ ruby 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0]
4
+
5
+ _Released 2024-08-27_
6
+
7
+ - Add `alert-me` command.
8
+
3
9
  ## [0.2.0]
4
10
 
5
11
  _Released 2024-08-26_
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,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
4
+
5
+ require "matheus"
6
+
7
+ Matheus::AlertMe.call ARGV
@@ -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", # using gpt-4o model
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Matheus
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.0"
5
5
  end
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.2.1
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-26 00:00:00.000000000 Z
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.17
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.