Skip to content

Commit

Permalink
Upgrade gems, switch from rubocop to standard
Browse files Browse the repository at this point in the history
  • Loading branch information
nertzy committed May 16, 2024
1 parent a01a770 commit 9da0542
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 151 deletions.
17 changes: 0 additions & 17 deletions .rubocop.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem "srp-api", github: "srpatx/srp-api", require: false
gem "xml-simple"

group :development do
gem "srp-style", require: false, github: "srpatx/srp-style"
gem "standard"
end

group :test do
Expand Down
172 changes: 88 additions & 84 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,138 +5,142 @@ GIT
srp-api (0.1.0)
http (>= 4.4)

GIT
remote: https://github.com/srpatx/srp-style.git
revision: 64afb53df4dc387249854e808ce9b7ee84ed74b3
specs:
srp-style (0.87.1)
rubocop (~> 1.31.0)
rubocop-performance (~> 1.14.2)
rubocop-rails (~> 2.15.1)
rubocop-rake (~> 0.6.0)
rubocop-rspec (~> 2.11.1)
rubocop-thread_safety (~> 0.4.4)

GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.7.1)
activesupport (7.1.3.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
concurrent-ruby (1.2.2)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crack (0.4.5)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ffi (1.15.5)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
diff-lcs (1.5.1)
domain_name (0.6.20240107)
drb (2.2.1)
ffi (1.16.3)
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
rake
hashdiff (1.0.1)
http (5.1.1)
hashdiff (1.1.0)
http (5.2.0)
addressable (~> 2.8)
base64 (~> 0.1)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.4.0)
llhttp-ffi (~> 0.5.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
i18n (1.14.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.6.3)
llhttp-ffi (0.4.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
minitest (5.19.0)
minitest (5.23.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nio4r (2.7.0)
parallel (1.23.0)
parser (3.2.2.3)
mutex_m (0.2.0)
nio4r (2.7.3)
parallel (1.24.0)
parser (3.3.1.0)
ast (~> 2.4.1)
racc
public_suffix (5.0.3)
public_suffix (5.0.5)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.8.1)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
racc (1.7.3)
rack (3.0.11)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rainbow (3.1.1)
rake (13.0.6)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.15.0)
rake (13.2.1)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.1)
connection_pool
regexp_parser (2.8.1)
rexml (3.2.7)
regexp_parser (2.9.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (~> 3.13.0)
rspec-its (1.3.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-match_fuzzy (0.1.3)
rspec-match_fuzzy (0.2.0)
rspec (>= 3.2)
rspec-mocks (3.12.6)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.31.2)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.14.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.15.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
rubocop-thread_safety (0.4.4)
rubocop (>= 0.53.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sinatra (3.1.0)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
standard (1.36.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.63.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
strscan (3.1.0)
tilt (2.2.0)
tilt (2.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
webmock (3.18.1)
unicode-display_width (2.5.0)
webmock (3.23.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down Expand Up @@ -164,7 +168,7 @@ DEPENDENCIES
rspec-match_fuzzy
sinatra
srp-api!
srp-style!
standard
webmock
xml-simple

Expand Down
19 changes: 4 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,15 @@ Bundler.require(:default)

task(:default)

# rubocop:disable Lint/SuppressedException
require "standard/rake"
Rake::Task[:default].enhance([:standard])

begin
require "rspec/core/rake_task"

desc("Run all specs in spec directory (excluding plugin specs)")
RSpec::Core::RakeTask.new(:spec)

Rake::Task["default"].enhance([:spec])
rescue LoadError
end

begin
require "rubocop/rake_task"

desc("Run rubocop")
task(:rubocop) do
RuboCop::RakeTask.new
end

Rake::Task["default"].enhance([:rubocop])
Rake::Task[:default].enhance([:spec])
rescue LoadError
end
# rubocop:enable Lint/SuppressedException
12 changes: 5 additions & 7 deletions bin/rubocop → bin/standardrb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
#
# This file was generated by Bundler.
#
# The application 'rubocop' is installed as part of a gem, and
# The application 'standardrb' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand All @@ -26,4 +24,4 @@ end
require "rubygems"
require "bundler/setup"

load Gem.bin_path("rubocop", "rubocop")
load Gem.bin_path("standard", "standardrb")
6 changes: 3 additions & 3 deletions lib/cctray.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize(github_client: nil, redis_pool: nil)
@github_client = github_client || GitHub::Client.new(redis_pool: redis_pool)
end

def status(group: , repo: , workflow: , branch: nil, xml: false)
def status(group:, repo:, workflow:, branch: nil, xml: false)
github_runs = github_client.runs(group: group, repo: repo, workflow: workflow)
runs = github_runs.fetch("workflow_runs", [])
runs = runs.select { |run| run["head_branch"] == branch } if branch
Expand All @@ -49,7 +49,7 @@ def status(group: , repo: , workflow: , branch: nil, xml: false)
attr_reader :github_client

# rubocop:disable Metrics/MethodLength
def generate_cctray_status_for(run, all_runs: )
def generate_cctray_status_for(run, all_runs:)
name = run["repository"]["full_name"]
created_at = run["created_at"]
conclusion = run["conclusion"] || previous_conclusion(name, created_at, all_runs)
Expand All @@ -76,6 +76,6 @@ def previous_conclusion(project_name, before, all_runs)
end

def render_xml(status)
XmlSimple.xml_out(status, { rootname: "Projects", anonymoustag: "Project" })
XmlSimple.xml_out(status, {rootname: "Projects", anonymoustag: "Project"})
end
end
8 changes: 4 additions & 4 deletions lib/github/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(token: nil, cache: nil, redis_pool: nil)
@cache = cache || RedisCache.new(redis_pool: redis_pool)
end

def runs(group: , repo: , workflow: )
def runs(group:, repo:, workflow:)
uri = URI("https://api.github.com/repos/#{group}/#{repo}/actions/workflows/#{workflow}/runs")

cached_data = cache.read(uri.to_s)
Expand All @@ -34,22 +34,22 @@ def fresh?(cached_data)
def fetch_runs(uri, cached_data)
runs = cached_data&.fetch("runs", nil)
etag = cached_data&.fetch("etag", nil)
response = request(:get, uri, headers: { "If-None-Match": etag })
response = request(:get, uri, headers: {"If-None-Match": etag})

if status_changed?(response)
runs = JSON.parse(response)
etag = response.headers["ETag"]
end

cache_until = (Time.current + CACHE_TTL).iso8601
cache.write(uri.to_s, { etag: etag, runs: runs, until: cache_until })
cache.write(uri.to_s, {etag: etag, runs: runs, until: cache_until})

runs
end

def request(method, uri, headers: {})
response = HTTP
.headers({ accept: "application/json" }.merge(headers))
.headers({accept: "application/json"}.merge(headers))
.basic_auth(user: nil, pass: token)
.request(method, uri)

Expand Down
2 changes: 1 addition & 1 deletion lib/redis_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "redis"

class RedisCache
def initialize(redis_pool: )
def initialize(redis_pool:)
@redis_pool = redis_pool
# @redis = redis || Redis.new(url: ENV["REDIS_URL"])
end
Expand Down
Loading

0 comments on commit 9da0542

Please sign in to comment.