Skip to content

Commit

Permalink
add Rubocop with omakse rules, correct them, add to gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Dec 28, 2024
1 parent f9b4be7 commit 0a87253
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 110 deletions.
46 changes: 31 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ on:
- main

jobs:
rubocop:
name: RuboCop
runs-on: ubuntu-latest
env:
BUNDLE_ONLY: rubocop
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
- name: Run Rubocop
run: bundle exec rubocop --parallel
test:
name: ${{ format('Unit tests (Ruby {0})', matrix.ruby-version) }}
runs-on: ubuntu-latest
Expand All @@ -21,18 +36,19 @@ jobs:
- "3.4"
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Set up Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Configure Git
run: |
git config --global user.name $NAME
git config --global user.email $EMAIL
env:
NAME: "George Costanza"
EMAIL: "[email protected]"
- name: Run tests
run: bundle exec rake test
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Configure Git
run: |
git config --global user.name $NAME
git config --global user.email $EMAIL
env:
NAME: "George Costanza"
EMAIL: "[email protected]"
- name: Run tests
run: bundle exec rake test
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_gem:
rubocop-rails-omakase: rubocop.yml
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
source 'https://rubygems.org'
source "https://rubygems.org"
gemspec

group :rubocop do
gem "rubocop-rails-omakase", require: false
end
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/*_test.rb"]
end

task :default => ['test']
task default: [ "test" ]
4 changes: 2 additions & 2 deletions lib/lolcommits/plugin/tranzlate.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'lolcommits/plugin/base'
require 'lolcommits/tranzlate/lolspeak'
require "lolcommits/plugin/base"
require "lolcommits/tranzlate/lolspeak"

module Lolcommits
module Plugin
Expand Down
4 changes: 2 additions & 2 deletions lib/lolcommits/tranzlate.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

require 'lolcommits/tranzlate/version'
require 'lolcommits/plugin/tranzlate'
require "lolcommits/tranzlate/version"
require "lolcommits/plugin/tranzlate"
151 changes: 75 additions & 76 deletions lib/lolcommits/tranzlate/lolspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,81 @@
module Lolcommits
module Tranzlate
module Lolspeak

# Adapted and expanded from https://github.com/rwtnorton/moar-lolspeak
LOL_DICTIONARY = {
/what/ => %w(wut whut),
/you\b/ => %w(yu yous yoo u yooz),
/cture/ => %w(kshur),
/ss\b/ => %w(s zz z),
/the\b/ => %w(teh),
/more/ => %w(moar),
/my/ => %w(mah mai),
/are/ => %w(is ar),
/eese/ => %w(eez),
/ph/ => %w(f),
/as\b/ => %w(az),
/seriously/ => %w(srsly),
/sion/ => %w(shun),
/just/ => %w(jus),
/ose\b/ => %w(oze),
/eady/ => %w(eddy),
/ome?\b/ => %w(um),
/of\b/ => %w(of ov of),
/uestion/ => %w(wesjun),
/want/ => %w(wants),
/ead\b/ => %w(edd),
/ck/ => %w(kk kkk),
/cat|kitten|kitty/ => %w(kitteh kittehz cat fuzzeh fuzzyrumpus foozles fuzzbut fluffernutter beast mew),
/eak/ => %w(ekk),
/age/ => %w(uj),
/like/ => %w(likez liek licks),
/love/ => %w(lovez lub lubs luv lurve lurves),
/\bis\b/ => ['ar teh', 'ar'],
/nd\b/ => %w(n n'),
/who/ => %w(hoo),
/'/ => [''],
/ese\b/ => %w(eez),
/outh/ => %w(owf),
/scio/ => %w(shu),
/esque/ => %w(esk),
/ture/ => %w(chur),
/\btoo?\b/ => %w(to t 2 to t),
/tious/ => %w(shus),
/sure\b/ => %w(shur),
/tty\b/ => %w(tteh),
/were/ => %w(was),
/ok\b|okay/ => %w(kthxbye!),
/\ba\b/ => %w(uh),
/ym/ => %w(im),
/fish/ => %w(ghoti),
/thy\b/ => %w(fee),
/\wly\w/ => %w(li),
/que\w/ => %w(kwe),
/\both/ => %w(udd),
/though\b/ => %w(tho),
/(t|r|en)ough/ => %w(\1uff),
/ought/ => %w(awt),
/ease/ => %w(eez),
/ing\b/ => %w(in ins ng ing in'),
/have/ => ['haz', 'hav', 'haz a'],
/has/ => %w(haz gots),
/your/ => %w(yur ur yore yoar),
/ove\b/ => %w(oov ove uuv uv oove),
/for/ => %w(for 4 fr fur for foar),
/thank/ => %w(fank tank thx thnx),
/good/ => %w(gud goed guud gude gewd goot gut),
/really/ => %w(rly rily rilly rilleh),
/world/ => %w(wurrld whirld wurld wrld),
/i'?m\b/ => ['im', 'i yam', 'i iz'],
/(?!e)ight/ => %w(ite),
/(?!ues)tion/ => %w(shun),
/you'?re/ => %w(yore yr),
/er\b|are|ere/ => %w(r),
/y\b|ey\b/ => %w(eh),
/ea/ => %w(ee),
/can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => ['i can haz'],
/(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/ => ['oh hai,'],
/(?:god\b|allah|buddah?|diety|lord)/ => ['ceiling cat']
/what/ => %w[wut whut],
/you\b/ => %w[yu yous yoo u yooz],
/cture/ => %w[kshur],
/ss\b/ => %w[s zz z],
/the\b/ => %w[teh],
/more/ => %w[moar],
/my/ => %w[mah mai],
/are/ => %w[is ar],
/eese/ => %w[eez],
/ph/ => %w[f],
/as\b/ => %w[az],
/seriously/ => %w[srsly],
/sion/ => %w[shun],
/just/ => %w[jus],
/ose\b/ => %w[oze],
/eady/ => %w[eddy],
/ome?\b/ => %w[um],
/of\b/ => %w[of ov of],
/uestion/ => %w[wesjun],
/want/ => %w[wants],
/ead\b/ => %w[edd],
/ck/ => %w[kk kkk],
/cat|kitten|kitty/ => %w[kitteh kittehz cat fuzzeh fuzzyrumpus foozles fuzzbut fluffernutter beast mew],
/eak/ => %w[ekk],
/age/ => %w[uj],
/like/ => %w[likez liek licks],
/love/ => %w[lovez lub lubs luv lurve lurves],
/\bis\b/ => [ "ar teh", "ar" ],
/nd\b/ => %w[n n'],
/who/ => %w[hoo],
/'/ => [ "" ],
/ese\b/ => %w[eez],
/outh/ => %w[owf],
/scio/ => %w[shu],
/esque/ => %w[esk],
/ture/ => %w[chur],
/\btoo?\b/ => %w[to t 2 to t],
/tious/ => %w[shus],
/sure\b/ => %w[shur],
/tty\b/ => %w[tteh],
/were/ => %w[was],
/ok\b|okay/ => %w[kthxbye!],
/\ba\b/ => %w[uh],
/ym/ => %w[im],
/fish/ => %w[ghoti],
/thy\b/ => %w[fee],
/\wly\w/ => %w[li],
/que\w/ => %w[kwe],
/\both/ => %w[udd],
/though\b/ => %w[tho],
/(t|r|en)ough/ => %w[\1uff],
/ought/ => %w[awt],
/ease/ => %w[eez],
/ing\b/ => %w[in ins ng ing in'],
/have/ => [ "haz", "hav", "haz a" ],
/has/ => %w[haz gots],
/your/ => %w[yur ur yore yoar],
/ove\b/ => %w[oov ove uuv uv oove],
/for/ => %w[for 4 fr fur for foar],
/thank/ => %w[fank tank thx thnx],
/good/ => %w[gud goed guud gude gewd goot gut],
/really/ => %w[rly rily rilly rilleh],
/world/ => %w[wurrld whirld wurld wrld],
/i'?m\b/ => [ "im", "i yam", "i iz" ],
/(?!e)ight/ => %w[ite],
/(?!ues)tion/ => %w[shun],
/you'?re/ => %w[yore yr],
/er\b|are|ere/ => %w[r],
/y\b|ey\b/ => %w[eh],
/ea/ => %w[ee],
/can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => [ "i can haz" ],
/(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/ => [ "oh hai," ],
/(?:god\b|allah|buddah?|diety|lord)/ => [ "ceiling cat" ]
}.freeze

def tranzlate(str)
Expand All @@ -87,8 +86,8 @@ def tranzlate(str)
lolstr.gsub!(english, lolspeak.sample)
end

lolstr << '! kthxbye!' if rand(10) == 2
lolstr.gsub!(/(\?|!|,|\.)+/, '!')
lolstr << "! kthxbye!" if rand(10) == 2
lolstr.gsub!(/(\?|!|,|\.)+/, "!")

lolstr.upcase
end
Expand Down
10 changes: 5 additions & 5 deletions lolcommits-tranzlate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ require 'lolcommits/tranzlate/version'
Gem::Specification.new do |spec|
spec.name = "lolcommits-tranzlate"
spec.version = Lolcommits::Tranzlate::VERSION
spec.authors = ["Matthew Hutchinson"]
spec.email = ["[email protected]"]
spec.summary = %q{lolcommits lolspekk tranzlation plugin}
spec.authors = [ "Matthew Hutchinson" ]
spec.email = [ "[email protected]" ]
spec.summary = %q(lolcommits lolspekk tranzlation plugin)
spec.homepage = "https://github.com/lolcommits/lolcommits-tranzlate"
spec.license = "LGPL-3.0"
spec.description = %q{TRANZLATE YOAR LOLCOMMIT MSG TO LOLSPEKK}
spec.description = %q(TRANZLATE YOAR LOLCOMMIT MSG TO LOLSPEKK)

spec.metadata = {
"homepage_uri" => "https://github.com/lolcommits/lolcommits-tranzlate",
Expand All @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
spec.bindir = "bin"
spec.executables = []
spec.require_paths = ["lib"]
spec.require_paths = [ "lib" ]

spec.required_ruby_version = ">= 3.1"
spec.add_runtime_dependency "lolcommits", ">= 0.17.2"
Expand Down
4 changes: 2 additions & 2 deletions test/lolcommits/plugin/tranzlate_test.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'test_helper'
require "test_helper"

class TestLolcommitsPluginTranzlate < Minitest::Test
include Lolcommits::TestHelpers::GitRepo
include Lolcommits::TestHelpers::FakeIO

def test_enabled_returns_false_by_default
refute plugin.enabled?
assert_equal false, plugin.enabled?
end

def test_enabled_returns_true_when_configured
Expand Down
12 changes: 6 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

# lolcommits gem
require 'lolcommits'
require "lolcommits"

# lolcommit test helpers
require 'lolcommits/test_helpers/git_repo'
require 'lolcommits/test_helpers/fake_io'
require "lolcommits/test_helpers/git_repo"
require "lolcommits/test_helpers/fake_io"

# plugin gem test libs
require 'lolcommits/tranzlate'
require 'minitest/autorun'
require "lolcommits/tranzlate"
require "minitest/autorun"

# swallow all debug output during test runs
def debug(msg); end

0 comments on commit 0a87253

Please sign in to comment.