Skip to content

Commit 36e35b5

Browse files
committed
lib/sqlite_extensions-uuid.rb, more rubocop
1 parent 73dc067 commit 36e35b5

File tree

8 files changed

+58
-34
lines changed

8 files changed

+58
-34
lines changed

.rubocop.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
AllCops:
2-
TargetRubyVersion: 3.0
1+
require:
2+
- standard
3+
- rubocop-rspec
4+
- rubocop-rake
5+
- rubocop-performance
36

4-
Style/StringLiterals:
5-
EnforcedStyle: double_quotes
7+
inherit_gem:
8+
standard: config/base.yml
69

7-
Style/StringLiteralsInInterpolation:
8-
EnforcedStyle: double_quotes
10+
AllCops:
11+
NewCops: enable
12+
TargetRubyVersion: 3.0
913

10-
Style/Documentation:
14+
RSpec/MultipleExpectations:
1115
Enabled: false
1216

13-
Metrics:
14-
Exclude:
15-
- 'test/test_*.rb'
17+
RSpec/ExampleLength:
18+
Max: 25

Gemfile.lock

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GEM
1818
reline (>= 0.4.2)
1919
json (2.7.2)
2020
language_server-protocol (3.17.0.3)
21+
lint_roller (1.1.0)
2122
mini_portile2 (2.8.8)
2223
parallel (1.26.3)
2324
parser (3.3.5.0)
@@ -60,9 +61,28 @@ GEM
6061
unicode-display_width (>= 2.4.0, < 3.0)
6162
rubocop-ast (1.32.3)
6263
parser (>= 3.3.1.0)
64+
rubocop-performance (1.23.1)
65+
rubocop (>= 1.48.1, < 2.0)
66+
rubocop-ast (>= 1.31.1, < 2.0)
67+
rubocop-rake (0.6.0)
68+
rubocop (~> 1.0)
69+
rubocop-rspec (3.4.0)
70+
rubocop (~> 1.61)
6371
ruby-progressbar (1.13.0)
6472
sqlite3 (2.4.0)
6573
mini_portile2 (~> 2.8.0)
74+
standard (1.35.0.1)
75+
language_server-protocol (~> 3.17.0.2)
76+
lint_roller (~> 1.0)
77+
rubocop (~> 1.62)
78+
standard-custom (~> 1.0.0)
79+
standard-performance (~> 1.3)
80+
standard-custom (1.0.2)
81+
lint_roller (~> 1.0)
82+
rubocop (~> 1.50)
83+
standard-performance (1.6.0)
84+
lint_roller (~> 1.1)
85+
rubocop-performance (~> 1.23.0)
6686
stringio (3.1.1)
6787
unicode-display_width (2.6.0)
6888

@@ -74,8 +94,11 @@ DEPENDENCIES
7494
rake
7595
rake-compiler
7696
rspec
77-
rubocop
97+
rubocop-performance
98+
rubocop-rake
99+
rubocop-rspec
78100
sqlite_extensions-uuid!
101+
standard
79102

80103
BUNDLED WITH
81104
2.5.21

Rakefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ RuboCop::RakeTask.new
99
require "rspec/core/rake_task"
1010
RSpec::Core::RakeTask.new(:spec)
1111

12-
task build: :compile
13-
14-
GEMSPEC = Gem::Specification.load(Dir.glob("*.gemspec").first)
15-
16-
Rake::ExtensionTask.new("sqlite_extensions/uuid", GEMSPEC) do |ext|
12+
Rake::ExtensionTask.new("sqlite_extensions/uuid") do |ext|
1713
ext.name = "uuid"
1814
ext.lib_dir = "lib/sqlite_extensions/uuid"
1915
end
2016

17+
desc "Update vendored SQLite files"
2118
task :update do
2219
sh "wget https://sqlite.org/2024/sqlite-autoconf-3460100.tar.gz"
2320
sh "tar xvf sqlite-autoconf-3460100.tar.gz"
@@ -28,6 +25,7 @@ task :update do
2825
sh "mv -v ./uuid.c ext/sqlite_extensions/uuid/"
2926
end
3027

