schema_plus_views 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/schema_plus/views/middleware.rb +4 -1
- data/lib/schema_plus/views/version.rb +1 -1
- data/spec/dumper_spec.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fc4b60cc9309357c2da20cbc1f47c1f70a84b7b
|
4
|
+
data.tar.gz: 373a4c477a67f60bf0eabe36c0091dcdb395123d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc62d9dcaf074c67a6c8541a1e148b9a0c1ae52ef364521f53ece17c872ebb65d5cc6ea8e4a3035ba7d9018d0854e0ba1f1c71924e4c3059f18d56f06244d746
|
7
|
+
data.tar.gz: ae3921d2c5749cbdc8d298729b9973cc3dd4fcebcebd15e03fb54e7c8b2d1fffeb4fa40957ec57415ce15c06bad0ac7dd20983e588a9d77a064fd8acb78a3eec
|
data/README.md
CHANGED
@@ -109,6 +109,7 @@ This returns just the body of the definition, i.e. the part after the `CREATE VI
|
|
109
109
|
|
110
110
|
## History
|
111
111
|
|
112
|
+
* 0.2.2 - Prettier dumps: use heredoc for definition string
|
112
113
|
* 0.2.1 - Fix db:rollback
|
113
114
|
* 0.2.0 - Added :allow_replace option (thanks to [@hcarver](https://github.com/hcarver))
|
114
115
|
* 0.1.0 - Initial release, extracted from schema_plus 1.x
|
@@ -18,7 +18,10 @@ module SchemaPlus::Views
|
|
18
18
|
# quacks like a SchemaMonkey Dump::Table
|
19
19
|
class View < KeyStruct[:name, :definition]
|
20
20
|
def assemble(stream)
|
21
|
-
|
21
|
+
heredelim = "END_VIEW_#{name.upcase}"
|
22
|
+
stream.puts " create_view #{name.to_json}, <<-#{heredelim}, :force => true\n"
|
23
|
+
definition.split("\n").each { |line| stream.puts line.to_json[1...-1] + "\n" }
|
24
|
+
stream.puts " #{heredelim}\n\n"
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
data/spec/dumper_spec.rb
CHANGED
@@ -16,8 +16,9 @@ describe "Dumper" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should include view definitions" do
|
19
|
-
|
20
|
-
expect(dump).to match(
|
19
|
+
puts dump
|
20
|
+
expect(dump).to match(view_re("a_ones", /SELECT .*b.*,.*s.* FROM .*items.* WHERE \(?.*a.* = 1\)?/mi))
|
21
|
+
expect(dump).to match(view_re("ab_ones", /SELECT .*s.* FROM .*a_ones.* WHERE \(?.*b.* = 1\)?/mi))
|
21
22
|
end
|
22
23
|
|
23
24
|
it "should include views in dependency order" do
|
@@ -26,7 +27,7 @@ describe "Dumper" do
|
|
26
27
|
|
27
28
|
it "should not include views listed in ignore_tables" do
|
28
29
|
dump(ignore_tables: /b_/) do |dump|
|
29
|
-
expect(dump).to match(
|
30
|
+
expect(dump).to match(view_re("a_ones", /SELECT .*b.*,.*s.* FROM .*items.* WHERE \(?.*a.* = 1\)?/mi))
|
30
31
|
expect(dump).not_to match(%r{"ab_ones"})
|
31
32
|
end
|
32
33
|
end
|
@@ -45,6 +46,11 @@ describe "Dumper" do
|
|
45
46
|
|
46
47
|
protected
|
47
48
|
|
49
|
+
def view_re(name, re)
|
50
|
+
heredelim = "END_VIEW_#{name.upcase}"
|
51
|
+
%r{create_view "#{name}", <<-#{heredelim}, :force => true\n\s*#{re}\s*\n *#{heredelim}$}mi
|
52
|
+
end
|
53
|
+
|
48
54
|
def define_schema_and_data
|
49
55
|
connection.views.each do |view| connection.drop_view view end
|
50
56
|
connection.tables.each do |table| connection.drop_table table, cascade: true end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|