Skip to content

Commit 16773a2

Browse files
committed
chore: Add RuboCop and build configurations
1 parent b8db6e6 commit 16773a2

File tree

8 files changed

+216
-89
lines changed

8 files changed

+216
-89
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*.o
66

77
Gemfile.lock
8-
.rspec_statu
8+
.rspec_status
99
.ruby-version
1010
.vscode
1111

.rspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--format documentation
2+
--color
3+
--require spec_helper
4+
--order rand

.rubocop.yml

Lines changed: 49 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,54 @@
1-
# from https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard
2-
require:
3-
- standard
4-
- standard-custom
5-
- standard-performance
6-
- rubocop-performance
7-
- rubocop-minitest
8-
9-
inherit_gem:
10-
standard: config/base.yml
11-
standard-custom: config/base.yml
12-
standard-performance: config/base.yml
13-
141
AllCops:
15-
SuggestExtensions: false
16-
TargetRubyVersion: 3.1
2+
Exclude:
3+
- 'vendor/**/*'
4+
- 'spec/**/*'
175

18-
Naming/InclusiveLanguage:
19-
Enabled: true
6+
NewCops: enable
7+
8+
TargetRubyVersion: 3.4
209

21-
Metrics/BlockLength:
22-
Exclude:
23-
- 'spec/**/*'
10+
AutoCorrect: true
11+
12+
Style:
13+
StringLiterals:
14+
EnforcedStyle: double_quotes
15+
16+
ParameterLists:
17+
EnforcedStyle: compact
18+
19+
RedundantSelf:
20+
Enabled: true
21+
22+
ModifierForm:
23+
AllowModifierForm: true
2424

25-
Minitest/AssertInDelta: # new in 0.10
26-
Enabled: true
27-
Minitest/AssertKindOf: # new in 0.10
28-
Enabled: true
29-
Minitest/AssertOperator: # new in 0.32
30-
Enabled: true
31-
Minitest/AssertOutput: # new in 0.10
32-
Enabled: true
33-
Minitest/AssertPathExists: # new in 0.10
34-
Enabled: true
35-
Minitest/AssertPredicate: # new in 0.18
36-
Enabled: true
37-
Minitest/AssertRaisesCompoundBody: # new in 0.21
38-
Enabled: true
39-
Minitest/AssertRaisesWithRegexpArgument: # new in 0.22
40-
Enabled: true
41-
Minitest/AssertSame: # new in 0.26
42-
Enabled: true
43-
Minitest/AssertSilent: # new in 0.10
44-
Enabled: true
45-
Minitest/AssertWithExpectedArgument: # new in 0.11
46-
Enabled: true
47-
Minitest/AssertionInLifecycleHook: # new in 0.10
48-
Enabled: true
49-
Minitest/DuplicateTestRun: # new in 0.19
50-
Enabled: true
51-
Minitest/EmptyLineBeforeAssertionMethods: # new in 0.23
25+
Layout:
26+
LineLength:
27+
Max: 120
28+
29+
FirstParameterIndentation:
30+
恩abled: true
31+
EnforcedStyle: indented
32+
33+
Indentation:
34+
Width:
35+
Width: 2
36+
37+
Metrics:
38+
ClassLength:
39+
Max: 200
40+
41+
MethodLength:
42+
Max: 20
43+
44+
ParameterLists:
45+
Max: 5
46+
47+
Lint/AmbiguousOperator:
5248
Enabled: false
53-
Minitest/LifecycleHooksOrder: # new in 0.28
54-
Enabled: true
55-
Minitest/LiteralAsActualArgument: # new in 0.10
56-
Enabled: true
57-
Minitest/MultipleAssertions: # new in 0.10
58-
Enabled: true
59-
Minitest/NonExecutableTestMethod: # new in 0.34
60-
Enabled: true
61-
Minitest/NonPublicTestMethod: # new in 0.27
62-
Enabled: true
63-
Minitest/RedundantMessageArgument: # new in 0.34
64-
Enabled: true
65-
Minitest/RefuteInDelta: # new in 0.10
66-
Enabled: true
67-
Minitest/RefuteKindOf: # new in 0.10
68-
Enabled: true
69-
Minitest/RefuteOperator: # new in 0.32
70-
Enabled: true
71-
Minitest/RefutePathExists: # new in 0.10
72-
Enabled: true
73-
Minitest/RefutePredicate: # new in 0.18
74-
Enabled: true
75-
Minitest/RefuteSame: # new in 0.26
76-
Enabled: true
77-
Minitest/ReturnInTestMethod: # new in 0.31
78-
Enabled: true
79-
Minitest/SkipEnsure: # new in 0.20
80-
Enabled: true
81-
Minitest/SkipWithoutReason: # new in 0.24
82-
Enabled: true
83-
Minitest/TestFileName: # new in 0.26
84-
Enabled: true
85-
Minitest/TestMethodName: # new in 0.10
86-
Enabled: true
87-
Minitest/UnreachableAssertion: # new in 0.14
88-
Enabled: true
89-
Minitest/UnspecifiedException: # new in 0.10
90-
Enabled: true
91-
Minitest/UselessAssertion: # new in 0.26
92-
Enabled: true
49+
50+
Style/Documentation:
51+
Enabled: false
52+
53+
Style/AccessModifierDeclarations:
54+
Enabled: false

Gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
source "https://rubygems.org"
2+
3+
gemspec
4+
5+
group :test do
6+
gem "rspec", "3.12.0"
7+
gem "ruby_memcheck", "3.0.1" if Gem::Platform.local.os == "linux"
8+
gem "rake-compiler", "1.2.9"
9+
gem "rake-compiler-dock", "1.9.1"
10+
end
11+
12+
group :development do
13+
gem "rdoc", "6.12.0"
14+
gem "rubocop", "1.59.0", require: false
15+
end

LICENSE.txt renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Copyright 2025 chDB, Inc.
188188
same "printed page" as the copyright notice for easier
189189
identification within third-party archives.
190190

191-
Copyright 2023 chDB, Inc.
191+
Copyright 2025 chDB, Inc.
192192

193193
Licensed under the Apache License, Version 2.0 (the "License");
194194
you may not use this file except in compliance with the License.

Rakefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "rspec/core/rake_task"
5+
require "rake/extensiontask"
6+
require "rubocop/rake_task"
7+
8+
# require "bundler"
9+
CHDB_SPEC = Bundler.load_gemspec("chdb.gemspec")
10+
11+
RSpec::Core::RakeTask.new(:spec)
12+
13+
Rake::ExtensionTask.new("chdb") do |ext|
14+
ext.lib_dir = "lib/chdb"
15+
end
16+
17+
RuboCop::RakeTask.new
18+
19+
task default: %i[spec rubocop]

