lexicon-common 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,47 +5,132 @@
5
5
  "description": "",
6
6
  "type": "object",
7
7
  "properties": {
8
+ "schema_version": {
9
+ "$ref": "#/definitions/schema_versions"
10
+ },
8
11
  "version": {
12
+ "$ref": "#/definitions/semver"
13
+ }
14
+ },
15
+ "oneOf": [
16
+ {
17
+ "properties": {
18
+ "schema_version": {
19
+ "type": "integer",
20
+ "const": 1
21
+ },
22
+ "content": {
23
+ "$ref": "#/definitions/content/1"
24
+ }
25
+ }
26
+ },
27
+ {
28
+ "properties": {
29
+ "schema_version": {
30
+ "type": "integer",
31
+ "const": 2
32
+ },
33
+ "content": {
34
+ "$ref": "#/definitions/content/2"
35
+ }
36
+ }
37
+ }
38
+ ],
39
+ "required": [
40
+ "version",
41
+ "content"
42
+ ],
43
+ "definitions": {
44
+ "schema_versions": {
45
+ "type": "integer",
46
+ "default": 2,
47
+ "enum": [
48
+ 2
49
+ ]
50
+ },
51
+ "semver": {
9
52
  "description": "The version of the packaged version",
10
53
  "type": "string",
11
54
  "$comment": "Regex is from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string",
12
55
  "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
13
56
  },
14
57
  "content": {
15
- "type": "object",
16
- "patternProperties": {
17
- "^[a-z][a-z_]*$": {
18
- "type": "object",
19
- "properties": {
20
- "name": {
21
- "type": "string"
22
- },
23
- "structure": {
24
- "type": "string"
25
- },
26
- "data": {
27
- "type": "string"
58
+ "1": {
59
+ "type": "object",
60
+ "patternProperties": {
61
+ "^[a-z][a-z_]*$": {
62
+ "type": "object",
63
+ "properties": {
64
+ "name": {
65
+ "type": "string"
66
+ },
67
+ "structure": {
68
+ "type": "string"
69
+ },
70
+ "data": {
71
+ "type": "string"
72
+ },
73
+ "tables": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "string"
77
+ },
78
+ "additionalItems": false
79
+ }
28
80
  },
29
- "tables": {
30
- "type": "array",
31
- "items": {
81
+ "required": [
82
+ "name",
83
+ "structure",
84
+ "tables"
85
+ ]
86
+ }
87
+ },
88
+ "additionalProperties": false
89
+ },
90
+ "2": {
91
+ "type": "object",
92
+ "patternProperties": {
93
+ "^[a-z][a-z_]*$": {
94
+ "type": "object",
95
+ "properties": {
96
+ "name": {
97
+ "type": "string"
98
+ },
99
+ "structure": {
32
100
  "type": "string"
33
101
  },
34
- "additionalItems": false
35
- }
36
- },
37
- "required": [
38
- "name",
39
- "structure",
40
- "tables"
41
- ]
102
+ "tables": {
103
+ "type": "object",
104
+ "patternProperties": {
105
+ "^([a-z]+)(_[a-z]+)*$": {
106
+ "type": "array",
107
+ "items": {
108
+ "type": "string"
109
+ },
110
+ "additionalItems": false
111
+ }
112
+ },
113
+ "additionalProperties": false
114
+ }
115
+ },
116
+ "required": [
117
+ "name",
118
+ "structure",
119
+ "tables"
120
+ ]
121
+ }
122
+ },
123
+ "additionalProperties": false
124
+ }
125
+ },
126
+ "versions": {
127
+ "default": {
128
+ "properties": {
129
+ "content": {
130
+ "$ref": "#/definitions/content/1"
131
+ }
42
132
  }
43
- },
44
- "additionalProperties": false
133
+ }
45
134
  }
46
- },
47
- "required": [
48
- "version",
49
- "content"
50
- ]
135
+ }
51
136
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lexicon-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ekylibre developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: corindon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: json_schemer
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +178,7 @@ dependencies:
150
178
  - - '='
151
179
  - !ruby/object:Gem::Version
152
180
  version: 1.11.0
153
- description:
181
+ description:
154
182
  email:
155
183
  - dev@ekylibre.com
156
184
  executables: []
@@ -165,14 +193,22 @@ files:
165
193
  - lib/lexicon/common/mixin/container_aware.rb
166
194
  - lib/lexicon/common/mixin/finalizable.rb
167
195
  - lib/lexicon/common/mixin/logger_aware.rb
196
+ - lib/lexicon/common/mixin/nameable.rb
168
197
  - lib/lexicon/common/mixin/schema_namer.rb
169
198
  - lib/lexicon/common/package/directory_package_loader.rb
170
199
  - lib/lexicon/common/package/package.rb
171
- - lib/lexicon/common/package/package_builder.rb
200
+ - lib/lexicon/common/package/package_file.rb
172
201
  - lib/lexicon/common/package/package_integrity_validator.rb
173
- - lib/lexicon/common/package/source_file_set.rb
202
+ - lib/lexicon/common/package/v1/package.rb
203
+ - lib/lexicon/common/package/v1/package_builder.rb
204
+ - lib/lexicon/common/package/v1/source_file_set.rb
205
+ - lib/lexicon/common/package/v2/package.rb
206
+ - lib/lexicon/common/package/v2/package_builder.rb
207
+ - lib/lexicon/common/package/v2/source_file_set.rb
174
208
  - lib/lexicon/common/production/datasource_loader.rb
175
209
  - lib/lexicon/common/production/file_loader.rb
210
+ - lib/lexicon/common/production/table_locker.rb
211
+ - lib/lexicon/common/psql.rb
176
212
  - lib/lexicon/common/remote/package_downloader.rb
177
213
  - lib/lexicon/common/remote/package_uploader.rb
178
214
  - lib/lexicon/common/remote/remote_base.rb
@@ -185,7 +221,7 @@ homepage: https://www.ekylibre.com
185
221
  licenses:
186
222
  - AGPL-3.0-only
187
223
  metadata: {}
188
- post_install_message:
224
+ post_install_message:
189
225
  rdoc_options: []
190
226
  require_paths:
191
227
  - lib
@@ -200,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
236
  - !ruby/object:Gem::Version
201
237
  version: '0'
202
238
  requirements: []
203
- rubygems_version: 3.0.3
204
- signing_key:
239
+ rubygems_version: 3.4.7
240
+ signing_key:
205
241
  specification_version: 4
206
242
  summary: Common classes and services for Ekylibre's Lexicon
207
243
  test_files: []
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lexicon
4
- module Common
5
- module Package
6
- class PackageBuilder < Package
7
- def initialize(version:, dir:)
8
- super(
9
- file_sets: [],
10
- version: version,
11
- dir: dir,
12
- checksum_file: dir.join(CHECKSUM_FILE_NAME),
13
- spec_file: dir.join(SPEC_FILE_NAME)
14
- )
15
-
16
- FileUtils.mkdir_p(data_dir)
17
- end
18
-
19
- # @param [String] id
20
- # @param [String] name
21
- # @param [Pathname] structure
22
- # Takes ownership of the file (moves it to the correct folder)
23
- # @param [Array<String>] tables
24
- # @param [Pathname] data
25
- # Takes ownership of the file (moves it to the correct folder)
26
- # @param [String] data_ext
27
- def add_file_set(id, name:, structure:, tables:, data: nil, data_ext: '.sql')
28
- # @type [Pathname] structure_file_path
29
- structure_file_path = data_dir.join(structure_file_name(id))
30
- FileUtils.mv(structure.to_s, structure_file_path.to_s)
31
-
32
- # @type [Pathname] data_file_path
33
- data_name = if data.nil?
34
- nil
35
- else
36
- dname = data_file_name(id, data_ext)
37
- path = data_dir.join(dname)
38
- FileUtils.mv(data, path)
39
-
40
- dname
41
- end
42
-
43
- file_sets << SourceFileSet.new(
44
- id: id,
45
- name: name,
46
- structure: structure_file_name(id),
47
- data: data.nil? ? nil : data_name,
48
- tables: tables
49
- )
50
- end
51
-
52
- def as_package
53
- Package.new(version: version, dir: dir, file_sets: file_sets, checksum_file: checksum_file, spec_file: spec_file)
54
- end
55
-
56
- private
57
-
58
- def data_file_name(id, ext)
59
- "#{id}#{ext}"
60
- end
61
-
62
- def structure_file_name(id)
63
- "#{id}__structure.sql"
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lexicon
4
- module Common
5
- module Package
6
- class SourceFileSet
7
- attr_reader :id, :name, :structure_path, :data_path, :tables
8
-
9
- # @param [String] id
10
- # @param [String] name
11
- # @param [String] structure
12
- # @param [String] data
13
- # @param [Array<String>] tables
14
- def initialize(id:, name:, structure:, data:, tables:)
15
- @id = id
16
- @name = name
17
- @structure_path = structure
18
- @data_path = data
19
- @tables = tables
20
- end
21
- end
22
- end
23
- end
24
- end