28+
desc "Run specs"
3129
task spec: :compile
3230

3331
task default: %i[clobber compile spec rubocop]

lib/sqlite_extensions-uuid.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "sqlite_extensions/uuid"

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
config.order = :random
77
Kernel.srand config.seed
88
end
9+
10+
require "sqlite_extensions-uuid"

spec/sqlite_spec.rb renamed to spec/sqlite_extensions/sqlite_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# frozen_string_literal: true
22

3-
require "sqlite_extensions/uuid"
4-
5-
# NOTE: `sqlite3` isn't required by our gem, but we need it for these tests.
3+
# not required by our gem, but needed for these tests
64
require "sqlite3"
75

8-
RSpec.describe "Sqlite3 usage" do
6+
RSpec.describe "Sqlite3 usage" do # rubocop:disable RSpec/DescribeClass
97
before do
10-
gemspec = instance_double(Gem::Specification, require_path: File.join(__dir__, "../lib"))
8+
gemspec = instance_double(
9+
Gem::Specification,
10+
require_path: File.join(__dir__, "../../lib")
11+
)
1112
allow(Gem).to receive(:loaded_specs).and_return("sqlite_extensions-uuid" => gemspec)
1213
end
1314

spec/uuid_spec.rb renamed to spec/sqlite_extensions/uuid_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

3-
require "sqlite_extensions/uuid"
4-
5-
RSpec.describe SqliteExtensions::UUID do # rubocop:disable Metrics/BlockLength
3+
RSpec.describe SqliteExtensions::UUID do
64
it "has a version" do
75
expect(described_class::VERSION).to eq "1.0.1"
86
end
@@ -14,14 +12,14 @@
1412
end
1513

1614
it "returns the path to the compiled extension" do
17-
path = SqliteExtensions::UUID.to_path
15+
path = described_class.to_path
1816

1917
expect(path).to eq "foo/sqlite_extensions/uuid/uuid"
2018
end
2119
end
2220

2321
it "has the correct gemspec info" do
24-
path = File.expand_path("../sqlite_extensions-uuid.gemspec", __dir__)
22+
path = File.expand_path("../../sqlite_extensions-uuid.gemspec", __dir__)
2523
gemspec = Gem::Specification.load path
2624

2725
expect(gemspec).to have_attributes(
@@ -32,6 +30,7 @@
3230
ext/sqlite_extensions/uuid/sqlite3.h
3331
ext/sqlite_extensions/uuid/sqlite3ext.h
3432
ext/sqlite_extensions/uuid/uuid.c
33+
lib/sqlite_extensions-uuid.rb
3534
lib/sqlite_extensions/uuid.rb
3635
lib/sqlite_extensions/uuid/version.rb
3736
],

sqlite_extensions-uuid.gemspec

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ Gem::Specification.new do |spec|
1313
spec.license = "MIT"
1414
spec.required_ruby_version = ">= 3.0.0"
1515

16-
spec.files = %w[
17-
lib/sqlite_extensions/uuid.rb
18-
lib/sqlite_extensions/uuid/version.rb
19-
ext/sqlite_extensions/uuid/sqlite3ext.h
20-
ext/sqlite_extensions/uuid/sqlite3.h
21-
ext/sqlite_extensions/uuid/uuid.c
22-
]
16+
spec.files = Dir.glob("lib/**/*.rb") + Dir.glob("ext/**/*.{c,h}")
2317
spec.require_paths = ["lib"]
2418
spec.extensions = ["ext/sqlite_extensions/uuid/extconf.rb"]
2519

@@ -29,5 +23,8 @@ Gem::Specification.new do |spec|
2923
spec.add_development_dependency "rake"
3024
spec.add_development_dependency "rake-compiler"
3125
spec.add_development_dependency "rspec"
32-
spec.add_development_dependency "rubocop"
26+
spec.add_development_dependency "standard"
27+
spec.add_development_dependency "rubocop-rake"
28+
spec.add_development_dependency "rubocop-rspec"
29+
spec.add_development_dependency "rubocop-performance"
3330
end

0 commit comments

Comments
 (0)