activerecord-s3-bucket-name-validator 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d92a2144185d4209736c4667fa431fcdfd6c03bc54f5438419418bfde54afd35
4
- data.tar.gz: f34996e4c9cca6eaa546937100d37d3b64d8d64cf94d3063b603ff7393232846
3
+ metadata.gz: 1db90636507488edf3d8fd10ff6d162cc3602535cc5393c1dc978e30453af4a1
4
+ data.tar.gz: a2e5f151e3e5b4ac5fd1e155e7effb88a7a4a1779c9b288730ffe46a592f83d5
5
5
  SHA512:
6
- metadata.gz: 75201a63526f505e40cdb651da3e40d128ea7484e6ee19b4c22784282346c93ae71f10b1a2c7061e6d4b9db0518e9551c5ac35117f0f2c2726bd20a60a2561d0
7
- data.tar.gz: a8b6e2f259af30265a5d3fbb434f72f35febc98a5cc481a32f463623bf7768c7739d68e971666d12d4eb635d3b405fce9ed353f79e80a209dc96168a7845e77d
6
+ metadata.gz: 949db64c400b317437bf4db49782f5249024d660a05c35ad9fec7c93ba4f53c2eaed39cc5d29249d9e99756f4a8ae06406c409e22c48bb092ab3e31617fecf5c
7
+ data.tar.gz: 8a9113a96a8d1fa4afcf1224ed7a48a0d8eaf99958884abe00bac0c83f878b07faa50d9d756c262e9beb198a32203dbe89813b9b790eed83134f55f7d81eb4aa
data/README.md CHANGED
@@ -23,8 +23,8 @@ bundle install
23
23
 
24
24
  ## Compatibility
25
25
 
26
- - Ruby: 3.1, 3.2, 3.3, 3.4 (CI runs 3.2–3.4)
27
- - ActiveModel: 7.2, 8.0 (CI targets)
26
+ - Ruby: 3.1, 3.2, 3.3, 3.4, 4.0 (CI runs 3.2–4.0)
27
+ - ActiveModel: 7.2, 8.0, 8.1 (CI targets)
28
28
  - Rails/ActiveRecord: supported via ActiveModel::Validations (no Rails runtime dependency)
29
29
 
30
30
  ## Quickstart
@@ -109,8 +109,8 @@ bundle install
109
109
  bundle exec rake test
110
110
 
111
111
  # With ActiveRecord integration (in-memory sqlite)
