lexicon-common 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lexicon-common.gemspec +2 -0
- data/lib/lexicon-common.rb +3 -0
- data/lib/lexicon/common.rb +1 -0
- data/lib/lexicon/common/mixin/logger_aware.rb +2 -2
- data/lib/lexicon/common/mixin/nameable.rb +16 -0
- data/lib/lexicon/common/package/directory_package_loader.rb +56 -12
- data/lib/lexicon/common/package/package.rb +11 -43
- data/lib/lexicon/common/package/package_file.rb +50 -0
- data/lib/lexicon/common/package/v1/package.rb +83 -0
- data/lib/lexicon/common/package/v1/package_builder.rb +70 -0
- data/lib/lexicon/common/package/v1/source_file_set.rb +28 -0
- data/lib/lexicon/common/package/v2/package.rb +56 -0
- data/lib/lexicon/common/package/v2/package_builder.rb +72 -0
- data/lib/lexicon/common/package/v2/source_file_set.rb +26 -0
- data/lib/lexicon/common/production/datasource_loader.rb +119 -60
- data/lib/lexicon/common/production/table_locker.rb +58 -0
- data/lib/lexicon/common/psql.rb +47 -0
- data/lib/lexicon/common/remote/package_downloader.rb +61 -43
- data/lib/lexicon/common/remote/package_uploader.rb +37 -28
- data/lib/lexicon/common/remote/s3_client.rb +6 -0
- data/lib/lexicon/common/schema/validator_factory.rb +1 -1
- data/lib/lexicon/common/shell_executor.rb +0 -3
- data/lib/lexicon/common/version.rb +1 -1
- data/resources/lexicon.schema.json +116 -31
- metadata +39 -3
- data/lib/lexicon/common/package/package_builder.rb +0 -68
- data/lib/lexicon/common/package/source_file_set.rb +0 -24
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexicon-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ekylibre developers
|
@@ -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
|
@@ -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/
|
200
|
+
- lib/lexicon/common/package/package_file.rb
|
172
201
|
- lib/lexicon/common/package/package_integrity_validator.rb
|
173
|
-
- lib/lexicon/common/package/
|
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
|
@@ -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
|