legion-data 1.6.15 → 1.6.16
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 +4 -4
- data/.github/workflows/ci.yml +36 -2
- data/.rubocop.yml +15 -45
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -1
- data/lib/legion/data/extract/handlers/base.rb +2 -2
- data/lib/legion/data/extract/handlers/xlsx.rb +2 -2
- data/lib/legion/data/extract.rb +2 -1
- data/lib/legion/data/migrations/019_add_audit_hash_chain.rb +40 -11
- data/lib/legion/data/migrations/020_add_webhooks.rb +6 -0
- data/lib/legion/data/settings.rb +1 -1
- data/lib/legion/data/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 458456d016a717f8ee9397f29f01b118ecb7e8a103142defe337788d72762176
|
|
4
|
+
data.tar.gz: cac5a1f8a0bb86ec3087da754d2432ae97ebdc65b003c4ee1aa5e9c9570cc03a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2303a3358441efcea756d106d92a102858eb3534109df30b294925213ae8cba7559969e7f2d01b6ec7ad5bbe1bdca9bf1c5af7d92e1d9fc647eeb8230c8c9269
|
|
7
|
+
data.tar.gz: e50d02ec9745f7dc178bb53ca222c104e822505190b5bacf7ed404e9a61480b4a3361817b220a399b1cd95d323503d66046050e6acabacca2fce493b842e3500
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -10,6 +10,40 @@ jobs:
|
|
|
10
10
|
ci:
|
|
11
11
|
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
12
12
|
|
|
13
|
+
ci-postgres:
|
|
14
|
+
name: "RSpec (PostgreSQL)"
|
|
15
|
+
timeout-minutes: 15
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
services:
|
|
18
|
+
postgres:
|
|
19
|
+
image: postgres:16-alpine
|
|
20
|
+
env:
|
|
21
|
+
POSTGRES_USER: legion
|
|
22
|
+
POSTGRES_PASSWORD: legion
|
|
23
|
+
POSTGRES_DB: legionio
|
|
24
|
+
ports:
|
|
25
|
+
- 5432:5432
|
|
26
|
+
options: >-
|
|
27
|
+
--health-cmd pg_isready
|
|
28
|
+
--health-interval 10s
|
|
29
|
+
--health-timeout 5s
|
|
30
|
+
--health-retries 5
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: ruby/setup-ruby@v1
|
|
34
|
+
with:
|
|
35
|
+
ruby-version: '3.4'
|
|
36
|
+
bundler-cache: true
|
|
37
|
+
- name: Run RSpec (PostgreSQL adapter)
|
|
38
|
+
env:
|
|
39
|
+
LEGION_DATA_ADAPTER: postgres
|
|
40
|
+
LEGION_DATA_HOST: 127.0.0.1
|
|
41
|
+
LEGION_DATA_PORT: 5432
|
|
42
|
+
LEGION_DATA_USER: legion
|
|
43
|
+
LEGION_DATA_PASSWORD: legion
|
|
44
|
+
LEGION_DATA_DATABASE: legionio
|
|
45
|
+
run: bundle exec rspec
|
|
46
|
+
|
|
13
47
|
lint:
|
|
14
48
|
uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main
|
|
15
49
|
|
|
@@ -27,8 +61,8 @@ jobs:
|
|
|
27
61
|
uses: LegionIO/.github/.github/workflows/stale.yml@main
|
|
28
62
|
|
|
29
63
|
release:
|
|
30
|
-
needs: [ci, lint]
|
|
64
|
+
needs: [ci, ci-postgres, lint]
|
|
31
65
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
32
66
|
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
33
67
|
secrets:
|
|
34
|
-
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
68
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.rubocop.yml
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
NewCops: enable
|
|
4
|
-
SuggestExtensions: false
|
|
1
|
+
inherit_gem:
|
|
2
|
+
rubocop-legion: config/core.yml
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
Max:
|
|
8
|
-
|
|
9
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
-
EnforcedStyle: space
|
|
11
|
-
|
|
12
|
-
Layout/HashAlignment:
|
|
13
|
-
EnforcedHashRocketStyle: table
|
|
14
|
-
EnforcedColonStyle: table
|
|
15
|
-
|
|
16
|
-
Metrics/MethodLength:
|
|
17
|
-
Max: 50
|
|
18
|
-
|
|
19
|
-
Metrics/ClassLength:
|
|
20
|
-
Max: 1500
|
|
21
|
-
|
|
22
|
-
Metrics/ModuleLength:
|
|
23
|
-
Max: 1500
|
|
4
|
+
Metrics/ParameterLists:
|
|
5
|
+
Max: 8
|
|
24
6
|
|
|
25
7
|
Metrics/BlockLength:
|
|
26
8
|
Max: 40
|
|
@@ -28,34 +10,22 @@ Metrics/BlockLength:
|
|
|
28
10
|
- 'spec/**/*'
|
|
29
11
|
- 'lib/legion/data/migrations/**/*'
|
|
30
12
|
|
|
31
|
-
|
|
32
|
-
Max: 60
|
|
33
|
-
|
|
34
|
-
Metrics/CyclomaticComplexity:
|
|
35
|
-
Max: 15
|
|
36
|
-
|
|
37
|
-
Metrics/PerceivedComplexity:
|
|
38
|
-
Max: 17
|
|
39
|
-
|
|
40
|
-
Style/Documentation:
|
|
13
|
+
Naming/VariableNumber:
|
|
41
14
|
Enabled: false
|
|
42
15
|
|
|
43
|
-
Style/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Style/FrozenStringLiteralComment:
|
|
47
|
-
Enabled: true
|
|
48
|
-
EnforcedStyle: always
|
|
16
|
+
Style/FileOpen:
|
|
17
|
+
Exclude:
|
|
18
|
+
- 'lib/legion/data/connection.rb'
|
|
49
19
|
|
|
50
|
-
|
|
20
|
+
# Pre-existing patterns — suppress until addressed in a dedicated cleanup PR
|
|
21
|
+
ThreadSafety/ClassInstanceVariable:
|
|
51
22
|
Enabled: false
|
|
52
23
|
|
|
53
|
-
|
|
24
|
+
ThreadSafety/ClassAndModuleAttributes:
|
|
54
25
|
Enabled: false
|
|
55
26
|
|
|
56
|
-
|
|
57
|
-
|
|
27
|
+
Legion/RescueLogging/NoCapture:
|
|
28
|
+
Enabled: false
|
|
58
29
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- 'lib/legion/data/connection.rb'
|
|
30
|
+
Legion/Framework/EagerSequelModel:
|
|
31
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.6.16] - 2026-03-30
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Migration 019: widen `record_hash` column to size 255 via `set_column_type` (column added in migration 017)
|
|
9
|
+
- Migration 019: rename `prev_hash` to `previous_hash` via `rename_column` instead of adding a duplicate column
|
|
10
|
+
- Migration 019: decouple index creation from column existence checks so indexes are always guarded by their own `idxs.key?` check
|
|
11
|
+
- Migration 019: `down` no longer drops `record_hash` (owned by migration 017, not 019)
|
|
12
|
+
- Migration 019: replace `db.indexes` with bare `indexes()` — inside a `Sequel.migration` block `self` is the DB object, so `db` is undefined
|
|
13
|
+
- Updated to rubocop-legion (`inherit_gem: config/core.yml`) for shared LegionIO cop configuration
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Migration 019 spec: 8 examples covering column presence, defaults, indexes, idempotency, and rollback
|
|
17
|
+
|
|
5
18
|
## [1.6.15] - 2026-03-29
|
|
6
19
|
|
|
7
20
|
### Added
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,7 @@ module Legion
|
|
|
5
5
|
module Extract
|
|
6
6
|
module Handlers
|
|
7
7
|
class Base
|
|
8
|
-
@registry = {}
|
|
8
|
+
@registry = {}.freeze
|
|
9
9
|
|
|
10
10
|
class << self
|
|
11
11
|
attr_reader :registry
|
|
@@ -22,7 +22,7 @@ module Legion
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def register(handler_class)
|
|
25
|
-
@registry
|
|
25
|
+
@registry = @registry.merge(handler_class.type => handler_class).freeze
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def for_type(type)
|
|
@@ -16,11 +16,11 @@ module Legion
|
|
|
16
16
|
workbook = ::RubyXL::Parser.parse(source)
|
|
17
17
|
sheets = []
|
|
18
18
|
workbook.worksheets.each do |sheet|
|
|
19
|
-
rows = sheet.each.
|
|
19
|
+
rows = sheet.each.filter_map do |row|
|
|
20
20
|
next unless row
|
|
21
21
|
|
|
22
22
|
row.cells.map { |c| c&.value.to_s }.join(', ')
|
|
23
|
-
end
|
|
23
|
+
end
|
|
24
24
|
sheets << "Sheet: #{sheet.sheet_name}\n#{rows.join("\n")}" unless rows.empty?
|
|
25
25
|
end
|
|
26
26
|
text = sheets.join("\n\n")
|
data/lib/legion/data/extract.rb
CHANGED
|
@@ -4,15 +4,32 @@ Sequel.migration do
|
|
|
4
4
|
up do
|
|
5
5
|
return unless table_exists?(:audit_log)
|
|
6
6
|
|
|
7
|
-
cols
|
|
7
|
+
cols = schema(:audit_log).map(&:first)
|
|
8
|
+
idxs = indexes(:audit_log)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
add_index :retention_tier, if_not_exists: true
|
|
10
|
+
# record_hash exists from migration 017 at size 64; widen to 255 if needed.
|
|
11
|
+
if cols.include?(:record_hash)
|
|
12
|
+
set_column_type :audit_log, :record_hash, String, size: 255
|
|
13
|
+
else
|
|
14
|
+
alter_table(:audit_log) { add_column :record_hash, String, size: 255 }
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
add_index :audit_log, :record_hash unless idxs.key?(:audit_log_record_hash_index)
|
|
18
|
+
|
|
19
|
+
# Rename prev_hash (introduced in migration 017) to previous_hash for clarity,
|
|
20
|
+
# then widen it to 255 to match record_hash.
|
|
21
|
+
if cols.include?(:prev_hash) && !cols.include?(:previous_hash)
|
|
22
|
+
rename_column :audit_log, :prev_hash, :previous_hash
|
|
23
|
+
set_column_type :audit_log, :previous_hash, String, size: 255
|
|
24
|
+
elsif !cols.include?(:previous_hash)
|
|
25
|
+
alter_table(:audit_log) { add_column :previous_hash, String, size: 255 }
|
|
26
|
+
elsif cols.include?(:previous_hash)
|
|
27
|
+
set_column_type :audit_log, :previous_hash, String, size: 255
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
alter_table(:audit_log) { add_column :retention_tier, String, size: 10, default: 'hot' } unless cols.include?(:retention_tier)
|
|
31
|
+
|
|
32
|
+
add_index :audit_log, :retention_tier unless idxs.key?(:audit_log_retention_tier_index)
|
|
16
33
|
end
|
|
17
34
|
|
|
18
35
|
down do
|
|
@@ -20,10 +37,22 @@ Sequel.migration do
|
|
|
20
37
|
|
|
21
38
|
cols = schema(:audit_log).map(&:first)
|
|
22
39
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
drop_index :audit_log, :record_hash, if_exists: true
|
|
41
|
+
|
|
42
|
+
# Restore record_hash to its original size (64 from migration 017).
|
|
43
|
+
set_column_type :audit_log, :record_hash, String, size: 64 if cols.include?(:record_hash)
|
|
44
|
+
|
|
45
|
+
# Rename previous_hash back to prev_hash (reverse of the up rename) and restore size to 64.
|
|
46
|
+
if cols.include?(:previous_hash) && !cols.include?(:prev_hash)
|
|
47
|
+
rename_column :audit_log, :previous_hash, :prev_hash
|
|
48
|
+
set_column_type :audit_log, :prev_hash, String, size: 64
|
|
49
|
+
elsif cols.include?(:previous_hash)
|
|
50
|
+
alter_table(:audit_log) { drop_column :previous_hash }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
if cols.include?(:retention_tier)
|
|
54
|
+
drop_index :audit_log, :retention_tier, if_exists: true
|
|
55
|
+
alter_table(:audit_log) { drop_column :retention_tier }
|
|
27
56
|
end
|
|
28
57
|
end
|
|
29
58
|
end
|
data/lib/legion/data/settings.rb
CHANGED
|
@@ -128,7 +128,7 @@ module Legion
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
begin
|
|
131
|
-
Legion::Settings.merge_settings('data', Legion::Data::Settings.default) if Legion.const_defined?('Settings')
|
|
131
|
+
Legion::Settings.merge_settings('data', Legion::Data::Settings.default) if Legion.const_defined?('Settings', false)
|
|
132
132
|
rescue StandardError => e
|
|
133
133
|
Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal)
|
|
134
134
|
end
|
data/lib/legion/data/version.rb
CHANGED