nitrocop 0.0.1.pre2-aarch64-linux

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4056ea2539167dcc58fd968e1f1d8b890a53229776ab1294e8289592e6c97a76
4
+ data.tar.gz: 919a6420360facf10ff37e43a0aa000c6a61ebad4ca56eef9578e56bc3a21114
5
+ SHA512:
6
+ metadata.gz: 0bc01e6744783a72b3f0966ff285f5005ff27ef8e8e211a6f4d6552d7a5ec7dc5c2a34f00677b3ad9286367ee865a7b87d0f55a9cc102d5adfd9804fb2382d2f
7
+ data.tar.gz: 554ecc6ef9be316a2cc13cc6eb89ce899a487e177d4b4aa76e940f8a05d2d3051bf3f572a8d8c8a204b1f5e7f1e5ff1c500c438622625a30ea4e9551a604808d
data/exe/nitrocop ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "nitrocop"
5
+
6
+ exe = Nitrocop.executable
7
+
8
+ if exe
9
+ exec(exe, *ARGV)
10
+ else
11
+ platform = defined?(Gem::Platform) ? Gem::Platform.local.to_s : RUBY_PLATFORM
12
+ abort <<~MSG
13
+ nitrocop: no precompiled binary for #{platform}
14
+
15
+ Supported platforms: arm64-darwin, x86_64-darwin, x86_64-linux, x86_64-linux-musl, aarch64-linux
16
+
17
+ To install from source (requires Rust 1.85+):
18
+ cargo install nitrocop
19
+ MSG
20
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "tmpdir"
5
+
6
+ # Builds nitrocop gems — both base (fallback) and platform-specific variants.
7
+ #
8
+ # Base gem: no binary, users on unsupported platforms get a helpful error.
9
+ # Platform gem: includes precompiled binary in libexec/.
10
+ class GemBuilder
11
+ GEM_SOURCE = File.expand_path("..", __dir__)
12
+
13
+ attr_reader :version, :platform, :binary_path
14
+
15
+ # @param version [String] gem version (e.g. "0.1.0")
16
+ # @param platform [String, nil] platform string (e.g. "arm64-darwin"), nil for base gem
17
+ # @param binary_path [String, nil] path to compiled binary, required for platform gems
18
+ def initialize(version:, platform: nil, binary_path: nil)
19
+ @version = version
20
+ @platform = platform
21
+ @binary_path = binary_path
22
+ end
23
+
24
+ def platform?
25
+ !platform.nil?
26
+ end
27
+
28
+ # Assembles gem contents into the given directory. Useful for testing.
29
+ # Returns the directory path.
30
+ def assemble(dir)
31
+ FileUtils.cp_r(File.join(GEM_SOURCE, "lib"), dir)
32
+ FileUtils.cp_r(File.join(GEM_SOURCE, "exe"), dir)
33
+
34
+ if platform?
35
+ raise "Binary not found: #{binary_path}" unless File.file?(binary_path)
36
+
37
+ libexec = File.join(dir, "libexec")
38
+ FileUtils.mkdir_p(libexec)
39
+ FileUtils.cp(binary_path, File.join(libexec, "nitrocop"))
40
+ FileUtils.chmod(0o755, File.join(libexec, "nitrocop"))
41
+ end
42
+
43
+ patch_version(dir)
44
+ write_gemspec(dir)
45
+ dir
46
+ end
47
+
48
+ # Builds the .gem file and moves it to output_dir.
49
+ # Returns the path to the built .gem file.
50
+ def build(output_dir: Dir.pwd)
51
+ Dir.mktmpdir("nitrocop-gem-") do |tmpdir|
52
+ assemble(tmpdir)
53
+
54
+ Dir.chdir(tmpdir) do
55
+ system("gem", "build", "nitrocop.gemspec", exception: true)
56
+ end
57
+
58
+ gem_file = Dir.glob(File.join(tmpdir, "nitrocop-*.gem")).first
59
+ dest = File.join(output_dir, File.basename(gem_file))
60
+ FileUtils.mv(gem_file, dest)
61
+ dest
62
+ end
63
+ end
64
+
65
+ # Returns the gemspec content as a string.
66
+ def gemspec_content
67
+ lines = []
68
+ lines << '# frozen_string_literal: true'
69
+ lines << ''
70
+ lines << 'require_relative "lib/nitrocop"'
71
+ lines << ''
72
+ lines << 'Gem::Specification.new do |spec|'
73
+ lines << ' spec.name = "nitrocop"'
74
+ lines << ' spec.version = Nitrocop::VERSION'
75
+ lines << " spec.platform = \"#{platform}\"" if platform?
76
+ lines << ' spec.authors = ["6"]'
77
+ lines << ''
78
+ lines << ' spec.summary = "Fast Ruby linter targeting RuboCop compatibility"'
79
+ if platform?
80
+ lines << ' spec.description = "A Ruby linter written in Rust that reads your existing .rubocop.yml " \\'
81
+ lines << ' "and runs 900+ cops. " \\'
82
+ lines << " \"Platform variant: #{platform}.\""
83
+ else
84
+ lines << ' spec.description = "A Ruby linter written in Rust that reads your existing .rubocop.yml " \\'
85
+ lines << ' "and runs 900+ cops."'
86
+ end
87
+ lines << ' spec.homepage = "https://github.com/6/nitrocop"'
88
+ lines << ' spec.license = "MIT"'
89
+ lines << ''
90
+ lines << ' spec.required_ruby_version = ">= 3.1.0"'
91
+ lines << ''
92
+ lines << ' spec.metadata["source_code_uri"] = spec.homepage'
93
+ lines << ' spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"'
94
+ lines << ''
95
+ lines << ' spec.files = Dir["lib/**/*", "exe/**/*", "libexec/**/*"]'
96
+ lines << ' spec.bindir = "exe"'
97
+ lines << ' spec.executables = ["nitrocop"]'
98
+ lines << 'end'
99
+ lines.join("\n") + "\n"
100
+ end
101
+
102
+ private
103
+
104
+ def patch_version(dir)
105
+ version_file = File.join(dir, "lib", "nitrocop.rb")
106
+ content = File.read(version_file)
107
+ content.sub!(/VERSION = ".*"/, %(VERSION = "#{version}"))
108
+ File.write(version_file, content)
109
+ end
110
+
111
+ def write_gemspec(dir)
112
+ File.write(File.join(dir, "nitrocop.gemspec"), gemspec_content)
113
+ end
114
+ end
data/lib/nitrocop.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nitrocop
4
+ VERSION = "0.0.1.pre2"
5
+
6
+ # Returns the path to the precompiled nitrocop binary, or nil if
7
+ # no binary is bundled (e.g. the base/fallback gem on an unsupported platform).
8
+ def self.executable
9
+ bin = File.expand_path("../libexec/nitrocop", __dir__)
10
+ bin if File.file?(bin) && File.executable?(bin)
11
+ end
12
+ end
data/libexec/nitrocop ADDED
Binary file
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nitrocop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre2
5
+ platform: aarch64-linux
6
+ authors:
7
+ - '6'
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: 'A Ruby linter written in Rust that reads your existing .rubocop.yml
13
+ and runs 900+ cops. Platform variant: aarch64-linux.'
14
+ executables:
15
+ - nitrocop
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - exe/nitrocop
20
+ - lib/gem_builder.rb
21
+ - lib/nitrocop.rb
22
+ - libexec/nitrocop
23
+ homepage: https://github.com/6/nitrocop
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ source_code_uri: https://github.com/6/nitrocop
28
+ changelog_uri: https://github.com/6/nitrocop/releases
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.1.0
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.6.9
44
+ specification_version: 4
45
+ summary: Fast Ruby linter targeting RuboCop compatibility
46
+ test_files: []