table_saw 0.2.1 → 0.3.0

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
  SHA256:
3
- metadata.gz: d488fbc1065d74a9ee27d2197634b8caa66859f0658a83e268e44c9b9a8534f4
4
- data.tar.gz: 269976846ca8d1a75282cc22228953ae798e65287f559ccb5881093311fd5252
3
+ metadata.gz: ce7f117d5db32cc1d9617f4f09126a60636519a1b8445ce2c65575120deac9db
4
+ data.tar.gz: 212a3f010918b397329ed3510c831898370865a60ee8949948b60f70f05f6a6d
5
5
  SHA512:
6
- metadata.gz: e275dc24ffa5107f9512c90deaf803bfcda080b277bb4f25049dc4f0ea1b84d75f7dbad9a3b5b5168871644356beec801ede7203464ea86a99d0964e7c29d790
7
- data.tar.gz: 31f5764301e19166431bd9f9ee055f33de9f57488b4e4184e4f4a79a6d1ab962690e0cd46fb7976e948b2aded7f89eda5620ef4f9bc4c749af7782c820bff57e
6
+ metadata.gz: e11664a36c6c5a649d4f79ed4018b24b9681d68053a0187b5927582d24dbf1f62fa706511bd493fb19ff583316083f1fbac17173efdfec6feb13f8432188cd54
7
+ data.tar.gz: 6375f829abd5d21a7aee6f36891d1e0a1f2778dbf59eab9c42cde7817d22a34f0831cf733a9053d9a429149338cae782ee64029288197ec0414afc084450339a
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 2.6
3
5
 
data/.travis.yml CHANGED
@@ -17,3 +17,5 @@ script:
17
17
  - bundle exec rspec
18
18
  after_script:
19
19
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
20
+ addons:
21
+ postgresql: "9.3"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_saw (0.2.1)
4
+ table_saw (0.3.0)
5
5
  connection_pool
6
6
  pg
7
7
  thor
@@ -34,6 +34,7 @@ GEM
34
34
  minitest (~> 5.1)
35
35
  tzinfo (~> 1.1)
36
36
  arel (9.0.0)
37
+ ast (2.4.0)
37
38
  builder (3.2.3)
38
39
  combustion (1.1.0)
39
40
  activesupport (>= 3.0.0)
@@ -48,6 +49,7 @@ GEM
48
49
  erubi (1.8.0)
49
50
  i18n (1.6.0)
50
51
  concurrent-ruby (~> 1.0)
52
+ jaro_winkler (1.5.2)
51
53
  json (2.2.0)
52
54
  loofah (2.2.3)
53
55
  crass (~> 1.0.2)
@@ -57,6 +59,9 @@ GEM
57
59
  minitest (5.11.3)
58
60
  nokogiri (1.10.3)
59
61
  mini_portile2 (~> 2.4.0)
62
+ parallel (1.17.0)
63
+ parser (2.6.3.0)
64
+ ast (~> 2.4.0)
60
65
  pg (1.1.4)
61
66
  rack (2.0.7)
62
67
  rack-test (1.1.0)
@@ -72,6 +77,7 @@ GEM
72
77
  method_source
73
78
  rake (>= 0.8.7)
74
79
  thor (>= 0.19.0, < 2.0)
80
+ rainbow (3.0.0)
75
81
  rake (10.5.0)
76
82
  rspec (3.8.0)
77
83
  rspec-core (~> 3.8.0)
@@ -86,6 +92,19 @@ GEM
86
92
  diff-lcs (>= 1.2.0, < 2.0)
87
93
  rspec-support (~> 3.8.0)
88
94
  rspec-support (3.8.0)
95
+ rubocop (0.71.0)
96
+ jaro_winkler (~> 1.5.1)
97
+ parallel (~> 1.10)
98
+ parser (>= 2.6)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ ruby-progressbar (~> 1.7)
101
+ unicode-display_width (>= 1.4.0, < 1.7)
102
+ rubocop-rspec (1.33.0)
103
+ rubocop (>= 0.60.0)
104
+ ruby-progressbar (1.10.1)
105
+ scenic (1.5.1)
106
+ activerecord (>= 4.0.0)
107
+ railties (>= 4.0.0)
89
108
  simplecov (0.16.1)
90
109
  docile (~> 1.1)
91
110
  json (>= 1.8, < 3)
@@ -95,6 +114,7 @@ GEM
95
114
  thread_safe (0.3.6)
96
115
  tzinfo (1.2.5)
97
116
  thread_safe (~> 0.1)
117
+ unicode-display_width (1.6.0)
98
118
 
99
119
  PLATFORMS
100
120
  ruby
@@ -106,6 +126,8 @@ DEPENDENCIES
106
126
  database_cleaner (~> 1.7)
107
127
  rake (~> 10.0)
108
128
  rspec (~> 3.0)
129
+ rubocop-rspec (~> 1.33)
130
+ scenic (~> 1.5)
109
131
  simplecov (~> 0.16)
110
132
  table_saw!
111
133
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'table_saw/queries/table_columns'
4
+ require 'table_saw/queries/materialized_views'
4
5
 
5
6
  module TableSaw
6
7
  class CreateDumpFile
@@ -11,7 +12,7 @@ module TableSaw
11
12
  @file = file
12
13
  end
13
14
 
14
- # rubocop:disable Metrics/MethodLength
15
+ # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
15
16
  def call
16
17
  write_to_file <<~SQL
17
18
  BEGIN;
@@ -51,12 +52,20 @@ module TableSaw
51
52
  write_to_file "\n"
52
53
  end
53
54
 
55
+ refresh_materialized_views
56
+
54
57
  write_to_file 'COMMIT;'
55
58
  end
56
- # rubocop:enable Metrics/MethodLength
59
+ # rubocop:enable Metrics/MethodLength,Metrics/AbcSize
57
60
 
58
61
  private
59
62
 
63
+ def refresh_materialized_views
64
+ TableSaw::Queries::MaterializedViews.new.call.each do |view|
65
+ write_to_file "REFRESH MATERIALIZED VIEW #{view};"
66
+ end
67
+ end
68
+
60
69
  def write_to_file(data)
61
70
  File.open(file, 'ab') { |f| f.puts(data) }
62
71
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'table_saw/connection'
4
+
5
+ module TableSaw
6
+ module Queries
7
+ class MaterializedViews
8
+ def call
9
+ TableSaw::Connection.with do |conn|
10
+ conn.exec('select matviewname from pg_matviews order by matviewname').map { |row| row['matviewname'] }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableSaw
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/table_saw.gemspec CHANGED
@@ -33,5 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'database_cleaner', '~> 1.7'
34
34
  spec.add_development_dependency 'rake', '~> 10.0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.33'
37
+ spec.add_development_dependency 'scenic', '~> 1.5'
36
38
  spec.add_development_dependency 'simplecov', '~> 0.16'
37
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_saw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamed Asghari
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-09 00:00:00.000000000 Z
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.33'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.33'
153
+ - !ruby/object:Gem::Dependency
154
+ name: scenic
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.5'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.5'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +208,7 @@ files:
180
208
  - lib/table_saw/create_dump_file.rb
181
209
  - lib/table_saw/manifest.rb
182
210
  - lib/table_saw/queries/foreign_key_relationships.rb
211
+ - lib/table_saw/queries/materialized_views.rb
183
212
  - lib/table_saw/queries/no_id_tables.rb
184
213
  - lib/table_saw/queries/table_columns.rb
185
214
  - lib/table_saw/version.rb