matheus 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08561d64b6400b698a4a1e0392db8b6e334f16fcdc82eddc77b94f3c119fccaf'
4
- data.tar.gz: ed62993f879971fa1ba7c9f6da817fe2f69f229c4ad29c9d9520e3f9f0cd30e8
3
+ metadata.gz: 0f58d7287ef588ecd9a19da562f85a0c94cecb1911b07c1b3e079b620c37d7de
4
+ data.tar.gz: f45c9ed2d4d192ead57a91562eecc52153c0dd35b6241fab31afcafa73050add
5
5
  SHA512:
6
- metadata.gz: efa24b6dc461527791a9960c7bd374635cf511cce3f51c9c6d4ac7b83f5abac79faf8b0c5f74b479660a53e7546ee9cf72b71c1976845d85f2ae3be1028559dd
7
- data.tar.gz: f1fa29a3e1caad57abcd2498d607367f2c70132ef8c34e083ddd020775182c29e07565c54996a1f1f46d696834c66c95c444adfb64575f1e64cfd51bcf421cf0
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.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/matheus.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dotenv/load"
3
+ require "dotenv"
4
4
  require "active_support"
5
5
  require "active_support/core_ext"
6
6
  require "zeitwerk"
7
7
 
8
+ Dotenv.load("~/.env")
8
9
  Zeitwerk::Loader.for_gem.setup
9
10
 
10
11
  module Matheus
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.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-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.6
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.