viewy 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -1
- data/lib/tasks/viewy_tasks.rake +8 -4
- data/lib/viewy.rb +19 -0
- data/lib/viewy/dependency_manager.rb +2 -13
- data/lib/viewy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be07e759aa1592dd80a7f81bbec2427fff93af61
|
4
|
+
data.tar.gz: 51318f8f014f9b6980730a7be4cbe8d2256c112b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32fb3217aba66d3fee88ca8d11799f96f003c65ba10927117dbe37e829f76eb0eb0c2addc9d2f84eb109397cd354bd01fec3ef5597c18e864a2327dbdcb8276e
|
7
|
+
data.tar.gz: de60f0942691053b95da785306fc6bb3c33a6adddfb6cf62a400c5ba0f522084f7613f7f884bd5d04f7cd19b9a5bab5cf564645c8381c9f1caa29feaa8115c43
|
data/README.rdoc
CHANGED
data/lib/tasks/viewy_tasks.rake
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :viewy do
|
2
|
+
desc 'This task updates the dependency information view'
|
3
|
+
task :refresh_dependency_information, :environment do
|
4
|
+
puts 'Refreshing view dependency information cache...'
|
5
|
+
Viewy.refresh_dependency_information
|
6
|
+
puts 'View dependency information refresh complete.'
|
7
|
+
end
|
8
|
+
end
|
data/lib/viewy.rb
CHANGED
@@ -5,5 +5,24 @@ require 'viewy/acts_as_materialized_view'
|
|
5
5
|
require 'viewy/dependency_management'
|
6
6
|
require 'viewy/dependency_manager'
|
7
7
|
|
8
|
+
# Viewy provides a means of interacting with views in a Postgres database in a way that allows the manipulation
|
9
|
+
# of views and their dependencies
|
8
10
|
module Viewy
|
11
|
+
# Calling this method will refresh the materialized view that stores the dependency information for other
|
12
|
+
# views in the system
|
13
|
+
#
|
14
|
+
# @raise [ActiveRecord::StatementInvalidError] raised if a dependent view is somehow not refreshed correctly
|
15
|
+
# @return [PG::Result] the result of the refresh statement on the materialized view
|
16
|
+
def self.refresh_dependency_information
|
17
|
+
view_refresher = Viewy::DependencyManagement::ViewRefresher.new(connection)
|
18
|
+
view_refresher.refresh_materialized_view('materialized_view_dependencies')
|
19
|
+
end
|
20
|
+
|
21
|
+
# The connection used by viewy to manage views
|
22
|
+
#
|
23
|
+
# @return [ActiveRecord::ConnectionAdapters::PostgreSQLAdapter] An ActiveRecord connection
|
24
|
+
# to a Postgres Database
|
25
|
+
def self.connection
|
26
|
+
ActiveRecord::Base.connection
|
27
|
+
end
|
9
28
|
end
|
@@ -3,11 +3,6 @@ module Viewy
|
|
3
3
|
#
|
4
4
|
# NOTE: the dependencies view is refreshed when an instance is initialized and this can take a little while to run.
|
5
5
|
class DependencyManager
|
6
|
-
# @param connection [ActiveRecord::ConnectionAdapters::PostgreSQLAdapter] An ActiveRecord connection
|
7
|
-
# to a Postgres Database
|
8
|
-
def initialize
|
9
|
-
view_refresher.refresh_materialized_view('materialized_view_dependencies')
|
10
|
-
end
|
11
6
|
|
12
7
|
# This method will refresh all materialized views in order of dependency
|
13
8
|
#
|
@@ -33,18 +28,12 @@ module Viewy
|
|
33
28
|
# @raise [ActiveRecord::StatementInvalidError] raised if a dependent view is somehow not refreshed correctly
|
34
29
|
# @return [PG::Result] the result of the refresh statement on the materialized view
|
35
30
|
def replace_view(view_name, new_definition_sql)
|
36
|
-
connection.execute("SELECT replace_view('#{view_name}', $$#{new_definition_sql}$$)")
|
31
|
+
Viewy.connection.execute("SELECT replace_view('#{view_name}', $$#{new_definition_sql}$$)")
|
37
32
|
end
|
38
33
|
|
39
34
|
# @return [Viewy::DependencyManagement::ViewRefresher] a memoized view refresher object
|
40
35
|
private def view_refresher
|
41
|
-
@view_refresher ||= Viewy::DependencyManagement::ViewRefresher.new(connection)
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [ActiveRecord::ConnectionAdapters::PostgreSQLAdapter] An ActiveRecord connection
|
45
|
-
# to a Postgres Database
|
46
|
-
private def connection
|
47
|
-
ActiveRecord::Base.connection
|
36
|
+
@view_refresher ||= Viewy::DependencyManagement::ViewRefresher.new(Viewy.connection)
|
48
37
|
end
|
49
38
|
end
|
50
39
|
end
|
data/lib/viewy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emerson Huitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.2.2
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Viewy is a tool for managing views in Rails applications
|