112
- AR_INTEGRATION=1 ACTIVERECORD_VERSION="~> 8.0" bundle install
113
- AR_INTEGRATION=1 ACTIVERECORD_VERSION="~> 8.0" bundle exec rake test
112
+ AR_INTEGRATION=1 ACTIVERECORD_VERSION="~> 8.1" bundle install
113
+ AR_INTEGRATION=1 ACTIVERECORD_VERSION="~> 8.1" bundle exec rake test
114
114
  ```
115
115
 
116
116
  ## License
@@ -29,10 +29,14 @@ Gem::Specification.new do |spec|
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
32
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
- end
32
+ # Keep the package lean: include library code, locales, and top-level docs only.
33
+ spec.files = Dir[
34
+ "lib/**/*",
35
+ "config/locales/**/*",
36
+ "README*",
37
+ "LICENSE*",
38
+ "*.gemspec"
39
+ ]
36
40
  spec.bindir = "exe"
37
41
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
42
  spec.require_paths = ["lib"]
@@ -16,4 +16,3 @@ module Activerecord
16
16
  end
17
17
  end
18
18
  end
19
-
@@ -3,7 +3,7 @@ module Activerecord
3
3
  module Bucket
4
4
  module Name
5
5
  module Validator
6
- VERSION = "0.1.2"
6
+ VERSION = "0.1.3"
7
7
  end
8
8
  end
9
9
  end
@@ -23,7 +23,7 @@ end
23
23
  begin
24
24
  locales_glob = File.expand_path("../../../../../config/locales/*.yml", __FILE__)
25
25
  I18n.load_path += Dir[locales_glob] if Dir.exist?(File.dirname(locales_glob))
26
- rescue StandardError
26
+ rescue
27
27
  # ignore i18n loading errors
28
28
  end
29
29
 
@@ -44,25 +44,25 @@ class S3BucketNameValidator < ActiveModel::EachValidator
44
44
  return if blank_ok?(value)
45
45
 
46
46
  valid = case type
47
- when :general_purpose then validate_general_purpose(value, transfer_acceleration: !!options[:transfer_acceleration])
48
- when :directory then validate_directory_bucket(value)
49
- when :table then validate_table_bucket(value)
50
- else
51
- record.errors.add(attribute, :invalid, message: "unknown bucket type: #{type}")
52
- false
53
- end
47
+ when :general_purpose then validate_general_purpose(value, transfer_acceleration: !!options[:transfer_acceleration])
48
+ when :directory then validate_directory_bucket(value)
49
+ when :table then validate_table_bucket(value)
50
+ else
51
+ record.errors.add(attribute, :invalid, message: "unknown bucket type: #{type}")
52
+ false
53
+ end
54
54
 
55
55
  unless valid
56
56
  error_key = if type == :general_purpose && options[:transfer_acceleration] && value.include?(".")
57
- :s3_bucket_name_invalid_transfer_acceleration
58
- else
59
- case type
60
- when :general_purpose then :s3_bucket_name_invalid_general
61
- when :directory then :s3_bucket_name_invalid_directory
62
- when :table then :s3_bucket_name_invalid_table
63
- else :s3_bucket_name_invalid
64
- end
65
- end
57
+ :s3_bucket_name_invalid_transfer_acceleration
58
+ else
59
+ case type
60
+ when :general_purpose then :s3_bucket_name_invalid_general
61
+ when :directory then :s3_bucket_name_invalid_directory
62
+ when :table then :s3_bucket_name_invalid_table
63
+ else :s3_bucket_name_invalid
64
+ end
65
+ end
66
66
  record.errors.add(attribute, error_key)
67
67
  end
68
68
  end
@@ -78,7 +78,7 @@ class S3BucketNameValidator < ActiveModel::EachValidator
78
78
  # Based on AWS docs: General purpose bucket naming rules
79
79
  def validate_general_purpose(name, transfer_acceleration: false)
80
80
  return false unless length_between?(name, 3, 63)
81
- return false unless name =~ /\A[a-z0-9.-]+\z/
81
+ return false unless /\A[a-z0-9.-]+\z/.match?(name)
82
82
  return false unless begins_and_ends_with_alnum?(name)
83
83
  return false if name.include?("..")
84
84
  return false if ip_like?(name)
@@ -91,10 +91,10 @@ class S3BucketNameValidator < ActiveModel::EachValidator
91
91
  # Based on AWS docs: Directory bucket naming rules (S3 Express One Zone)
92
92
  def validate_directory_bucket(name)
93
93
  return false unless length_between?(name, 3, 63)
94
- return false unless name =~ /\A[a-z0-9-]+\z/
94
+ return false unless /\A[a-z0-9-]+\z/.match?(name)
95
95
  return false unless begins_and_ends_with_alnum?(name)
96
96
  # must contain --<zone-id>--x-s3 suffix
97
- return false unless name =~ /--[a-z0-9-]+--x-s3\z/
97
+ return false unless /--[a-z0-9-]+--x-s3\z/.match?(name)
98
98
  # reserved prefixes/suffixes still apply
99
99
  return false if name.start_with?("xn--", "sthree-", "sthree-configurator", "amzn-s3-demo-")
100
100
  return false if name.end_with?("-s3alias", "--ol-s3", ".mrap", "--table-s3")
@@ -104,7 +104,7 @@ class S3BucketNameValidator < ActiveModel::EachValidator
104
104
  # Based on AWS docs: S3 Tables bucket naming rules
105
105
  def validate_table_bucket(name)
106
106
  return false unless length_between?(name, 3, 63)
107
- return false unless name =~ /\A[a-z0-9-]+\z/
107
+ return false unless /\A[a-z0-9-]+\z/.match?(name)
108
108
  return false unless begins_and_ends_with_alnum?(name)
109
109
  return false unless RESERVED_PREFIXES_TABLE.none? { |p| name.start_with?(p) }
110
110
  return false unless RESERVED_SUFFIXES_TABLE.none? { |s| name.end_with?(s) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-s3-bucket-name-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Poli
@@ -93,18 +93,9 @@ executables: []
93
93
  extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
- - ".github/workflows/release.yaml"
97
- - ".github/workflows/test.yml"
98
- - ".gitignore"
99
- - ".ruby-version"
100
- - Gemfile
101
- - Gemfile.lock
102
96
  - LICENSE.txt
103
97
  - README.md
104
- - Rakefile
105
98
  - activerecord-s3-bucket-name-validator.gemspec
106
- - bin/console
107
- - bin/setup
108
99
  - config/locales/de.yml
109
100
  - config/locales/en.yml
110
101
  - config/locales/es.yml
@@ -1,28 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- tags:
6
- - v*
7
- workflow_dispatch:
8
-
9
- permissions:
10
- contents: read
11
- id-token: write
12
-
13
- jobs:
14
- release:
15
- runs-on: ubuntu-latest
16
- steps:
17
- - uses: actions/checkout@v5
18
- - name: Set up Ruby
19
- uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: '3.4'
22
- bundler-cache: false
23
- - name: Configure RubyGems credentials (OIDC)
24
- uses: rubygems/configure-rubygems-credentials@v1.0.0
25
- - name: Build gem
26
- run: gem build *.gemspec
27
- - name: Push gem
28
- run: gem push *.gem
@@ -1,77 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- workflow_dispatch:
5
- push:
6
- branches: [ main, master ]
7
- pull_request:
8
- branches: [ main, master ]
9
- schedule:
10
- - cron: "0 0 * * 0"
11
-
12
- permissions:
13
- contents: read
14
-
15
- concurrency:
16
- group: test-${{ github.ref }}
17
- cancel-in-progress: true
18
-
19
- jobs:
20
- test:
21
- strategy:
22
- matrix:
23
- ruby: ["3.2", "3.3", "3.4"]
24
- activemodel: ["~> 7.2", "~> 8.0"]
25
- runs-on: ubuntu-latest
26
-
27
- steps:
28
- - uses: actions/checkout@v5
29
- - name: Set up Environment Variables
30
- run: |
31
- echo "ACTIVEMODEL_VERSION=${{ matrix.activemodel }}" >> $GITHUB_ENV
32
-
33
- - name: Set up Ruby
34
- uses: ruby/setup-ruby@v1
35
- with:
36
- ruby-version: ${{ matrix.ruby }}
37
- bundler-cache: false
38
- - name: Prepare Gemfile for matrix
39
- run: |
40
- bundle config set frozen false
41
- bundle lock --add-platform ruby --add-platform x86_64-linux || true
42
- if [ -n "${{ matrix.activemodel }}" ]; then
43
- bundle lock --update activemodel || true
44
- fi
45
- - name: Install dependencies
46
- run: bundle install --jobs 4 --retry 1
47
-
48
- - name: Run tests
49
- run: bundle exec rake test
50
-
51
- ar_integration:
52
- strategy:
53
- matrix:
54
- ruby: ["3.2", "3.3", "3.4"]
55
- activerecord: ["~> 7.2", "~> 8.0"]
56
- runs-on: ubuntu-latest
57
-
58
- steps:
59
- - uses: actions/checkout@v5
60
- - name: Set up Environment Variables
61
- run: |
62
- echo "AR_INTEGRATION=1" >> $GITHUB_ENV
63
- echo "ACTIVERECORD_VERSION=${{ matrix.activerecord }}" >> $GITHUB_ENV
64
- - name: Set up Ruby
65
- uses: ruby/setup-ruby@v1
66
- with:
67
- ruby-version: ${{ matrix.ruby }}
68
- bundler-cache: false
69
- - name: Prepare Gemfile for AR matrix
70
- run: |
71
- bundle config set frozen false
72
- bundle lock --add-platform ruby --add-platform x86_64-linux || true
73
- bundle lock --update activerecord sqlite3 || true
74
- - name: Install dependencies
75
- run: bundle install --jobs 4 --retry 1
76
- - name: Run integration tests
77
- run: bundle exec rake test
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- /vendor/
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.4.3
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Allow CI to pin a specific ActiveModel version via env var
6
- am_ver = ENV["ACTIVEMODEL_VERSION"]
7
- gem "activemodel", am_ver if am_ver
8
-
9
- # Optional: ActiveRecord integration testing
10
- if ENV["AR_INTEGRATION"] == "1"
11
- ar_ver = ENV["ACTIVERECORD_VERSION"]
12
- gem "activerecord", ar_ver || ">= 7.0", "< 9"
13
- sqlite_req = (ar_ver && ar_ver.start_with?("~> 8")) ? ">= 2.1" : ">= 1.6"
14
- gem "sqlite3", sqlite_req
15
- end
16
-
17
- # Specify your gem's dependencies in activerecord-s3-bucket-name-validator.gemspec
18
- gemspec
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- activerecord-s3-bucket-name-validator (0.1.0)
5
- activemodel (>= 7.0, < 9)
6
- i18n (>= 1.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activemodel (8.0.3)
12
- activesupport (= 8.0.3)
13
- activesupport (8.0.3)
14
- base64
15
- benchmark (>= 0.3)
16
- bigdecimal
17
- concurrent-ruby (~> 1.0, >= 1.3.1)
18
- connection_pool (>= 2.2.5)
19
- drb
20
- i18n (>= 1.6, < 2)
21
- logger (>= 1.4.2)
22
- minitest (>= 5.1)
23
- securerandom (>= 0.3)
24
- tzinfo (~> 2.0, >= 2.0.5)
25
- uri (>= 0.13.1)
26
- base64 (0.3.0)
27
- benchmark (0.4.1)
28
- bigdecimal (3.2.3)
29
- concurrent-ruby (1.3.5)
30
- connection_pool (2.5.4)
31
- drb (2.2.3)
32
- i18n (1.14.7)
33
- concurrent-ruby (~> 1.0)
34
- logger (1.7.0)
35
- minitest (5.25.5)
36
- rake (13.3.0)
37
- securerandom (0.4.1)
38
- tzinfo (2.0.6)
39
- concurrent-ruby (~> 1.0)
40
- uri (1.0.3)
41
-
42
- PLATFORMS
43
- arm64-darwin-24
44
- ruby
45
-
46
- DEPENDENCIES
47
- activerecord-s3-bucket-name-validator!
48
- bundler (>= 1.17)
49
- minitest (>= 5.0)
50
- rake (>= 10.0)
51
-
52
- BUNDLED WITH
53
- 2.6.7
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "activerecord/s3/bucket/name/validator"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here