-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
dff2cd5
commit 240a30e
Showing
12 changed files
with
181 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Create MPUtils Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
bump_version: | ||
description: 'Define the version number to bump' | ||
required: true | ||
default: patch | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
tests: | ||
secrets: inherit | ||
uses: ./.github/workflows/ruby-tests.yml | ||
bump_version: | ||
secrets: inherit | ||
uses: ./.github/workflows/bump-version.yml | ||
with: | ||
bump_version: ${{ inputs.bump_version }} | ||
publish_gem: | ||
needs: bump_version | ||
secrets: inherit | ||
uses: ./.github/workflows/publish-gem.yml | ||
documentation: | ||
needs: publish_gem | ||
secrets: inherit | ||
uses: ./.github/workflows/create-doc-page.yml | ||
# git_release: | ||
# needs: publish_gem | ||
# secrets: inherit | ||
# uses: ./.github/workflows/create-git-release.yml | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Create a release for the gem | ||
name: Publish Gem in ruby Gems | ||
|
||
on: | ||
workflow_dispatch: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'question' | ||
require_relative 'message' | ||
require_relative 'ansi' | ||
require_relative 'key' | ||
|
||
# This class provides additional methods to the standard Ruby String class, | ||
# allowing for the removal of ANSI codes, and conversion to Key, Question, | ||
# and Message objects. | ||
class String | ||
# Removes ANSI escape codes from the string. | ||
# | ||
# @return [String] a new string with ANSI codes removed. | ||
def remove_ansi | ||
ANSI.remove_from_string(self) | ||
end | ||
|
||
# Converts the string to a Key object. | ||
# | ||
# @return [Key] a new Key object initialized with the string. | ||
def to_key | ||
Key.new(self) | ||
end | ||
|
||
# Converts the string to a Question object. | ||
# | ||
# @return [Question] a new Question object initialized with the string. | ||
def to_question | ||
Question.new(self) | ||
end | ||
|
||
# Converts the string to a Message object. | ||
# | ||
# @param replaces [Hash, nil] optional replacements to be applied in the message. | ||
# @return [Message] a new Message object initialized with the string and optional replacements. | ||
def to_message(replaces: nil) | ||
Message.new(self, replaces: replaces) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../lib/utils/string' | ||
|
||
RSpec.describe String do | ||
describe '#remove_ansi' do | ||
it 'removes ANSI escape codes from the string' do | ||
string_with_ansi = "\e[31mHello\e[0m World" | ||
expect(string_with_ansi.remove_ansi).to eq('Hello World') | ||
end | ||
|
||
it 'returns the same string if there are no ANSI codes' do | ||
plain_string = 'Hello World' | ||
expect(plain_string.remove_ansi).to eq('Hello World') | ||
end | ||
end | ||
|
||
describe '#to_key' do | ||
it 'converts the string to a Key object' do | ||
string = 'my_key' | ||
key = string.to_key | ||
expect(key).to be_a(Key) | ||
expect(key.value).to eq('my_key') | ||
end | ||
end | ||
|
||
describe '#to_question' do | ||
it 'converts the string to a Question object' do | ||
string = 'Is this a question?' | ||
question = string.to_question | ||
expect(question).to be_a(Question) | ||
end | ||
end | ||
|
||
describe '#to_message' do | ||
it 'converts the string to a Message object without replacements' do | ||
string = 'This is a message' | ||
message = string.to_message | ||
expect(message).to be_a(Message) | ||
expect(message.message).to eq('This is a message') | ||
end | ||
|
||
it 'converts the string to a Message object with replacements' do | ||
string = 'Hello, <||name||>s' | ||
replacements = { name: 'Alice' } | ||
message = string.to_message(replaces: replacements) | ||
expect(message).to be_a(Message) | ||
expect(message.message).to eq(string) | ||
end | ||
end | ||
end |