smart_todo 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/smart_todo/events/issue_close.rb +28 -1
- data/lib/smart_todo/events/ruby_version.rb +36 -0
- data/lib/smart_todo/events.rb +8 -0
- data/lib/smart_todo/parser/metadata_parser.rb +1 -1
- data/lib/smart_todo/version.rb +1 -1
- data/lib/smart_todo.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c17d1471d893e5a764dda2fa9adcfc73049b5c5a45d6678feca40104879065fc
|
4
|
+
data.tar.gz: 85411f13bc189f060372e90a72fc1a545cd0030b6f67cf0fd75f1ff97dbeb755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe190ce26c9b3e65aea86f3d23e40a400c14edcac8c465b361341ac00a7ab7d59498c9c3edda92d7e180659cad96240148bce26dc3a1db77a92ee2e03575204
|
7
|
+
data.tar.gz: f1c0386fbb5346a74c3f9c0c3b6228a9af29a810241793a5f44db5cbe7d7873c24e9dda987b65aff0d4984193be3652bec472431a48407badb2eb7610da506d6
|
data/Gemfile.lock
CHANGED
@@ -11,6 +11,11 @@ module SmartTodo
|
|
11
11
|
# If the Pull Request or Issue is on a private repository, exporting a token
|
12
12
|
# with the `repos` scope in the +SMART_TODO_GITHUB_TOKEN+ environment variable
|
13
13
|
# is required.
|
14
|
+
#
|
15
|
+
# You can also set a per-org or per-repo token by exporting more specific environment variables:
|
16
|
+
# +SMART_TODO_GITHUB_TOKEN__<ORG>+ and +SMART_TODO_GITHUB_TOKEN__<ORG>__<REPO>+
|
17
|
+
# The +<ORG>+ and +<REPO>+ parts should be uppercased and use underscores.
|
18
|
+
# For example, +Shopify/my-repo+ would become +SMART_TODO_GITHUB_TOKEN__SHOPIFY__MY_REPO=...+.
|
14
19
|
class IssueClose
|
15
20
|
TOKEN_ENV = "SMART_TODO_GITHUB_TOKEN"
|
16
21
|
|
@@ -78,8 +83,30 @@ module SmartTodo
|
|
78
83
|
# @return [Hash]
|
79
84
|
def default_headers
|
80
85
|
{ "Accept" => "application/vnd.github.v3+json" }.tap do |headers|
|
81
|
-
|
86
|
+
token = authorization_token
|
87
|
+
headers["Authorization"] = "token #{token}" if token
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String, nil]
|
92
|
+
def authorization_token
|
93
|
+
# Will look in order for:
|
94
|
+
# SMART_TODO_GITHUB_TOKEN__ORG__REPO
|
95
|
+
# SMART_TODO_GITHUB_TOKEN__ORG
|
96
|
+
# SMART_TODO_GITHUB_TOKEN
|
97
|
+
parts = [
|
98
|
+
TOKEN_ENV,
|
99
|
+
@organization.upcase.gsub(/[^A-Z0-9]/, "_"),
|
100
|
+
@repo.upcase.gsub(/[^A-Z0-9]/, "_"),
|
101
|
+
]
|
102
|
+
|
103
|
+
(parts.size - 1).downto(0).each do |i|
|
104
|
+
key = parts[0..i].join("__")
|
105
|
+
token = ENV[key]
|
106
|
+
return token unless token.nil? || token.empty?
|
82
107
|
end
|
108
|
+
|
109
|
+
nil
|
83
110
|
end
|
84
111
|
end
|
85
112
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SmartTodo
|
4
|
+
module Events
|
5
|
+
# An event that checks the currently installed ruby version.
|
6
|
+
# @example
|
7
|
+
# RubyVersion.new(['>= 2.3', '< 3'])
|
8
|
+
class RubyVersion
|
9
|
+
def initialize(requirements)
|
10
|
+
@requirements = Gem::Requirement.new(requirements)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param requirements [Array<String>] a list of version specifiers
|
14
|
+
# @return [String, false]
|
15
|
+
def met?
|
16
|
+
if @requirements.satisfied_by?(Gem::Version.new(installed_ruby_version))
|
17
|
+
message(installed_ruby_version)
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param installed_ruby_version [String], requirements [String]
|
24
|
+
# @return [String]
|
25
|
+
def message(installed_ruby_version)
|
26
|
+
"The currently installed version of Ruby #{installed_ruby_version} is #{@requirements}."
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def installed_ruby_version
|
32
|
+
RUBY_VERSION
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/smart_todo/events.rb
CHANGED
@@ -66,5 +66,13 @@ module SmartTodo
|
|
66
66
|
def pull_request_close(organization, repo, pr_number)
|
67
67
|
IssueClose.new(organization, repo, pr_number, type: "pulls").met?
|
68
68
|
end
|
69
|
+
|
70
|
+
# Check if the installed ruby version meets requirements.
|
71
|
+
#
|
72
|
+
# @param requirements [Array<String>] a list of version specifiers
|
73
|
+
# @return [false, String]
|
74
|
+
def ruby_version(*requirements)
|
75
|
+
RubyVersion.new(requirements).met?
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
data/lib/smart_todo/version.rb
CHANGED
data/lib/smart_todo.rb
CHANGED
@@ -18,6 +18,7 @@ module SmartTodo
|
|
18
18
|
autoload :GemBump, "smart_todo/events/gem_bump"
|
19
19
|
autoload :GemRelease, "smart_todo/events/gem_release"
|
20
20
|
autoload :IssueClose, "smart_todo/events/issue_close"
|
21
|
+
autoload :RubyVersion, "smart_todo/events/ruby_version"
|
21
22
|
end
|
22
23
|
|
23
24
|
module Dispatchers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_todo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rexml
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/smart_todo/events/gem_bump.rb
|
119
119
|
- lib/smart_todo/events/gem_release.rb
|
120
120
|
- lib/smart_todo/events/issue_close.rb
|
121
|
+
- lib/smart_todo/events/ruby_version.rb
|
121
122
|
- lib/smart_todo/parser/comment_parser.rb
|
122
123
|
- lib/smart_todo/parser/metadata_parser.rb
|
123
124
|
- lib/smart_todo/parser/todo_node.rb
|
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
- !ruby/object:Gem::Version
|
151
152
|
version: '0'
|
152
153
|
requirements: []
|
153
|
-
rubygems_version: 3.4.
|
154
|
+
rubygems_version: 3.4.16
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: Enhance todo's comments in your codebase.
|