rubocop-extension-generator 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/README.md +8 -4
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/exe/rubocop-extension-generator +1 -0
- data/lib/rubocop/extension/generator/cli.rb +2 -0
- data/lib/rubocop/extension/generator/generator.rb +51 -33
- data/lib/rubocop/extension/generator/version.rb +3 -1
- data/lib/rubocop/extension/generator.rb +2 -0
- data/rubocop-extension-generator.gemspec +4 -2
- data/smoke/smoke.rb +4 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c4899e8b926cb6c6a60ca7b066b5906fc12b688c677fad0b16b99feaa79841
|
4
|
+
data.tar.gz: c2183a8c1490dc9821a59d2e4d852156588a9ee8aedd57862d81a4a00dc71aa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea0ac44be2a482201530d82ba7762015f22eed4cb338bba1fed352e368656c0944315f88873af63100858e1f2885d1d3eb3022ea5f8f2bd8af003bae26cdc692
|
7
|
+
data.tar.gz: 7a3f38354de69f19802075f379d7c7d347948a88f323101dd822524ffbb84d9c31d86bf0239ec477e9aa41ff170741d70cbb520d6c196148069adfda8103fc29
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# master (unreleased)
|
2
2
|
|
3
|
+
## v0.6.0
|
4
|
+
|
5
|
+
* [#27](https://github.com/rubocop/rubocop-extension-generator/pull/27): Support RuboCop extension plugin.
|
6
|
+
|
3
7
|
## v0.5.2
|
4
8
|
|
5
9
|
* [#19](https://github.com/rubocop/rubocop-extension-generator/pull/19): Support `bundle gem` gem name placeholder.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -26,27 +26,32 @@ Creating gem 'rubocop-foobar'...
|
|
26
26
|
create rubocop-foobar/Gemfile
|
27
27
|
create rubocop-foobar/lib/rubocop/foobar.rb
|
28
28
|
create rubocop-foobar/lib/rubocop/foobar/version.rb
|
29
|
+
create rubocop-foobar/sig/rubocop/foobar.rbs
|
29
30
|
create rubocop-foobar/rubocop-foobar.gemspec
|
30
31
|
create rubocop-foobar/Rakefile
|
31
32
|
create rubocop-foobar/README.md
|
32
33
|
create rubocop-foobar/bin/console
|
33
34
|
create rubocop-foobar/bin/setup
|
34
35
|
create rubocop-foobar/.gitignore
|
35
|
-
|
36
|
+
create rubocop-foobar/LICENSE.txt
|
36
37
|
Gem 'rubocop-foobar' was successfully created. For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html
|
37
38
|
create rubocop-foobar/lib/rubocop-foobar.rb
|
38
|
-
create rubocop-foobar/lib/rubocop/foobar/
|
39
|
+
create rubocop-foobar/lib/rubocop/foobar/plugin.rb
|
39
40
|
create rubocop-foobar/lib/rubocop/cop/foobar_cops.rb
|
40
41
|
create rubocop-foobar/config/default.yml
|
41
42
|
create rubocop-foobar/spec/spec_helper.rb
|
42
43
|
create rubocop-foobar/.rspec
|
43
|
-
|
44
|
+
create rubocop-foobar/.rubocop.yml
|
44
45
|
update lib/rubocop/foobar.rb
|
45
46
|
update lib/rubocop/foobar/version.rb
|
47
|
+
update README.md
|
48
|
+
update rubocop-foobar.gemspec
|
46
49
|
update rubocop-foobar.gemspec
|
47
50
|
update rubocop-foobar.gemspec
|
48
51
|
update Rakefile
|
49
52
|
update Gemfile
|
53
|
+
update README.md
|
54
|
+
delete sig
|
50
55
|
|
51
56
|
It's done! You can start developing a new extension of RuboCop in rubocop-foobar.
|
52
57
|
For the next step, you can use the cop generator.
|
@@ -67,4 +72,3 @@ You can execute a smoke test with `ruby smoke/smoke.rb`. Check it is success bef
|
|
67
72
|
## Contributing
|
68
73
|
|
69
74
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-extension-generator.
|
70
|
-
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Extension
|
3
5
|
module Generator
|
@@ -16,30 +18,39 @@ module RuboCop
|
|
16
18
|
|
17
19
|
require_relative '#{dirname}'
|
18
20
|
require_relative '#{dirname}/version'
|
19
|
-
require_relative '#{dirname}/
|
20
|
-
|
21
|
-
RuboCop::#{classname}::Inject.defaults!
|
21
|
+
require_relative '#{dirname}/plugin'
|
22
22
|
|
23
|
-
require_relative '#{cops_file_name.sub(/\.rb$/, '').sub(
|
23
|
+
require_relative '#{cops_file_name.sub(/\.rb$/, '').sub(%r{^lib/}, '')}'
|
24
24
|
RUBY
|
25
25
|
|
26
|
-
put "lib/#{dirname}/
|
26
|
+
put "lib/#{dirname}/plugin.rb", <<~RUBY
|
27
27
|
# frozen_string_literal: true
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
require 'lint_roller'
|
30
|
+
|
31
31
|
module RuboCop
|
32
32
|
module #{classname}
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
# A plugin that integrates #{name} with RuboCop's plugin system.
|
34
|
+
class Plugin < LintRoller::Plugin
|
35
|
+
def about
|
36
|
+
LintRoller::About.new(
|
37
|
+
name: '#{name}',
|
38
|
+
version: VERSION,
|
39
|
+
homepage: "TODO: Put your plugin's homepage URL here.",
|
40
|
+
description: "TODO: Put your plugin's description here."
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def supported?(context)
|
45
|
+
context.engine == :rubocop
|
46
|
+
end
|
47
|
+
|
48
|
+
def rules(_context)
|
49
|
+
LintRoller::Rules.new(
|
50
|
+
type: :path,
|
51
|
+
config_format: :rubocop,
|
52
|
+
value: Pathname.new(__dir__).join('../../../config/default.yml')
|
53
|
+
)
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
@@ -61,8 +72,6 @@ module RuboCop
|
|
61
72
|
require 'rubocop/rspec/support'
|
62
73
|
|
63
74
|
RSpec.configure do |config|
|
64
|
-
config.include RuboCop::RSpec::ExpectOffense
|
65
|
-
|
66
75
|
config.disable_monkey_patching!
|
67
76
|
config.raise_errors_for_deprecations!
|
68
77
|
config.raise_on_warning = true
|
@@ -80,28 +89,25 @@ module RuboCop
|
|
80
89
|
TEXT
|
81
90
|
|
82
91
|
put '.rubocop.yml', <<~YML
|
92
|
+
plugins:
|
93
|
+
- rubocop-internal_affairs
|
94
|
+
|
83
95
|
Naming/FileName:
|
84
|
-
|
85
|
-
|
96
|
+
Exclude:
|
97
|
+
- lib/#{name}.rb
|
86
98
|
YML
|
87
99
|
|
88
|
-
patch "lib/#{dirname}.rb", /^ end\nend/, <<~RUBY
|
89
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
90
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
91
|
-
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
92
|
-
|
93
|
-
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
RUBY
|
97
|
-
|
98
100
|
patch "lib/#{dirname}.rb", 'module Rubocop', 'module RuboCop'
|
99
101
|
patch "lib/#{dirname}/version.rb", 'module Rubocop', 'module RuboCop'
|
102
|
+
patch 'README.md', 'Rubocop', 'RuboCop'
|
100
103
|
patch "#{name}.gemspec", 'Rubocop', 'RuboCop'
|
101
|
-
|
104
|
+
patch "#{name}.gemspec", /required_ruby_version = ">= \d.\d.\d"/, 'required_ruby_version = ">= 2.7.0"'
|
102
105
|
patch "#{name}.gemspec", /^end/, <<~RUBY
|
103
106
|
|
104
|
-
spec.
|
107
|
+
spec.metadata['default_lint_roller_plugin'] = 'RuboCop::#{classname}::Plugin'
|
108
|
+
|
109
|
+
spec.add_dependency 'lint_roller', '~> 1.1'
|
110
|
+
spec.add_dependency 'rubocop', '>= 1.72.2'
|
105
111
|
end
|
106
112
|
RUBY
|
107
113
|
|
@@ -134,6 +140,7 @@ module RuboCop
|
|
134
140
|
RUBY
|
135
141
|
|
136
142
|
patch 'Gemfile', /\z/, <<~RUBY
|
143
|
+
gem 'rubocop', '>= 1.72.2'
|
137
144
|
gem 'rspec'
|
138
145
|
RUBY
|
139
146
|
|
@@ -143,6 +150,10 @@ module RuboCop
|
|
143
150
|
patch 'README.md', /^gem '#{name}'$/, "gem '#{name}', require: false"
|
144
151
|
end
|
145
152
|
|
153
|
+
# NOTE: Since useful type definitions are usually not provided, they are not generated by default.
|
154
|
+
# Users can create them as needed.
|
155
|
+
delete "sig"
|
156
|
+
|
146
157
|
puts
|
147
158
|
puts <<~MESSAGE
|
148
159
|
It's done! You can start developing a new extension of RuboCop in #{root_path}.
|
@@ -164,9 +175,16 @@ module RuboCop
|
|
164
175
|
path = root_path / path
|
165
176
|
file = path.read
|
166
177
|
raise "Cannot apply patch for #{path} because #{pattern} is missing" unless file.match?(pattern)
|
178
|
+
|
167
179
|
path.write file.sub(pattern, replacement)
|
168
180
|
end
|
169
181
|
|
182
|
+
private def delete(path)
|
183
|
+
puts "delete #{path}"
|
184
|
+
path = root_path / path
|
185
|
+
FileUtils.rm_r(path)
|
186
|
+
end
|
187
|
+
|
170
188
|
private def root_path
|
171
189
|
@root_path ||= Pathname(name)
|
172
190
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/rubocop/extension/generator/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.summary = %q{A generator of RuboCop's custom cops gem}
|
10
12
|
spec.description = %q{A generator of RuboCop's custom cops gem}
|
11
13
|
spec.homepage = "https://github.com/rubocop/rubocop-extension-generator"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
13
15
|
spec.licenses = ['MIT']
|
14
16
|
|
15
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
@@ -27,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
27
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
30
|
spec.require_paths = ["lib"]
|
29
31
|
|
30
|
-
spec.add_runtime_dependency 'rubocop', '>= 1.
|
32
|
+
spec.add_runtime_dependency 'rubocop', '>= 1.72.2'
|
31
33
|
spec.add_runtime_dependency 'bundler'
|
32
34
|
spec.add_runtime_dependency 'activesupport'
|
33
35
|
end
|
data/smoke/smoke.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Smoke testing for this gem
|
2
4
|
|
3
5
|
require 'tmpdir'
|
@@ -18,11 +20,12 @@ Dir.mktmpdir('-rubocop-extension-generator-smoke') do |base_dir|
|
|
18
20
|
gemspec[/spec\.summary.+/] = 'spec.summary = "a gem for smoke testing"'
|
19
21
|
gemspec.gsub!(/^.+spec\.description.+$/, '')
|
20
22
|
gemspec.gsub!(/^.+spec\.homepage.+$/, '')
|
21
|
-
gemspec.gsub!(/^.+spec\.metadata.+$/, '')
|
23
|
+
gemspec.gsub!(/^.+spec\.metadata\["(homepage_uri|source_code_uri|changelog_uri)"\].+$/, '')
|
22
24
|
|
23
25
|
gemspec_path.write gemspec
|
24
26
|
|
25
27
|
system('bundle', 'install', exception: true, chdir: gem_dir)
|
26
28
|
system('bundle', 'exec', 'rake', 'new_cop[Smoke/Foo]', exception: true, chdir: gem_dir)
|
29
|
+
system('bundle', 'exec', 'rubocop', '-a', exception: true, chdir: gem_dir)
|
27
30
|
system('bundle', 'exec', 'rake', 'spec', exception: true, chdir: gem_dir)
|
28
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-extension-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.72.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.72.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2.
|
93
|
+
version: 2.7.0
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.2.
|
100
|
+
rubygems_version: 3.2.33
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: A generator of RuboCop's custom cops gem
|