Skip to content

Commit a904ef1

Browse files
authored
Standard (#15)
* Add standard gem * Standard * Standard * Add RSpec badge * Add RSpec on JRuby badge * Add standard badge * Standard * Standard * Standard * Standard * Standard * Standard
1 parent 1ca62ec commit a904ef1

File tree

11 files changed

+502
-166
lines changed

11 files changed

+502
-166
lines changed

Gemfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
source "https://rubygems.org"
44

55
# Specify your gem's dependencies in errbit_plugin.gemspec
66
gemspec
77

88
gem "rake"
9-
gem 'rspec'
9+
gem "rspec"
10+
gem "standard"
1011
gem "simplecov", require: false

Gemfile.lock

+47
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9+
ast (2.4.3)
910
diff-lcs (1.6.1)
1011
docile (1.4.1)
12+
json (2.10.2)
13+
language_server-protocol (3.17.0.4)
14+
lint_roller (1.1.0)
15+
parallel (1.26.3)
16+
parser (3.3.7.4)
17+
ast (~> 2.4.1)
18+
racc
19+
prism (1.4.0)
20+
racc (1.8.1)
21+
rainbow (3.1.1)
1122
rake (13.2.1)
23+
regexp_parser (2.10.0)
1224
rspec (3.13.0)
1325
rspec-core (~> 3.13.0)
1426
rspec-expectations (~> 3.13.0)
@@ -22,12 +34,46 @@ GEM
2234
diff-lcs (>= 1.2.0, < 2.0)
2335
rspec-support (~> 3.13.0)
2436
rspec-support (3.13.2)
37+
rubocop (1.75.2)
38+
json (~> 2.3)
39+
language_server-protocol (~> 3.17.0.2)
40+
lint_roller (~> 1.1.0)
41+
parallel (~> 1.10)
42+
parser (>= 3.3.0.2)
43+
rainbow (>= 2.2.2, < 4.0)
44+
regexp_parser (>= 2.9.3, < 3.0)
45+
rubocop-ast (>= 1.44.0, < 2.0)
46+
ruby-progressbar (~> 1.7)
47+
unicode-display_width (>= 2.4.0, < 4.0)
48+
rubocop-ast (1.44.0)
49+
parser (>= 3.3.7.2)
50+
prism (~> 1.4)
51+
rubocop-performance (1.25.0)
52+
lint_roller (~> 1.1)
53+
rubocop (>= 1.75.0, < 2.0)
54+
rubocop-ast (>= 1.38.0, < 2.0)
55+
ruby-progressbar (1.13.0)
2556
simplecov (0.22.0)
2657
docile (~> 1.1)
2758
simplecov-html (~> 0.11)
2859
simplecov_json_formatter (~> 0.1)
2960
simplecov-html (0.13.1)
3061
simplecov_json_formatter (0.1.4)
62+
standard (1.49.0)
63+
language_server-protocol (~> 3.17.0.2)
64+
lint_roller (~> 1.0)
65+
rubocop (~> 1.75.2)
66+
standard-custom (~> 1.0.0)
67+
standard-performance (~> 1.8)
68+
standard-custom (1.0.2)
69+
lint_roller (~> 1.0)
70+
rubocop (~> 1.50)
71+
standard-performance (1.8.0)
72+
lint_roller (~> 1.1)
73+
rubocop-performance (~> 1.25.0)
74+
unicode-display_width (3.1.4)
75+
unicode-emoji (~> 4.0, >= 4.0.4)
76+
unicode-emoji (4.0.4)
3177

3278
PLATFORMS
3379
arm64-darwin-24
@@ -37,6 +83,7 @@ DEPENDENCIES
3783
rake
3884
rspec
3985
simplecov
86+
standard
4087

4188
BUNDLED WITH
4289
2.6.7

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ErrbitPlugin
22

3+
[![RSpec](https://github.com/errbit/errbit_plugin/actions/workflows/rspec.yml/badge.svg)](https://github.com/errbit/errbit_plugin/actions/workflows/rspec.yml)
4+
[![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)
5+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard)
6+
37
ErrbitPlugin provides a set of base classes that you can extend to create
48
Errbit plugins.
59

errbit_plugin.gemspec

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# frozen_string_literal: true
22

3-
lib = File.expand_path('../lib', __FILE__)
3+
lib = File.expand_path("../lib", __FILE__)
44
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5-
require 'errbit_plugin/version'
5+
require "errbit_plugin/version"
66

77
Gem::Specification.new do |spec|
8-
spec.name = "errbit_plugin"
9-
spec.version = ErrbitPlugin::VERSION
10-
spec.authors = ["Stephen Crosby"]
11-
spec.email = ["[email protected]"]
12-
spec.description = %q{Base to create an errbit plugin}
13-
spec.summary = %q{Base to create an errbit plugin}
14-
spec.homepage = "http://github.com/errbit/errbit"
15-
spec.license = "MIT"
8+
spec.name = "errbit_plugin"
9+
spec.version = ErrbitPlugin::VERSION
10+
spec.authors = ["Stephen Crosby"]
11+
spec.email = ["[email protected]"]
12+
spec.description = "Base to create an errbit plugin"
13+
spec.summary = "Base to create an errbit plugin"
14+
spec.homepage = "http://github.com/errbit/errbit"
15+
spec.license = "MIT"
1616

17-
spec.files = `git ls-files`.split($/)
18-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17+
spec.files = `git ls-files`.split($/)
18+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
2019
spec.require_paths = ["lib"]
2120
end

lib/errbit_plugin/issue_trackers/none.rb

+37-13
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,55 @@
22

33
module ErrbitPlugin
44
class NoneIssueTracker < IssueTracker
5-
def self.label; 'none'; end
5+
def self.label
6+
"none"
7+
end
8+
69
def self.note
7-
'When no issue tracker has been configured, you will be able to ' <<
8-
'leave comments on errors.'
10+
"When no issue tracker has been configured, you will be able to " <<
11+
"leave comments on errors."
12+
end
13+
14+
def self.fields
15+
{}
916
end
10-
def self.fields; {}; end
17+
1118
def self.icons
1219
@icons ||= {
13-
create: ['image/png', read_static_file('none_create.png')],
14-
goto: ['image/png', read_static_file('none_create.png')],
15-
inactive: ['image/png', read_static_file('none_inactive.png')],
20+
create: ["image/png", read_static_file("none_create.png")],
21+
goto: ["image/png", read_static_file("none_create.png")],
22+
inactive: ["image/png", read_static_file("none_inactive.png")]
1623
}
1724
end
25+
1826
def self.read_static_file(file)
1927
File.read(File.expand_path(File.join(
20-
File.dirname(__FILE__), '..', '..', '..', 'static', file)))
28+
File.dirname(__FILE__), "..", "..", "..", "static", file
29+
)))
2130
end
31+
2232
##
2333
# The NoneIssueTracker is mark like configured? false because it not valid
2434
# like a real IssueTracker
25-
def configured?; false; end
26-
def errors; {}; end
27-
def url; ''; end
28-
def create_issue(*); false; end
29-
def close_issue(*); false; end
35+
def configured?
36+
false
37+
end
38+
39+
def errors
40+
{}
41+
end
42+
43+
def url
44+
""
45+
end
46+
47+
def create_issue(*)
48+
false
49+
end
50+
51+
def close_issue(*)
52+
false
53+
end
3054
end
3155
end
3256

