oxcop 0.1.0-x86_64-linux-gnu
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +16 -0
- data/THIRD_PARTY_NOTICES.md +1226 -0
- data/exe/oxcop +11 -0
- data/exe/x86_64-linux-gnu/oxcop +0 -0
- data/lib/oxcop/version.rb +8 -0
- data/lib/oxcop.rb +80 -0
- metadata +54 -0
data/exe/oxcop
ADDED
|
Binary file
|
data/lib/oxcop.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "oxcop/version"
|
|
4
|
+
|
|
5
|
+
# Locates and runs the native `oxcop` binary. Platform gems ship it under
|
|
6
|
+
# `exe/<platform>/oxcop` (the layout tailwindcss-ruby uses); the plain `ruby`
|
|
7
|
+
# platform gem has no binary and explains why at run time.
|
|
8
|
+
module Oxcop
|
|
9
|
+
GEM_NAME = "oxcop"
|
|
10
|
+
EXE_DIR = File.expand_path("../exe", __dir__)
|
|
11
|
+
REPO_ROOT = File.expand_path("../../..", __dir__)
|
|
12
|
+
|
|
13
|
+
class ExecutableNotFound < StandardError; end
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def executable
|
|
17
|
+
return ENV["OXCOP_BINARY"] if ENV["OXCOP_BINARY"] && !ENV["OXCOP_BINARY"].empty?
|
|
18
|
+
|
|
19
|
+
packaged_executable || development_executable || raise(ExecutableNotFound, not_found_message)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def exec(argv)
|
|
23
|
+
Kernel.exec(ruby_env, executable, *argv)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def packaged_executable
|
|
29
|
+
Dir.glob(File.join(EXE_DIR, "*", "oxcop")).find do |path|
|
|
30
|
+
platform = Gem::Platform.new(File.basename(File.dirname(path)))
|
|
31
|
+
Gem::Platform.match_gem?(platform, GEM_NAME)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# When the gem is used straight from a checkout (`gem "oxcop", path: ...`),
|
|
36
|
+
# fall back to the Cargo build output.
|
|
37
|
+
def development_executable
|
|
38
|
+
%w[release debug].map { |profile| File.join(REPO_ROOT, "target", profile, "oxcop") }
|
|
39
|
+
.find { |path| File.executable?(path) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ruby_env
|
|
43
|
+
{
|
|
44
|
+
"OXCOP_RUBY_ENGINE" => RUBY_ENGINE,
|
|
45
|
+
"OXCOP_RUBY_VERSION" => RUBY_VERSION,
|
|
46
|
+
"OXCOP_RUBY_PATCHLEVEL" => RUBY_PATCHLEVEL.to_s,
|
|
47
|
+
"OXCOP_RUBY_PLATFORM" => RUBY_PLATFORM,
|
|
48
|
+
"OXCOP_GEMS" => gems,
|
|
49
|
+
# `AllCops/ProjectIndexIncludesGems` indexes the gems only in a bundle.
|
|
50
|
+
"OXCOP_IN_BUNDLE" => defined?(Bundler) && Bundler::SharedHelpers.in_bundle? ? "1" : "",
|
|
51
|
+
# Renders ERB in .rubocop.yml files.
|
|
52
|
+
"OXCOP_RUBY" => RbConfig.ruby
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The gems RuboCop could load plugins (and `inherit_gem` configs) from,
|
|
57
|
+
# one `name<TAB>full_gem_path<TAB>default_lint_roller_plugin` per line:
|
|
58
|
+
# the bundle's under Bundler, otherwise the latest installed versions.
|
|
59
|
+
def gems
|
|
60
|
+
specs = defined?(Bundler) && !Gem.loaded_specs.empty? ? Gem.loaded_specs.values : Gem::Specification.latest_specs(true)
|
|
61
|
+
specs.map { |spec| [spec.name, spec.full_gem_path, lint_roller_plugin(spec)].join("\t") }
|
|
62
|
+
.join("\n")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# `latest_specs` returns stubs, which don't carry metadata; loading the
|
|
66
|
+
# full gemspecs takes a few tens of milliseconds.
|
|
67
|
+
def lint_roller_plugin(spec)
|
|
68
|
+
spec = spec.to_spec unless spec.respond_to?(:metadata)
|
|
69
|
+
spec&.metadata&.[]("default_lint_roller_plugin")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def not_found_message
|
|
73
|
+
<<~MSG
|
|
74
|
+
oxcop does not ship a prebuilt binary for #{Gem::Platform.local} (#{RUBY_PLATFORM}).
|
|
75
|
+
Supported platforms: #{Dir.children(EXE_DIR).select { |d| File.directory?(File.join(EXE_DIR, d)) }.join(", ").then { |s| s.empty? ? "none in this gem (see https://github.com/pocketflows/oxruby#releasing for those with prebuilt gems)" : s }}.
|
|
76
|
+
Set OXCOP_BINARY to the path of an oxcop binary built with `cargo build --release`.
|
|
77
|
+
MSG
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: oxcop
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: x86_64-linux-gnu
|
|
6
|
+
authors:
|
|
7
|
+
- Teddy Liu
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: |
|
|
13
|
+
oxcop reads your .rubocop.yml, accepts RuboCop's command-line options and
|
|
14
|
+
prints RuboCop-compatible output, but runs as a native binary. It tracks
|
|
15
|
+
RuboCop 1.91.0.
|
|
16
|
+
email:
|
|
17
|
+
- theodoretliu@gmail.com
|
|
18
|
+
executables:
|
|
19
|
+
- oxcop
|
|
20
|
+
extensions: []
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- THIRD_PARTY_NOTICES.md
|
|
26
|
+
- exe/oxcop
|
|
27
|
+
- exe/x86_64-linux-gnu/oxcop
|
|
28
|
+
- lib/oxcop.rb
|
|
29
|
+
- lib/oxcop/version.rb
|
|
30
|
+
homepage: https://github.com/pocketflows/oxruby
|
|
31
|
+
licenses:
|
|
32
|
+
- MIT
|
|
33
|
+
metadata:
|
|
34
|
+
homepage_uri: https://github.com/pocketflows/oxruby
|
|
35
|
+
source_code_uri: https://github.com/pocketflows/oxruby
|
|
36
|
+
rubygems_mfa_required: 'true'
|
|
37
|
+
rdoc_options: []
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '3.1'
|
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
requirements: []
|
|
51
|
+
rubygems_version: 4.0.3
|
|
52
|
+
specification_version: 4
|
|
53
|
+
summary: A drop-in replacement for RuboCop, rewritten in Rust on the Prism parser
|
|
54
|
+
test_files: []
|