duck_duck_duck 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/duck_duck_duck.rb +23 -2
- data/specs/duck_duck_duck.rb +27 -1
- data/specs/lib/models/0030_model/migrates/0010-table.sql +5 -4
- data/specs/lib/models/0030_model/migrates/0020-insert_1.sql +5 -4
- data/specs/lib/models/0030_model/migrates/0030-insert_2.sql +11 -3
- metadata +3 -5
- data/specs/lib/user/migrates/001-user.js +0 -3
- data/specs/lib/user/migrates/002-two.js +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 408c8ff124e2c853f32fc6f5d3620d12107805e6
|
4
|
+
data.tar.gz: c6c87955b7ac26a994ecbf8d95638b7562ced0a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a70919b41eba20e83627c848a45f01f5d242247cbf3a0defaca1202227d72ffe7b3e8760c6a7eb3599d81c7824b17b851b7c121a9288f2a9c22e58f11c771c
|
7
|
+
data.tar.gz: c5b85fa17c3464c3eda293090429cffc75b1b9c4e6f98b372f5030e7b3f0a21c1ba1bec9a8c131f522d88f0a54a85f2fcced11553c09c971b5f54b8abcf6eeb6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.0
|
data/lib/duck_duck_duck.rb
CHANGED
@@ -25,6 +25,27 @@ class Duck_Duck_Duck
|
|
25
25
|
EOF
|
26
26
|
end
|
27
27
|
|
28
|
+
def read_file f
|
29
|
+
raw = File.read(f).split(/\s*--\s+(UP|DOWN)\s*/).
|
30
|
+
inject([:UP, { :UP => [], :DOWN => [] }]) do |memo, val|
|
31
|
+
dir = memo.first
|
32
|
+
meta = memo.last
|
33
|
+
|
34
|
+
case val
|
35
|
+
when 'UP', :UP, :DOWN, 'DOWN'
|
36
|
+
dir = val.to_sym
|
37
|
+
when ''
|
38
|
+
# do nothing
|
39
|
+
else
|
40
|
+
meta[dir] << val
|
41
|
+
end
|
42
|
+
|
43
|
+
[dir, meta]
|
44
|
+
end
|
45
|
+
meta = raw.last
|
46
|
+
{:UP=>meta[:UP].join("\n"), :DOWN=>meta[:DOWN].join("\n")}
|
47
|
+
end
|
48
|
+
|
28
49
|
%w{reset up down}.each { |meth|
|
29
50
|
eval <<-EOF, nil, __FILE__, __LINE__ + 1
|
30
51
|
def #{meth} name = nil
|
@@ -77,7 +98,7 @@ class Duck_Duck_Duck
|
|
77
98
|
files = @files.sort.map { |f|
|
78
99
|
ver = file_to_ver(f)
|
79
100
|
if ver > rec[:version]
|
80
|
-
[ ver,
|
101
|
+
[ ver, Duck_Duck_Duck.read_file(f)[:UP] ]
|
81
102
|
end
|
82
103
|
}.compact
|
83
104
|
|
@@ -116,7 +137,7 @@ class Duck_Duck_Duck
|
|
116
137
|
files = @files.sort.reverse.map { |f|
|
117
138
|
ver = file_to_ver(f)
|
118
139
|
next unless ver <= rec[:version]
|
119
|
-
[ ver,
|
140
|
+
[ ver, Duck_Duck_Duck.read_file(f)[:DOWN] ]
|
120
141
|
}.compact
|
121
142
|
|
122
143
|
if files.empty?
|
data/specs/duck_duck_duck.rb
CHANGED
@@ -3,7 +3,7 @@ require 'sequel'
|
|
3
3
|
require 'Exit_0'
|
4
4
|
|
5
5
|
schema = ENV['SCHEMA_TABLE'] = '_test_schema'
|
6
|
-
DB
|
6
|
+
DB = Sequel.connect ENV['DATABASE_URL']
|
7
7
|
MODELS = Dir.glob('*/migrates').map { |dir| File.basename File.dirname(dir) }
|
8
8
|
|
9
9
|
# === Reset tables ===========================================================
|
@@ -45,6 +45,17 @@ describe :initialize do
|
|
45
45
|
|
46
46
|
end # === describe :initialize
|
47
47
|
|
48
|
+
describe "read_file" do
|
49
|
+
|
50
|
+
it "returns: {:UP=>STRING, :DOWN=>STRING}" do
|
51
|
+
file = "/tmp/ddd_up_down.sql"
|
52
|
+
File.write(file, ["-- DOWN", "2", "-- UP", "1", "-- DOWN", "2", "-- UP", "1"].join("\n"))
|
53
|
+
Duck_Duck_Duck.read_file(file).
|
54
|
+
should == {:UP=>"1\n1", :DOWN=>"2\n2"}
|
55
|
+
end # === it
|
56
|
+
|
57
|
+
end # === describe "read_file"
|
58
|
+
|
48
59
|
describe "create" do
|
49
60
|
|
50
61
|
before {
|
@@ -125,5 +136,20 @@ describe 'down model' do
|
|
125
136
|
|
126
137
|
end # === describe down model
|
127
138
|
|
139
|
+
describe '-- UP/-- DOWN model' do
|
140
|
+
|
141
|
+
before { reset }
|
142
|
+
|
143
|
+
it "runs UPs in proper order" do
|
144
|
+
Exit_0("duck_duck_duck up 0030_model")
|
145
|
+
get(%^SELECT title FROM "0030_model"^).
|
146
|
+
should == [
|
147
|
+
{:title=>"record 1-1: 0030_model"},
|
148
|
+
{:title=>"record 2-1: 0030_model"},
|
149
|
+
{:title=>"record 2-2: 0030_model"},
|
150
|
+
]
|
151
|
+
end # === it
|
152
|
+
|
153
|
+
end # === describe '-- UP/-- DOWN model'
|
128
154
|
|
129
155
|
|
@@ -1,13 +1,14 @@
|
|
1
|
+
-- DOWN
|
2
|
+
|
3
|
+
INSERT INTO "0030_model" (title)
|
4
|
+
VALUES ('DROP 0030_model');
|
1
5
|
|
6
|
+
-- UP
|
2
7
|
CREATE TABLE "0030_model" (
|
3
8
|
id serial NOT NULL PRIMARY KEY,
|
4
9
|
title varchar(100)
|
5
10
|
);
|
6
11
|
|
7
12
|
|
8
|
-
-- DOWN
|
9
|
-
|
10
|
-
INSERT INTO "0030_model" (title)
|
11
|
-
VALUES ('DROP 0030_model');
|
12
13
|
|
13
14
|
|
@@ -1,11 +1,12 @@
|
|
1
|
+
-- DOWN
|
1
2
|
|
2
3
|
INSERT INTO "0030_model" (title)
|
3
|
-
VALUES ('record 1: 0030_model');
|
4
|
-
|
4
|
+
VALUES ('DROP record 1: 0030_model');
|
5
5
|
|
6
|
-
-- DOWN
|
7
6
|
|
7
|
+
-- UP
|
8
8
|
INSERT INTO "0030_model" (title)
|
9
|
-
VALUES ('
|
9
|
+
VALUES ('record 1-1: 0030_model');
|
10
|
+
|
10
11
|
|
11
12
|
|
@@ -1,11 +1,19 @@
|
|
1
|
-
|
1
|
+
-- DOWN
|
2
2
|
INSERT INTO "0030_model" (title)
|
3
|
-
VALUES ('record 1: 0030_model');
|
3
|
+
VALUES ('DROP record 2-1: 0030_model');
|
4
4
|
|
5
|
+
-- UP
|
6
|
+
INSERT INTO "0030_model" (title)
|
7
|
+
VALUES ('record 2-1: 0030_model');
|
5
8
|
|
6
9
|
-- DOWN
|
10
|
+
INSERT INTO "0030_model" (title)
|
11
|
+
VALUES ('DROP record 2-1: 0030_model');
|
7
12
|
|
13
|
+
-- UP
|
8
14
|
INSERT INTO "0030_model" (title)
|
9
|
-
VALUES ('
|
15
|
+
VALUES ('record 2-2: 0030_model');
|
16
|
+
|
17
|
+
|
10
18
|
|
11
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_duck_duck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- da99
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -145,8 +145,6 @@ files:
|
|
145
145
|
- specs/lib/models/0030_model/migrates/0010-table.sql
|
146
146
|
- specs/lib/models/0030_model/migrates/0020-insert_1.sql
|
147
147
|
- specs/lib/models/0030_model/migrates/0030-insert_2.sql
|
148
|
-
- specs/lib/user/migrates/001-user.js
|
149
|
-
- specs/lib/user/migrates/002-two.js
|
150
148
|
homepage: https://github.com/da99/duck_duck_duck
|
151
149
|
licenses:
|
152
150
|
- MIT
|
@@ -167,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
165
|
version: '0'
|
168
166
|
requirements: []
|
169
167
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.4.
|
168
|
+
rubygems_version: 2.4.8
|
171
169
|
signing_key:
|
172
170
|
specification_version: 4
|
173
171
|
summary: Migrations for apps composed of mini-apps.
|