fancybox2 0.0.9 → 0.0.10
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/lib/fancybox2/migrations/runner.rb +27 -8
- data/lib/fancybox2/version.rb +1 -1
- 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: 3656436f12dfd2d4129e12b7db0ffd45a116698030802589a729ee82bc829948
|
4
|
+
data.tar.gz: 75f33ab435919e63a9696ef84a731084060bf3cc654a0a80d427b6c96c38f89a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdbd2c3d7e2e69882a53d830c49bf7ee8341c5091bbd43ed55fda77776da36326c16c0c5093a5ed62ef8632357fa0c14e8cc951846352ca9f001fec72b88bad8
|
7
|
+
data.tar.gz: 01716640347e04c37b72cdf7fc9b8055c2685beb59381f7869f6b08fc86614eb8a747dfd1611e37e1aa6f6f61424f22da5e1d1363a63d255671d73860132078e
|
@@ -15,6 +15,22 @@ module Fancybox2
|
|
15
15
|
|
16
16
|
version.to_i
|
17
17
|
end
|
18
|
+
|
19
|
+
def auto(migrations_folder, last_migrated_file_path: nil, logger: nil)
|
20
|
+
# Try to read file content, rescue with nil
|
21
|
+
content = File.read(last_migrated_file_path) rescue nil
|
22
|
+
# Extract last run migration version
|
23
|
+
last_run_migration_version = content.to_i
|
24
|
+
|
25
|
+
runner = new(migrations_folder, logger: logger)
|
26
|
+
last_migrated = runner.run last_migrated: last_run_migration_version
|
27
|
+
# Update migration status file
|
28
|
+
if last_migrated
|
29
|
+
f = File.open last_migrated_file_path, 'w'
|
30
|
+
f.write last_migrated.version
|
31
|
+
f.close
|
32
|
+
end
|
33
|
+
end
|
18
34
|
end
|
19
35
|
|
20
36
|
attr_reader :files_path, :current_version, :migrations, :logger
|
@@ -37,12 +53,16 @@ module Fancybox2
|
|
37
53
|
from = self.class.extract_and_validate_version_from(from || last_migrated || 0)
|
38
54
|
# This works independently from the direction if migrations' folder contains only migrations of last installed version
|
39
55
|
to = self.class.extract_and_validate_version_from (to || @migrations.last.version)
|
40
|
-
puts "from: #{from}, to: #{to}, last_migrated: #{last_migrated}"
|
41
56
|
# Select migrations to run
|
42
57
|
to_run, direction = migrations_to_run from, to
|
43
|
-
# If last_migrated has been
|
44
|
-
if last_migrated &&
|
45
|
-
to_run.
|
58
|
+
# If last_migrated param has been provided, remove some migration from the list depending on direction
|
59
|
+
if last_migrated && to_run.any?
|
60
|
+
if direction == :up && last_migrated == to_run.first.version
|
61
|
+
to_run.shift
|
62
|
+
elsif direction == :down
|
63
|
+
# We surely have at least 2 migrations in the array, otherwise the direction would've been :up
|
64
|
+
to_run.pop
|
65
|
+
end
|
46
66
|
end
|
47
67
|
to_run.each do |migration|
|
48
68
|
logger.info "Running migration #{migration.name}"
|
@@ -68,9 +88,6 @@ module Fancybox2
|
|
68
88
|
selected = []
|
69
89
|
direction = from <= to ? :up : :down
|
70
90
|
@migrations.each do |m|
|
71
|
-
puts m.version
|
72
|
-
# Edge case, no migrations to run
|
73
|
-
break if from == to
|
74
91
|
# downgrading - Break if we already arrived to "from" migration (e.g from=4, to=2 => 1, >2<, 3, *4*, 5)
|
75
92
|
break if (from > to) && (m.version > from)
|
76
93
|
# upgrading - Break if we already arrived to "to" migration (e.g from=2, to=4 => 1, *2*, 3, >4<, 5)
|
@@ -78,7 +95,9 @@ module Fancybox2
|
|
78
95
|
# downgrading - Skip until we arrive to "to" migration (e.g from=4, to=2 => 1, >2<, 3, *4*, 5)
|
79
96
|
next if (from > to) && (m.version < to)
|
80
97
|
# upgrading - Skip until we arrive to "from" migration (e.g from=2, to=4 => 1, *2*, 3, >4<, 5)
|
81
|
-
next if (from
|
98
|
+
next if (from <= to) && (m.version < from)
|
99
|
+
# Break if we're already out of range
|
100
|
+
break if (m.version > from && m.version > to)
|
82
101
|
|
83
102
|
if m.version <= from
|
84
103
|
selected.prepend m
|
data/lib/fancybox2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancybox2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Verlato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|