lib/errbit_plugin/registry.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module ErrbitPlugin
44
class IncompatibilityError < StandardError; end
5+
56
class AlreadyRegisteredError < StandardError; end
67

78
module Registry
@@ -20,7 +21,7 @@ def self.add_issue_tracker(klass)
2021
if validate.valid?
2122
@issue_trackers[key] = klass
2223
else
23-
raise IncompatibilityError.new(validate.errors.join('; '))
24+
raise IncompatibilityError.new(validate.errors.join("; "))
2425
end
2526
end
2627

lib/errbit_plugin/validate_issue_tracker.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def valid?
1919
private
2020

2121
def good_inherit?
22-
unless @klass.ancestors.include?(ErrbitPlugin::IssueTracker)
22+
if @klass.ancestors.include?(ErrbitPlugin::IssueTracker)
23+
true
24+
else
2325
add_errors(:not_inherited)
2426
false
25-
else
26-
true
2727
end
2828
end
2929

@@ -57,7 +57,7 @@ def instance
5757
@instance ||= @klass.new({})
5858
end
5959

60-
def add_errors(key, value=nil)
60+
def add_errors(key, value = nil)
6161
@errors << [key, value].compact
6262
end
6363
end

lib/errbit_plugin/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ErrbitPlugin
4-
VERSION = '0.7.0'
4+
VERSION = "0.7.0"
55
end

spec/errbit_plugin/registry_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
3+
require "spec_helper"
44

55
describe ErrbitPlugin::Registry do
66
before do
@@ -10,7 +10,7 @@
1010
let(:tracker) {
1111
tracker = Class.new(ErrbitPlugin::IssueTracker) do
1212
def self.label
13-
'something'
13+
"something"
1414
end
1515
end
1616
tracker
@@ -22,16 +22,16 @@ def self.label
2222
allow(ErrbitPlugin::ValidateIssueTracker)
2323
.to receive(:new)
2424
.with(tracker)
25-
.and_return(double(:valid? => true, :message => ''))
25+
.and_return(double(valid?: true, message: ""))
2626
end
27-
it 'add new issue_tracker plugin' do
27+
it "add new issue_tracker plugin" do
2828
ErrbitPlugin::Registry.add_issue_tracker(tracker)
2929
expect(ErrbitPlugin::Registry.issue_trackers).to eq({
30-
'something' => tracker
30+
"something" => tracker
3131
})
3232
end
3333
context "with already issue_tracker with this key" do
34-
it 'raise ErrbitPlugin::AlreadyRegisteredError' do
34+
it "raise ErrbitPlugin::AlreadyRegisteredError" do
3535
ErrbitPlugin::Registry.add_issue_tracker(tracker)
3636
expect {
3737
ErrbitPlugin::Registry.add_issue_tracker(tracker)
@@ -41,26 +41,26 @@ def self.label
4141
end
4242

4343
context "with an IssueTracker not valid" do
44-
it 'raise an IncompatibilityError' do
44+
it "raise an IncompatibilityError" do
4545
allow(ErrbitPlugin::ValidateIssueTracker)
4646
.to receive(:new)
4747
.with(tracker)
48-
.and_return(double(:valid? => false, :message => 'foo', :errors => []))
48+
.and_return(double(valid?: false, message: "foo", errors: []))
4949
expect {
5050
ErrbitPlugin::Registry.add_issue_tracker(tracker)
5151
}.to raise_error(ErrbitPlugin::IncompatibilityError)
5252
end
5353

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

6060
begin
6161
ErrbitPlugin::Registry.add_issue_tracker(tracker)
6262
rescue ErrbitPlugin::IncompatibilityError => e
63-
expect(e.message).to eq('one; two')
63+
expect(e.message).to eq("one; two")
6464
end
6565
end
6666
end

0 commit comments

Comments
 (0)