Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard #15

Merged
merged 12 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in errbit_plugin.gemspec
gemspec

gem "rake"
gem 'rspec'
gem "rspec"
gem "standard"
gem "simplecov", require: false
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.3)
diff-lcs (1.6.1)
docile (1.4.1)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
parallel (1.26.3)
parser (3.3.7.4)
ast (~> 2.4.1)
racc
prism (1.4.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.10.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -22,12 +34,46 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rubocop (1.75.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.44.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-performance (1.25.0)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
standard (1.49.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.75.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.8)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.8.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.25.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)

PLATFORMS
arm64-darwin-24
Expand All @@ -37,6 +83,7 @@ DEPENDENCIES
rake
rspec
simplecov
standard

BUNDLED WITH
2.6.7
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ErrbitPlugin

[![RSpec](https://github.com/errbit/errbit_plugin/actions/workflows/rspec.yml/badge.svg)](https://github.com/errbit/errbit_plugin/actions/workflows/rspec.yml)
[![RSpec on JRuby](https://github.com/errbit/errbit_plugin/actions/workflows/jruby.yml/badge.svg)](https://github.com/errbit/errbit_plugin/actions/workflows/jruby.yml)
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard)

ErrbitPlugin provides a set of base classes that you can extend to create
Errbit plugins.

Expand Down
25 changes: 12 additions & 13 deletions errbit_plugin.gemspec
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'errbit_plugin/version'
require "errbit_plugin/version"

Gem::Specification.new do |spec|
spec.name = "errbit_plugin"
spec.version = ErrbitPlugin::VERSION
spec.authors = ["Stephen Crosby"]
spec.email = ["[email protected]"]
spec.description = %q{Base to create an errbit plugin}
spec.summary = %q{Base to create an errbit plugin}
spec.homepage = "http://github.com/errbit/errbit"
spec.license = "MIT"
spec.name = "errbit_plugin"
spec.version = ErrbitPlugin::VERSION
spec.authors = ["Stephen Crosby"]
spec.email = ["[email protected]"]
spec.description = "Base to create an errbit plugin"
spec.summary = "Base to create an errbit plugin"
spec.homepage = "http://github.com/errbit/errbit"
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
end
50 changes: 37 additions & 13 deletions lib/errbit_plugin/issue_trackers/none.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,55 @@

module ErrbitPlugin
class NoneIssueTracker < IssueTracker
def self.label; 'none'; end
def self.label
"none"
end

def self.note
'When no issue tracker has been configured, you will be able to ' <<
'leave comments on errors.'
"When no issue tracker has been configured, you will be able to " <<
"leave comments on errors."
end

def self.fields
{}
end
def self.fields; {}; end

def self.icons
@icons ||= {
create: ['image/png', read_static_file('none_create.png')],
goto: ['image/png', read_static_file('none_create.png')],
inactive: ['image/png', read_static_file('none_inactive.png')],
create: ["image/png", read_static_file("none_create.png")],
goto: ["image/png", read_static_file("none_create.png")],
inactive: ["image/png", read_static_file("none_inactive.png")]
}
end

def self.read_static_file(file)
File.read(File.expand_path(File.join(
File.dirname(__FILE__), '..', '..', '..', 'static', file)))
File.dirname(__FILE__), "..", "..", "..", "static", file
)))
end

##
# The NoneIssueTracker is mark like configured? false because it not valid
# like a real IssueTracker
def configured?; false; end
def errors; {}; end
def url; ''; end
def create_issue(*); false; end
def close_issue(*); false; end
def configured?
false
end

def errors
{}
end

def url
""
end

def create_issue(*)
false
end

def close_issue(*)
false
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/errbit_plugin/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module ErrbitPlugin
class IncompatibilityError < StandardError; end

class AlreadyRegisteredError < StandardError; end

module Registry
Expand All @@ -20,7 +21,7 @@ def self.add_issue_tracker(klass)
if validate.valid?
@issue_trackers[key] = klass
else
raise IncompatibilityError.new(validate.errors.join('; '))
raise IncompatibilityError.new(validate.errors.join("; "))
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/errbit_plugin/validate_issue_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def valid?
private

def good_inherit?
unless @klass.ancestors.include?(ErrbitPlugin::IssueTracker)
if @klass.ancestors.include?(ErrbitPlugin::IssueTracker)
true
else
add_errors(:not_inherited)
false
else
true
end
end

Expand Down Expand Up @@ -57,7 +57,7 @@ def instance
@instance ||= @klass.new({})
end

def add_errors(key, value=nil)
def add_errors(key, value = nil)
@errors << [key, value].compact
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/errbit_plugin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ErrbitPlugin
VERSION = '0.7.0'
VERSION = "0.7.0"
end
22 changes: 11 additions & 11 deletions spec/errbit_plugin/registry_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require "spec_helper"

describe ErrbitPlugin::Registry do
before do
Expand All @@ -10,7 +10,7 @@
let(:tracker) {
tracker = Class.new(ErrbitPlugin::IssueTracker) do
def self.label
'something'
"something"
end
end
tracker
Expand All @@ -22,16 +22,16 @@ def self.label
allow(ErrbitPlugin::ValidateIssueTracker)
.to receive(:new)
.with(tracker)
.and_return(double(:valid? => true, :message => ''))
.and_return(double(valid?: true, message: ""))
end
it 'add new issue_tracker plugin' do
it "add new issue_tracker plugin" do
ErrbitPlugin::Registry.add_issue_tracker(tracker)
expect(ErrbitPlugin::Registry.issue_trackers).to eq({
'something' => tracker
"something" => tracker
})
end
context "with already issue_tracker with this key" do
it 'raise ErrbitPlugin::AlreadyRegisteredError' do
it "raise ErrbitPlugin::AlreadyRegisteredError" do
ErrbitPlugin::Registry.add_issue_tracker(tracker)
expect {
ErrbitPlugin::Registry.add_issue_tracker(tracker)
Expand All @@ -41,26 +41,26 @@ def self.label
end

context "with an IssueTracker not valid" do
it 'raise an IncompatibilityError' do
it "raise an IncompatibilityError" do
allow(ErrbitPlugin::ValidateIssueTracker)
.to receive(:new)
.with(tracker)
.and_return(double(:valid? => false, :message => 'foo', :errors => []))
.and_return(double(valid?: false, message: "foo", errors: []))
expect {
ErrbitPlugin::Registry.add_issue_tracker(tracker)
}.to raise_error(ErrbitPlugin::IncompatibilityError)
end

it 'puts the errors in the exception message' do
it "puts the errors in the exception message" do
allow(ErrbitPlugin::ValidateIssueTracker)
.to receive(:new)
.with(tracker)
.and_return(double(:valid? => false, :message => 'foo', :errors => ['one', 'two']))
.and_return(double(valid?: false, message: "foo", errors: ["one", "two"]))

begin
ErrbitPlugin::Registry.add_issue_tracker(tracker)
rescue ErrbitPlugin::IncompatibilityError => e
expect(e.message).to eq('one; two')
expect(e.message).to eq("one; two")
end
end
end
Expand Down
Loading