diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 19d0d2f..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Tests - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - ruby-version: ['3.1', '3.2', '3.3', '3.4'] - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true - - name: Configure git user name, email - run: | - git config --global user.name $NAME - git config --global user.email $EMAIL - env: - NAME: "George Costanza" - EMAIL: "george.costanza@vandelay.com" - - name: Run tests - run: bundle exec rake test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..662a8fd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI +permissions: + contents: read + +on: + push: + branches: + - main + pull_request: + branches: + - 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 + strategy: + matrix: + ruby-version: + - "3.1" + - "3.2" + - "3.3" + - "3.4" + continue-on-error: true + steps: + - 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: "george.costanza@vandelay.com" + - name: Run tests + run: bundle exec rake test diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml deleted file mode 100644 index d974f13..0000000 --- a/.github/workflows/push_gem.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Publish gem to RubyGems.org - -on: - push: - tags: - - v* - -jobs: - push: - name: Push gem to RubyGems.org - runs-on: ubuntu-latest - - permissions: - id-token: write - contents: write - - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: ruby - - - uses: rubygems/release-gem@v1 diff --git a/.quickhook/pre-commit/ruby-lint b/.quickhook/pre-commit/ruby-lint new file mode 100755 index 0000000..fcf3f0f --- /dev/null +++ b/.quickhook/pre-commit/ruby-lint @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +grep -E "\.rb$|Rakefile|Gemfile" | xargs ./bin/rubocop --config .rubocop.yml --force-exclusion diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..dc9c9b4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +inherit_gem: + rubocop-rails-omakase: rubocop.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f49c14..faf6a18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ project adheres to [Semantic Versioning][Semver]. - Your contribution here! +## [0.5.1] - 2024-12-29 +### Changed +- Push gems with bundler (not GitHub actions) +- Updated documentation links + ## [0.5.0] - 2024-09-20 ### Removed - Support for Ruby < 3.1 (older rubies no longer supported) @@ -88,7 +93,8 @@ lolcommits 0.14.0) ### Changed - Initial release (Yanked) -[Unreleased]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.5.0...HEAD +[Unreleased]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.5.1...HEAD +[0.5.1]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.5.0...v0.5.1 [0.5.0]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.3.0...v0.4.0 [0.3.0]: https://github.com/lolcommits/lolcommits-loltext/compare/v0.2.1...v0.3.0 diff --git a/Gemfile b/Gemfile index 851fabc..b816373 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,6 @@ -source 'https://rubygems.org' +source "https://rubygems.org" gemspec + +group :rubocop do + gem "rubocop-rails-omakase", require: false +end diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index ebbcad3..0000000 --- a/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,16 +0,0 @@ - -Explain what you're changing and why here. - ---- -#### :memo: Checklist - -Please check this list and leave it intact for the reviewer. Thanks! :heart: - -- [ ] Commit messages to provide context (why not just what, some tips [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)). -- [ ] If relevant, mention GitHub issue number above and include in a commit message. -- [ ] Latest code from master merged. -- [ ] New behaviour has test coverage. -- [ ] Avoid duplicating code. -- [ ] No commented out code. -- [ ] Avoid comments for your code, write code that explains itself. -- [ ] Changes are simple, useful, clear and brief. diff --git a/README.md b/README.md index 73d40c9..5dedfec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Lolcommits Loltext -[![Build](https://img.shields.io/github/actions/workflow/status/lolcommits/lolcommits-loltext/build.yml?branch=main&style=flat)](https://github.com/lolcommits/lolcommits-loltext/actions/workflows/build.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/lolcommits/lolcommits-loltext/ci.yml?branch=main&style=flat&label=CI)](https://github.com/lolcommits/lolcommits-loltext/actions/workflows/ci.yml) [![Gem](https://img.shields.io/gem/v/lolcommits-loltext.svg?style=flat)](http://rubygems.org/gems/lolcommits-loltext) [![Depfu](https://img.shields.io/depfu/lolcommits/lolcommits-loltext.svg?style=flat)](https://depfu.com/github/lolcommits/lolcommits-loltext) @@ -8,9 +8,9 @@ webcam every time you git commit code, and archives a lolcat style image with it. Git blame has never been so much fun! -This plugin annotates each lolcommit with the commit message and sha -text. You can style and position these however you like, or add a -transparent overlay color that covers the entire image. +This plugin annotates each lolcommit with the commit message and sha text. You +can style and position these however you like, or add a transparent overlay +color that covers the entire image. By default your lolcommit will look something like this (maybe without the horse): @@ -35,15 +35,14 @@ more information on the options available. ## Installation -By default, this plugin is automatically included with the main -lolcommits gem. If you have uninstalled this gem, install it again -with: +By default, this plugin is automatically included with the main lolcommits gem. +If you have uninstalled this gem, install it again with: $ gem install lolcommits-loltext -That's it! Every lolcommit will now be stamped with your commit message -and sha. This plugin is enabled by default (if no configuration for it -exists). To disable (so no text or overlay is applied) use: +That's it! Every lolcommit will now be stamped with your commit message and sha. +This plugin is enabled by default (if no configuration for it exists). To +disable (so no text or overlay is applied) use: $ lolcommits --config -p loltext # and set enabled to `false` @@ -75,10 +74,10 @@ Please note that: * Colors can be hex values (#FC0) or strings (white, red etc.) * You can set one or more `overlay_colors` to pick from, separated with commas -With these options it is possible to create your own unique lolcommit -format. To achieve these '[hipster -styled](https://twitter.com/matthutchin/status/738411190343368704)' 🕶 -commits, try the following: +With these options it is possible to create your own unique lolcommit format. +To achieve these '[hipster +styled](https://twitter.com/matthutchin/status/738411190343368704)' 🕶 commits, +try the following: ``` loltext: @@ -111,8 +110,8 @@ loltext: Check out this repo and run `bin/setup`, to install all dependencies and generate docs. Run `bundle exec rake` to run all tests. -You can also run `bin/console` for an interactive prompt that will allow -you to experiment with the gem code. +You can also run `bin/console` for an interactive prompt that will allow you to +experiment with the gem code. ## Tests @@ -129,26 +128,23 @@ Generate docs for this gem with: ## Troubles? If you think something is broken or missing, please raise a new -[issue](https://github.com/lolcommits/lolcommits-loltext/issues). Take a -moment to check it hasn't been raised in the past (and possibly closed). +[issue](https://github.com/lolcommits/lolcommits-loltext/issues). Take a moment +to check it hasn't been raised in the past (and possibly closed). ## Contributing -Bug [reports](https://github.com/lolcommits/lolcommits-loltext/issues) -and [pull -requests](https://github.com/lolcommits/lolcommits-loltext/pulls) are -welcome on GitHub. +Bug [reports](https://github.com/lolcommits/lolcommits-loltext/issues) and [pull +requests](https://github.com/lolcommits/lolcommits-loltext/pulls) are welcome on +GitHub. -When submitting pull requests, remember to add tests covering any new -behaviour, and ensure all tests are passing. Read the -[contributing +When submitting pull requests, remember to add tests covering any new behaviour, +and ensure all tests are passing. Read the [contributing guidelines](https://github.com/lolcommits/lolcommits-loltext/blob/master/CONTRIBUTING.md) for more details. -This project is intended to be a safe, welcoming space for -collaboration, and contributors are expected to adhere to the -[Contributor Covenant](http://contributor-covenant.org) code of conduct. -See +This project is intended to be a safe, welcoming space for collaboration, and +contributors are expected to adhere to the [Contributor +Covenant](http://contributor-covenant.org) code of conduct. See [here](https://github.com/lolcommits/lolcommits-loltext/blob/master/CODE_OF_CONDUCT.md) for more details. @@ -159,7 +155,7 @@ The gem is available as open source under the terms of ## Links -* [CI](https://github.com/lolcommits/lolcommits-loltext/actions/workflows/build.yml) +* [CI](https://github.com/lolcommits/lolcommits-loltext/actions/workflows/ci.yml) * [RDoc](http://rdoc.info/projects/lolcommits/lolcommits-loltext) * [Issues](http://github.com/lolcommits/lolcommits-loltext/issues) * [Report a bug](http://github.com/lolcommits/lolcommits-loltext/issues/new) diff --git a/Rakefile b/Rakefile index 620bfa7..b2487de 100644 --- a/Rakefile +++ b/Rakefile @@ -18,4 +18,4 @@ Rake::TestTask.new(:test) do |t| t.test_files = FileList["test/**/*_test.rb"] end -task :default => ['test'] +task default: [ 'test' ] diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..397dc4f --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler/setup" +load Gem.bin_path("rubocop", "rubocop") diff --git a/lib/lolcommits/loltext.rb b/lib/lolcommits/loltext.rb index a6a6a12..f3d21e4 100644 --- a/lib/lolcommits/loltext.rb +++ b/lib/lolcommits/loltext.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -require 'lolcommits/loltext/version' -require 'lolcommits/plugin/loltext' +require "lolcommits/loltext/version" +require "lolcommits/plugin/loltext" diff --git a/lib/lolcommits/loltext/version.rb b/lib/lolcommits/loltext/version.rb index 57255ea..5beb416 100644 --- a/lib/lolcommits/loltext/version.rb +++ b/lib/lolcommits/loltext/version.rb @@ -2,6 +2,6 @@ module Lolcommits module Loltext - VERSION = "0.5.0".freeze + VERSION = "0.5.1".freeze end end diff --git a/lib/lolcommits/plugin/loltext.rb b/lib/lolcommits/plugin/loltext.rb index 3d102bb..90e31f6 100644 --- a/lib/lolcommits/plugin/loltext.rb +++ b/lib/lolcommits/plugin/loltext.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'lolcommits/plugin/base' +require "lolcommits/plugin/base" module Lolcommits module Plugin class Loltext < Base - DEFAULT_FONT_PATH = File.join( File.dirname(__FILE__), "../../../vendor/fonts/Impact.ttf" ).freeze @@ -17,7 +16,7 @@ class Loltext < Base # @return [Array] the position(s) (:post_capture) # def self.runner_order - [:post_capture] + [ :post_capture ] end ## @@ -48,18 +47,18 @@ def valid_configuration? # @return [Hash] a hash of configured plugin options # def configure_options! - puts '---------------------------------------------------------------' - puts ' LolText options ' - puts '' - puts ' * any blank options will use the (default)' - puts ' * always use the full absolute path to fonts' - puts ' * valid text positions are NE, NW, SE, SW, S, C (centered)' - puts ' * colors can be hex #FC0 value or a string \'white\'' - puts ' - use `none` for no stroke color' - puts ' * overlay fills your image with a random color' - puts ' - set one or more overlay_colors with a comma seperator' - puts ' - overlay_percent (0-100) sets the fill colorize strength' - puts '---------------------------------------------------------------' + puts "---------------------------------------------------------------" + puts " LolText options " + puts "" + puts " * any blank options will use the (default)" + puts " * always use the full absolute path to fonts" + puts " * valid text positions are NE, NW, SE, SW, S, C (centered)" + puts " * colors can be hex #FC0 value or a string 'white'" + puts " - use `none` for no stroke color" + puts " * overlay fills your image with a random color" + puts " - set one or more overlay_colors with a comma seperator" + puts " - overlay_percent (0-100) sets the fill colorize strength" + puts "---------------------------------------------------------------" super end @@ -74,13 +73,13 @@ def configure_options! def run_post_capture debug "creating annotation overlay with MiniMagick" if config_option(:overlay, :enabled) - color = config_option(:overlay, :overlay_colors).split(',').map(&:strip).sample + color = config_option(:overlay, :overlay_colors).split(",").map(&:strip).sample overlay_percent = config_option(:overlay, :overlay_percent).to_f debug "adding colorized overlay (#{color} at #{overlay_percent}% opacity)" overlay_percent = (255 * (overlay_percent/100)).round runner.overlay.combine_options do |c| - c.fill "#{color}#{sprintf('%02X',overlay_percent)}" + c.fill "#{color}#{sprintf('%02X', overlay_percent)}" c.draw "color 0,0 reset" end end @@ -106,7 +105,7 @@ def annotate(image, type, string) debug("annotating #{type} text (#{string})") transformed_position = position_transform(config_option(type, :position)) - annotate_location = '0' + annotate_location = "0" padded_annotation = 10 if config_option(:border, :enabled) @@ -141,34 +140,34 @@ def annotate(image, type, string) def default_options { message: { - color: 'white', + color: "white", font: DEFAULT_FONT_PATH, - position: 'SW', + position: "SW", size: 48, - stroke_color: 'black', + stroke_color: "black", uppercase: false }, sha: { - color: 'white', + color: "white", font: DEFAULT_FONT_PATH, - position: 'NE', + position: "NE", size: 32, - stroke_color: 'black', + stroke_color: "black", uppercase: false }, overlay: { enabled: false, overlay_colors: [ - '#2e4970', '#674685', '#ca242f', '#1e7882', '#2884ae', '#4ba000', - '#187296', '#7e231f', '#017d9f', '#e52d7b', '#0f5eaa', '#e40087', - '#5566ac', '#ed8833', '#f8991c', '#408c93', '#ba9109' - ].join(','), + "#2e4970", "#674685", "#ca242f", "#1e7882", "#2884ae", "#4ba000", + "#187296", "#7e231f", "#017d9f", "#e52d7b", "#0f5eaa", "#e40087", + "#5566ac", "#ed8833", "#f8991c", "#408c93", "#ba9109" + ].join(","), overlay_percent: 50 }, border: { enabled: false, - color: 'white', - size: 10, + color: "white", + size: 10 } } end @@ -176,18 +175,18 @@ def default_options # explode psuedo-names for text positioning def position_transform(position) case position - when 'NE' - 'NorthEast' - when 'NW' - 'NorthWest' - when 'SE' - 'SouthEast' - when 'SW' - 'SouthWest' - when 'C' - 'Center' - when 'S' - 'South' + when "NE" + "NorthEast" + when "NW" + "NorthWest" + when "SE" + "SouthEast" + when "SW" + "SouthWest" + when "C" + "Center" + when "S" + "South" end end diff --git a/lolcommits-loltext.gemspec b/lolcommits-loltext.gemspec index e96344e..41dec1c 100644 --- a/lolcommits-loltext.gemspec +++ b/lolcommits-loltext.gemspec @@ -5,9 +5,9 @@ require 'lolcommits/loltext/version' Gem::Specification.new do |spec| spec.name = "lolcommits-loltext" spec.version = Lolcommits::Loltext::VERSION - spec.authors = ["Matthew Hutchinson"] - spec.email = ["matt@hiddenloop.com"] - spec.summary = %q{lolcommits commit message annotation plugin} + spec.authors = [ "Matthew Hutchinson" ] + spec.email = [ "matt@hiddenloop.com" ] + spec.summary = %q(lolcommits commit message annotation plugin) spec.homepage = "https://github.com/lolcommits/lolcommits-loltext" spec.license = "LGPL-3.0" @@ -28,11 +28,11 @@ 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_development_dependency "lolcommits", ">= 0.17.0" + spec.add_development_dependency "lolcommits", ">= 0.17.2" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" spec.add_development_dependency "minitest" diff --git a/test/lolcommits/plugin/loltext_test.rb b/test/lolcommits/plugin/loltext_test.rb index ceae3fe..617d5e4 100644 --- a/test/lolcommits/plugin/loltext_test.rb +++ b/test/lolcommits/plugin/loltext_test.rb @@ -1,16 +1,15 @@ # frozen_string_literal: true -require 'test_helper' +require "test_helper" describe Lolcommits::Plugin::Loltext do - include Lolcommits::TestHelpers::FakeIO - it 'should run on post capturing' do - _(::Lolcommits::Plugin::Loltext.runner_order).must_equal [:post_capture] + it "should run on post capturing" do + _(::Lolcommits::Plugin::Loltext.runner_order).must_equal [ :post_capture ] end - describe 'with a runner' do + describe "with a runner" do def runner # a simple lolcommits runner with an empty configuration Hash @runner ||= Lolcommits::Runner.new @@ -24,66 +23,66 @@ def valid_enabled_config { enabled: true } end - describe 'initalizing' do - it 'should assign runner and an enabled option' do + describe "initalizing" do + it "should assign runner and an enabled option" do _(plugin.runner).must_equal runner - _(plugin.options).must_equal [:enabled] + _(plugin.options).must_equal [ :enabled ] end end - describe '#enabled?' do - it 'should be true by default' do + describe "#enabled?" do + it "should be true by default" do _(plugin.enabled?).must_equal true end - it 'should true when configured' do + it "should true when configured" do plugin.configuration = valid_enabled_config _(plugin.enabled?).must_equal true end end - describe 'configuration' do - it 'should allow plugin options to be configured' do + describe "configuration" do + it "should allow plugin options to be configured" do # enabled - inputs = ['true'] + inputs = [ "true" ] # styling message and sha - inputs += %w( + inputs += %w[ red myfont.ttf SE 38 orange true - ) * 2 + ] * 2 # styling overlay - inputs += %w(true #2884ae,#7e231f 40) + inputs += %w[true #2884ae,#7e231f 40] # border options - inputs += %w(true #e96d46 23) + inputs += %w[true #e96d46 23] configured_plugin_options = {} fake_io_capture(inputs: inputs) do configured_plugin_options = plugin.configure_options! end - _(configured_plugin_options).must_equal( { + _(configured_plugin_options).must_equal({ enabled: true, message: { - color: 'red', - font: 'myfont.ttf', - position: 'SE', + color: "red", + font: "myfont.ttf", + position: "SE", size: 38, - stroke_color: 'orange', + stroke_color: "orange", uppercase: true }, sha: { - color: 'red', - font: 'myfont.ttf', - position: 'SE', + color: "red", + font: "myfont.ttf", + position: "SE", size: 38, - stroke_color: 'orange', + stroke_color: "orange", uppercase: true }, overlay: { @@ -93,18 +92,18 @@ def valid_enabled_config }, border: { enabled: true, - color: '#e96d46', - size: 23, + color: "#e96d46", + size: 23 } }) end - describe '#valid_configuration?' do - it 'should be true even if config is not set' do + describe "#valid_configuration?" do + it "should be true even if config is not set" do _(plugin.valid_configuration?).must_equal(true) end - it 'should be true for a valid configuration' do + it "should be true for a valid configuration" do plugin.configuration = valid_enabled_config _(plugin.valid_configuration?).must_equal true end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3a7cbda..803e22b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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/loltext' -require 'minitest/autorun' +require "lolcommits/loltext" +require "minitest/autorun" # swallow all debug output during test runs def debug(msg); end