chdb.gemspec

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
begin
2+
require_relative "lib/chdb/version"
3+
rescue LoadError
4+
puts "WARNING: could not load ChDB::VERSION"
5+
end
6+
7+
Gem::Specification.new do |s|
8+
s.name = "chdb"
9+
s.version = defined?(ChDB::VERSION) ? ChDB::VERSION : "0.0.0"
10+
11+
s.summary = "Ruby library to interface with the chDB database engine (https://clickhouse.com/docs/chdb)."
12+
s.description = <<~TEXT
13+
Ruby library to interface with the chDB database engine (https://clickhouse.com/docs/chdb). Precompiled
14+
binaries are available for common platforms for recent versions of Ruby.
15+
TEXT
16+
17+
s.authors = ["Xiaozhe Yu", "Auxten Wang"]
18+
19+
s.licenses = ["Apache-2.0"]
20+
21+
s.required_ruby_version = Gem::Requirement.new(">= 3.1")
22+
23+
s.homepage = "https://github.com/chdb-io/chdb-ruby"
24+
s.metadata = {
25+
"homepage_uri" => "https://github.com/chdb-io/chdb-ruby",
26+
"bug_tracker_uri" => "https://github.com/chdb-io/chdb-ruby/issues",
27+
"changelog_uri" => "https://github.com/chdb-io/chdb-ruby/blob/main/CHANGELOG.md",
28+
"source_code_uri" => "https://github.com/chdb-io/chdb-ruby",
29+
30+
# https://guides.rubygems.org/mfa-requirement-opt-in/
31+
"rubygems_mfa_required" => "true"
32+
}
33+
34+
s.files = [
35+
"CHANGELOG.md",
36+
"LICENSE",
37+
"README.md",
38+
"lib/chdb.rb",
39+
"lib/chdb/constants.rb",
40+
"lib/chdb/data_path.rb",
41+
"lib/chdb/database.rb",
42+
"lib/chdb/errors.rb",
43+
"lib/chdb/local_result.rb",
44+
"lib/chdb/parameter_binding.rb",
45+
"lib/chdb/result_handler.rb",
46+
"lib/chdb/result_set.rb",
47+
"lib/chdb/sql_processor.rb",
48+
"lib/chdb/statement.rb",
49+
"lib/chdb/version_info.rb",
50+
"lib/chdb/version.rb"
51+
]
52+
53+
s.rdoc_options = ["--main", "README.md"]
54+
55+
s.extensions << "ext/chdb/extconf.rb"
56+
end

rakelib/check_manifest.rake

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# frozen_string_literal: true
2+
3+
desc "Perform a sanity check on the gemspec file list"
4+
task :check_manifest do
5+
ignore_directories = %w{
6+
.DS_Store
7+
.bundle
8+
.git
9+
.github
10+
.ruby-lsp
11+
.vscode
12+
adr
13+
bin
14+
doc
15+
gems
16+
issues
17+
patches
18+
pkg
19+
ports
20+
rakelib
21+
spec
22+
test
23+
tmp
24+
vendor
25+
[0-9]*
26+
}
27+
ignore_files = %w[
28+
.editorconfig
29+
.gitignore
30+
.rdoc_options
31+
.rspec
32+
.rspec_status
33+
.ruby-version
34+
.rubocop.yml
35+
ext/chdb/*.{c,h}
36+
lib/chdb/chdb*.{bundle,so}
37+
Gemfile*
38+
Rakefile
39+
[a-z]*.{log,out}
40+
[0-9]*
41+
*.gemspec
42+
*.so
43+
]
44+
45+
intended_directories = Dir.children(".")
46+
.select { |filename| File.directory?(filename) }
47+
.reject { |filename| ignore_directories.any? { |ig| File.fnmatch?(ig, filename) } }
48+
49+
intended_files = Dir.children(".")
50+
.select { |filename| File.file?(filename) }
51+
.reject { |filename| ignore_files.any? { |ig| File.fnmatch?(ig, filename, File::FNM_EXTGLOB) } }
52+
53+
intended_files += Dir.glob(intended_directories.map { |d| File.join(d, "/**/*") })
54+
.select { |filename| File.file?(filename) }
55+
.reject { |filename| ignore_files.any? { |ig| File.fnmatch?(ig, filename, File::FNM_EXTGLOB) } }
56+
.sort
57+
58+
spec_files = CHDB_SPEC.files.sort
59+
60+
missing_files = intended_files - spec_files
61+
extra_files = spec_files - intended_files
62+
63+
unless missing_files.empty?
64+
puts "missing:"
65+
missing_files.sort.each { |f| puts "- #{f}" }
66+
end
67+
unless extra_files.empty?
68+
puts "unexpected:"
69+
extra_files.sort.each { |f| puts "+ #{f}" }
70+
end
71+
end

0 commit comments

Comments
 (0)