matheus 0.6.4 → 0.7.1

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: 3242a48a3b7fe938a403c8e5585e3b1fa1e8c5ba444d0bd9d504410c1fb66d40
4
- data.tar.gz: d0687724e54eb42d206c41b9d22960249b8aef9adb30538c206950fdb0fc30a3
3
+ metadata.gz: ac93e4b9cc074bcacf3f6a1876bc7b3b64ed327b9311e38e06296bb0865326fd
4
+ data.tar.gz: 1cea1255adfd37b392788346126c47b280e77fbb6efc0e81315e7b136fed3731
5
5
  SHA512:
6
- metadata.gz: b5adab4e860c1a9948419654f467a0d7b3cace6c63d427f22906fe5c7bd63ed50944653cf0d1e63fc729ed36ca424b84252ac87694e2fb04d09372e6eb8b8ea3
7
- data.tar.gz: 43d1385804ba40942a75aaa4bf533f77beb920bb88f67568a9cc7cb230db609680869610096c0c198a44693849afd398e0a4d62e76fd1a26f20b2410bc2cb3fe
6
+ metadata.gz: 65ffbf0cf5faabd5ca15b6dece5e5f5c4be20b6667bac5d593cb529d85198611d9b3339e29acc3fe3751e93515f6a387317228b473ef62aa6854c0d8e3284930
7
+ data.tar.gz: febd6039248df0aa1c7ec14be94fe5656a16a393646cab3e1e9564aad73a168a5556584e8e14addc95757440cfca49130929e39ff8eb6dde166c9ae973c85e9c
data/CHANGELOG.md CHANGED
@@ -1,10 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.1]
4
+
5
+ - Update sound playback commands to run in the background with success status
6
+
7
+ ## [0.7.0]
8
+
9
+ _Released 2025-03-03_
10
+
11
+ - Add `quick-commit` command to commit staged changes with a generated message.
12
+
3
13
  ## [0.6.0]
4
14
 
5
15
  _Released 2025-01-07_
6
16
 
7
17
  - Allow specifying values on `convert-currency` command.
18
+
8
19
  ```sh
9
20
  $ convert-currency 100 usd eur
10
21
  ```
data/README.md CHANGED
@@ -54,6 +54,14 @@ $ puts 10.days.ago
54
54
  2024-08-17 15:50:11 -0300
55
55
  ```
56
56
 
57
+ ### [`quick-commit`](./lib/matheus/quick_commit.rb)
58
+
59
+ Commits the staged changes with a generated commit message.
60
+
61
+ ```sh
62
+ $ quick-commit
63
+ ```
64
+
57
65
  ## Contributing
58
66
 
59
67
  Probably not accepting contributions at the moment, but feel free to open an issue if you have any ideas or suggestions.
data/Rakefile CHANGED
@@ -46,4 +46,4 @@ end
46
46
  # Ensure the generate_executables task runs before the build task
47
47
  task build: :generate_executables
48
48
  # Ensure tests are run before releasing the gem
49
- task release: :spec
49
+ task build: :spec
data/exe/quick-commit ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
4
+
5
+ require "matheus"
6
+
7
+ Matheus::QuickCommit.call ARGV
@@ -9,9 +9,9 @@ module Matheus
9
9
  # Runs the command and plays a sound based on its success or failure after it finishes.
10
10
  def call(*args)
11
11
  if system(args.join(" ").presence || "true")
12
- system("afplay /System/Library/Sounds/Glass.aiff")
12
+ system("afplay /System/Library/Sounds/Glass.aiff & true")
13
13
  else
14
- system("afplay /System/Library/Sounds/Sosumi.aiff")
14
+ system("afplay /System/Library/Sounds/Sosumi.aiff & false")
15
15
  end
16
16
  rescue => e
17
17
  Failure(e.message)
@@ -5,9 +5,9 @@ module Matheus
5
5
  include Result::Methods
6
6
  extend StringFormat
7
7
 
8
- def self.call(argv)
8
+ def self.call(...)
9
9
  new
10
- .call(argv)
10
+ .call(...)
11
11
  .then { Result.from(_1) } # ensure it's a Result object
12
12
  .on_failure { |error_msg| abort error(error_msg) }
13
13
  end
data/lib/matheus/q.rb CHANGED
@@ -10,18 +10,18 @@ module Matheus
10
10
  class Q < Command
11
11
  BASE_PROMPT = "Answer this question in a short and concise way. You can use markdown in the response: "
12
12
 
13
- def call(question)
13
+ def call(*question, skip_cache: false)
14
14
  question = question.join(" ")
15
15
  existing_entry = search_question_in_history(question)
16
16
 
17
- if existing_entry && use_existing_answer?
17
+ if existing_entry && use_existing_answer?(skip_cache)
18
18
  answer = existing_entry["answer"]
19
19
  else
20
20
  answer = ask_llm(question)
21
21
  save_qa(question, answer)
22
22
  end
23
23
 
24
- print_markdown(answer)
24
+ answer.tap { |it| print_markdown(it) }
25
25
  rescue => e
26
26
  Failure(e.message)
27
27
  end
@@ -67,7 +67,9 @@ module Matheus
67
67
  load_history.reverse.find { |entry| entry["question"].downcase.strip == question.downcase.strip }
68
68
  end
69
69
 
70
- def use_existing_answer?
70
+ def use_existing_answer?(skip_cache)
71
+ return false if skip_cache
72
+
71
73
  prompt = TTY::Prompt.new
72
74
  prompt.yes?("An existing answer was found. Do you want to use it?") do |q|
73
75
  q.default true
@@ -0,0 +1,24 @@
1
+ module Matheus
2
+ class QuickCommit < Command
3
+ # Usage:
4
+ # $ quick-commit
5
+ def call(*)
6
+ diff = `git diff --cached`
7
+ return Failure("No changes to commit.") if diff.blank?
8
+
9
+ Q.call(["Please write a good one-line commit message for the following diff. Return only plain-text. Diff:\n#{diff}"], skip_cache: true)
10
+ .on_success { |msg| confirm("Accept commit message?", return_value: msg) }
11
+ .on_success { |commit_message| system(%(git commit -m "#{commit_message}"), out: :close) }
12
+ end
13
+
14
+ private
15
+
16
+ def confirm(message, return_value:)
17
+ response = TTY::Prompt.new.yes?(message) do |q|
18
+ q.default true
19
+ end
20
+
21
+ response ? Success(return_value) : Failure("Cancelled by user.")
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Matheus
4
- VERSION = "0.6.4"
4
+ VERSION = "0.7.1"
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.6.4
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Richard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -118,6 +118,7 @@ executables:
118
118
  - puts
119
119
  - q
120
120
  - qs
121
+ - quick-commit
121
122
  extensions: []
122
123
  extra_rdoc_files: []
123
124
  files:
@@ -133,6 +134,7 @@ files:
133
134
  - exe/puts
134
135
  - exe/q
135
136
  - exe/qs
137
+ - exe/quick-commit
136
138
  - lib/matheus.rb
137
139
  - lib/matheus/alert_me.rb
138
140
  - lib/matheus/command.rb
@@ -141,6 +143,7 @@ files:
141
143
  - lib/matheus/puts.rb
142
144
  - lib/matheus/q.rb
143
145
  - lib/matheus/qs.rb
146
+ - lib/matheus/quick_commit.rb
144
147
  - lib/matheus/result.rb
145
148
  - lib/matheus/string_format.rb
146
149
  - lib/matheus/version.rb