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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2a5ea547ab99bca7ef7d039c784b580065ef142
4
- data.tar.gz: b1dc65dab6140a1c68de87da4c2d6eb54620879b
3
+ metadata.gz: 7fc4b60cc9309357c2da20cbc1f47c1f70a84b7b
4
+ data.tar.gz: 373a4c477a67f60bf0eabe36c0091dcdb395123d
5
5
  SHA512:
6
- metadata.gz: f5e60a51b299a09aa1429f1da508a217c9306bb7a126ad0f499849255b1d7942edac5b2b905e3c82abc4cc2aeb3fc261451882f8786b30d5c981004c6e199725
7
- data.tar.gz: 01eb9ee07f00334652b549e81bd20a280ba6d9b0b5ac48d806d1eafe7dde63273817078566aa06245775f7a38322355884cb2e5296c1ceae857b09d56b2669fd
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
- stream.puts(" create_view #{name.inspect}, #{definition.inspect}, :force => true\n")
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
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Views
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -16,8 +16,9 @@ describe "Dumper" do
16
16
  end
17
17
 
18
18
  it "should include view definitions" do
19
- expect(dump).to match(%r{create_view "a_ones", " ?SELECT .*b.*,.*s.* FROM .*items.* WHERE .*a.* = 1.*, :force => true}mi)
20
- expect(dump).to match(%r{create_view "ab_ones", " ?SELECT .*s.* FROM .*a_ones.* WHERE .*b.* = 1.*, :force => true}mi)
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(%r{create_view "a_ones", " ?SELECT .*b.*,.*s.* FROM .*items.* WHERE .*a.* = 1.*, :force => true}mi)
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.1
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-15 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord