Skip to content

Commit 9d24372

Browse files
authored
Merge pull request #7 from increments/add-search-issues
Add `search issues` command and refactoring
2 parents 20943ca + f33079f commit 9d24372

22 files changed

+401
-137
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: "bundler"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
rspec:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
ruby: ["2.7", "3.0", "3.1"]
19+
runs-on: "ubuntu-latest"
20+
continue-on-error: false
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: ${{ matrix.ruby }}
26+
bundler-cache: true
27+
- run: bundle exec rspec
28+
29+
rubocop:
30+
runs-on: "ubuntu-latest"
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: "3.1"
36+
bundler-cache: true
37+
- run: bundle exec rubocop

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ tmp
2020
*.o
2121
*.a
2222
mkmf.log
23+
vendor/bundle/

.rubocop.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
require:
4+
- rubocop-performance
5+
- rubocop-rspec
6+
- rubocop-rake
7+
8+
AllCops:
9+
NewCops: enable

.rubocop_todo.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config --exclude-limit 99999`
3+
# on 2022-10-12 04:57:08 UTC using RuboCop version 1.36.0.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: Include.
11+
# Include: **/*.gemspec
12+
Gemspec/RequiredRubyVersion:
13+
Exclude:
14+
- 'ruboty-github.gemspec'
15+
16+
# Offense count: 1
17+
Lint/UnreachableCode:
18+
Exclude:
19+
- 'lib/ruboty/github/actions/close_issue.rb'
20+
21+
# Offense count: 1
22+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
23+
Metrics/AbcSize:
24+
Max: 24
25+
26+
# Offense count: 2
27+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
28+
Metrics/MethodLength:
29+
Max: 14
30+
31+
# Offense count: 2
32+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
33+
# NamePrefix: is_, has_, have_
34+
# ForbiddenPrefixes: is_, has_, have_
35+
# AllowedMethods: is_a?
36+
# MethodDefinitionMacros: define_method, define_singleton_method
37+
Naming/PredicateName:
38+
Exclude:
39+
- 'spec/**/*'
40+
- 'lib/ruboty/github/actions/base.rb'
41+
- 'lib/ruboty/github/actions/close_issue.rb'
42+
43+
# Offense count: 3
44+
# Configuration parameters: .
45+
# SupportedStyles: have_received, receive
46+
RSpec/MessageSpies:
47+
EnforcedStyle: receive
48+
49+
# Offense count: 2
50+
RSpec/MultipleExpectations:
51+
Max: 2
52+
53+
# Offense count: 11
54+
# Configuration parameters: AllowSubject.
55+
RSpec/MultipleMemoizedHelpers:
56+
Max: 13
57+
58+
# Offense count: 1
59+
RSpec/NoExpectationExample:
60+
Exclude:
61+
- 'spec/ruboty/handlers/github_spec.rb'
62+
63+
# Offense count: 9
64+
# Configuration parameters: AllowedConstants.
65+
Style/Documentation:
66+
Exclude:
67+
- 'spec/**/*'
68+
- 'test/**/*'
69+
- 'lib/ruboty/github/actions/base.rb'
70+
- 'lib/ruboty/github/actions/close_issue.rb'
71+
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
72+
- 'lib/ruboty/github/actions/create_issue.rb'
73+
- 'lib/ruboty/github/actions/create_pull_request.rb'
74+
- 'lib/ruboty/github/actions/merge_pull_request.rb'
75+
- 'lib/ruboty/github/actions/remember.rb'
76+
- 'lib/ruboty/github/actions/search_issues.rb'
77+
- 'lib/ruboty/handlers/github.rb'
78+
79+
# Offense count: 1
80+
# This cop supports safe autocorrection (--autocorrect).
81+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
82+
# URISchemes: http, https
83+
Layout/LineLength:
84+
Max: 148

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
- Add `search issues` command
3+
- Support test on GitHub Actions
4+
- Add rubocop, rubocop-rake, rubocop-performance, rubocop-rspec gems
5+
- Use rubocop autocorrect and modify the code
6+
17
## 0.2.3
28
- Fix typo
39

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in ruboty-github.gemspec

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
require "bundler/gem_tasks"
1+
# frozen_string_literal: true
22

3+
require 'bundler/gem_tasks'

lib/ruboty/github.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
require "active_support/core_ext/string/strip"
2-
require "octokit"
1+
# frozen_string_literal: true
32

4-
require "ruboty"
5-
require "ruboty/github/actions/base"
6-
require "ruboty/github/actions/close_issue"
7-
require "ruboty/github/actions/create_issue"
8-
require "ruboty/github/actions/create_pull_request"
9-
require "ruboty/github/actions/create_deploy_pull_request"
10-
require "ruboty/github/actions/merge_pull_request"
11-
require "ruboty/github/actions/remember"
12-
require "ruboty/github/version"
13-
require "ruboty/handlers/github"
3+
require 'active_support/core_ext/string/strip'
4+
require 'octokit'
5+
6+
require 'ruboty'
7+
require 'ruboty/github/actions/base'
8+
require 'ruboty/github/actions/close_issue'
9+
require 'ruboty/github/actions/create_issue'
10+
require 'ruboty/github/actions/create_pull_request'
11+
require 'ruboty/github/actions/create_deploy_pull_request'
12+
require 'ruboty/github/actions/merge_pull_request'
13+
require 'ruboty/github/actions/remember'
14+
require 'ruboty/github/actions/search_issues'
15+
require 'ruboty/github/version'
16+
require 'ruboty/handlers/github'

lib/ruboty/github/actions/base.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module Ruboty
24
module Github
35
module Actions
46
class Base
5-
NAMESPACE = "github"
7+
NAMESPACE = 'github'
68

79
attr_reader :message
810

@@ -17,7 +19,7 @@ def access_tokens
1719
end
1820

1921
def body
20-
message[:description] || ""
22+
message[:description] || ''
2123
end
2224

2325
def sender_name
@@ -45,14 +47,14 @@ def repository
4547
end
4648

4749
def client_options
48-
client_options_with_nil_value.reject {|key, value| value.nil? }
50+
client_options_with_nil_value.compact
4951
end
5052

5153
def client_options_with_nil_value
5254
{
5355
access_token: access_token,
5456
api_endpoint: api_endpoint,
55-
web_endpoint: web_endpoint,
57+
web_endpoint: web_endpoint
5658
}
5759
end
5860

@@ -66,11 +68,10 @@ def api_endpoint
6668

6769
# @note GITHUB_HOST will be deprecated on the next major version
6870
def github_base_url
69-
case
70-
when ENV["GITHUB_BASE_URL"]
71-
ENV["GITHUB_BASE_URL"]
72-
when ENV["GITHUB_HOST"]
73-
"https://#{ENV['GITHUB_HOST']}"
71+
if ENV.fetch('GITHUB_BASE_URL', nil)
72+
ENV.fetch('GITHUB_BASE_URL', nil)
73+
elsif ENV.fetch('GITHUB_HOST', nil)
74+
"https://#{ENV.fetch('GITHUB_HOST', nil)}"
7475
end
7576
end
7677
end

0 commit comments

Comments
 (0)