pgtk 0.9.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rultor.yml +2 -2
- data/README.md +9 -4
- data/lib/pgtk/liquibase_task.rb +21 -11
- data/lib/pgtk/version.rb +1 -1
- data/test/test_liquibase_task.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b201e77d472e16891cd9b86c0c403431319b14f651be6f4f8891f1d4373b346
|
4
|
+
data.tar.gz: 764f9a225a0025b0c88457bb1875e1b11c8c972a487482547427dbee0af02748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e7225c5e2fb009a170df8bf047323e023751ec185c62aaa21479620020e1939f834b9358f417950aaf9bcc04469cdefd8c0e716401f66eaebf4fc56ae969b6
|
7
|
+
data.tar.gz: 20d725cf5522d2342b4ea894c4eb6b4177baa5906687a89e5d9b0ee827100bbd8594f6e9c2f996f0632717ccb6e4bccb370b861ab32d38b429791ebd2587b4fa
|
data/.rubocop.yml
CHANGED
data/.rultor.yml
CHANGED
@@ -3,10 +3,10 @@ docker:
|
|
3
3
|
assets:
|
4
4
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
5
5
|
install: |
|
6
|
-
sudo chown -R "$(whoami)" /usr/local/rvm
|
7
6
|
pdd -f /dev/null
|
8
|
-
bundle install --no-color
|
7
|
+
bundle install --no-color
|
9
8
|
release:
|
9
|
+
pre: false
|
10
10
|
script: |-
|
11
11
|
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
12
12
|
bundle exec rake
|
data/README.md
CHANGED
@@ -50,13 +50,16 @@ Pgtk::PgsqlTask.new :pgsql do |t|
|
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
53
|
-
And this too:
|
53
|
+
And this too ([org.postgresql:postgresql](https://mvnrepository.com/artifact/org.postgresql/postgresql) and [org.liquibase:liquibase-maven-plugin](https://mvnrepository.com/artifact/org.liquibase/liquibase-maven-plugin) are used inside):
|
54
54
|
|
55
55
|
```ruby
|
56
56
|
require 'pgtk/liquibase_task'
|
57
57
|
Pgtk::LiquibaseTask.new liquibase: :pgsql do |t|
|
58
58
|
t.master = 'liquibase/master.xml' # Master XML file path
|
59
59
|
t.yaml = ['target/pgsql-config.yml', 'config.yml'] # YAML files with connection details
|
60
|
+
t.quiet = false # TRUE by default
|
61
|
+
t.postgresql_version = '42.7.0' # overwriting default version
|
62
|
+
t.liquibase_version = '3.2.2' # overwriting default version
|
60
63
|
end
|
61
64
|
```
|
62
65
|
|
@@ -129,10 +132,12 @@ end
|
|
129
132
|
|
130
133
|
Should work.
|
131
134
|
|
132
|
-
Well, it works in
|
135
|
+
Well, it works in
|
136
|
+
[netbout.com](https://github.com/yegor256/netbout),
|
137
|
+
[wts.zold.io](https://github.com/zold-io/wts.zold.io),
|
133
138
|
[mailanes.com](https://github.com/yegor256/mailanes), and
|
134
|
-
[0rsk.com](https://github.com/yegor256/0rsk).
|
135
|
-
open source, you can see how they use `pgtk`.
|
139
|
+
[0rsk.com](https://github.com/yegor256/0rsk).
|
140
|
+
They are all open source, you can see how they use `pgtk`.
|
136
141
|
|
137
142
|
## How to contribute
|
138
143
|
|
data/lib/pgtk/liquibase_task.rb
CHANGED
@@ -54,17 +54,25 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
|
|
54
54
|
def run
|
55
55
|
raise "Option 'master' is mandatory" unless @master
|
56
56
|
raise "Option 'yaml' is mandatory" unless @yaml
|
57
|
-
yml =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
yml = @yaml
|
58
|
+
unless yml.is_a?(Hash)
|
59
|
+
yml = YAML.load_file(
|
60
|
+
if @yaml.is_a?(Array)
|
61
|
+
@yaml.drop_while { |f| !File.exist?(f) }.first
|
62
|
+
else
|
63
|
+
@yaml
|
64
|
+
end
|
65
|
+
)
|
66
|
+
end
|
67
|
+
raise "YAML configuration is missing the 'pgsql' section" unless yml['pgsql']
|
67
68
|
@master = File.expand_path(@master)
|
69
|
+
unless File.exist?(@master)
|
70
|
+
raise "Liquibase master is absent at '#{@master}'. \
|
71
|
+
More about this file you can find in Liquibase documentation: \
|
72
|
+
https://docs.liquibase.com/concepts/changelogs/xml-format.html"
|
73
|
+
end
|
74
|
+
pom = File.expand_path(File.join(__dir__, '../../resources/pom.xml'))
|
75
|
+
old = @liquibase_version.match?(/^[1-3]\..+$/)
|
68
76
|
Dir.chdir(File.dirname(@master)) do
|
69
77
|
system(
|
70
78
|
[
|
@@ -80,7 +88,9 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
|
|
80
88
|
'--define',
|
81
89
|
"postgresql.version=#{@postgresql_version}",
|
82
90
|
'--define',
|
83
|
-
"liquibase.
|
91
|
+
"liquibase.searchPath=#{File.dirname(@master)}",
|
92
|
+
'--define',
|
93
|
+
"liquibase.changeLogFile=#{old ? @master : File.basename(@master)}",
|
84
94
|
'--define',
|
85
95
|
"liquibase.url=#{Shellwords.escape(yml['pgsql']['url'])}",
|
86
96
|
'--define',
|
data/lib/pgtk/version.rb
CHANGED
data/test/test_liquibase_task.rb
CHANGED
@@ -53,4 +53,36 @@ class TestLiquibaseTask < Minitest::Test
|
|
53
53
|
Rake::Task['liquibase2'].invoke
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
def test_latest_version
|
58
|
+
Dir.mktmpdir 'test' do |dir|
|
59
|
+
Pgtk::PgsqlTask.new(:pgsql) do |t|
|
60
|
+
t.dir = File.join(dir, 'pgsql')
|
61
|
+
t.user = 'xxx'
|
62
|
+
t.password = 'xxx'
|
63
|
+
t.dbname = 'xxx'
|
64
|
+
t.yaml = File.join(dir, 'xxx.yml')
|
65
|
+
t.quiet = true
|
66
|
+
end
|
67
|
+
Rake::Task['pgsql'].invoke
|
68
|
+
Pgtk::LiquibaseTask.new(:liquibase) do |t|
|
69
|
+
t.master = File.join(__dir__, '../test-resources/master.xml')
|
70
|
+
t.yaml = File.join(dir, 'xxx.yml')
|
71
|
+
t.postgresql_version = '42.7.1'
|
72
|
+
t.liquibase_version = '4.25.1'
|
73
|
+
end
|
74
|
+
Rake::Task['liquibase'].invoke
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_with_invalid_master_file
|
79
|
+
Pgtk::LiquibaseTask.new(:lb) do |t|
|
80
|
+
t.master = 'the-file-doesnt-exist.xml'
|
81
|
+
t.yaml = { 'pgsql' => {} }
|
82
|
+
end
|
83
|
+
ex = assert_raises do
|
84
|
+
Rake::Task['lb'].invoke
|
85
|
+
end
|
86
|
+
assert(ex.message.include?('the-file-doesnt-exist.xml'))
|
87
|
+
end
|
56
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|