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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd6d659f8f14cd535594ec9233de26f7f660c847
4
- data.tar.gz: 523f1a8313390bca0c4c23a42ea47ab11400a918
3
+ metadata.gz: be07e759aa1592dd80a7f81bbec2427fff93af61
4
+ data.tar.gz: 51318f8f014f9b6980730a7be4cbe8d2256c112b
5
5
  SHA512:
6
- metadata.gz: ad687b0f31773a795e3e044a1c6d656dbd0dfd0ddb5a6f31b94476ef2c4430ddac2f26aa15da99a380a7c042003463bfd7ce070d22fe6a8ad69824644ff4c2ac
7
- data.tar.gz: e257df4302a3e45744df45f9e886f457b6cfdc8c8063f18b5ac688bbaae2300e01ddd669190d4a35c850b83ca1b99e06aa574d748d9a2b6a1d4d3c7ec0f00452
6
+ metadata.gz: 32fb3217aba66d3fee88ca8d11799f96f003c65ba10927117dbe37e829f76eb0eb0c2addc9d2f84eb109397cd354bd01fec3ef5597c18e864a2327dbdcb8276e
7
+ data.tar.gz: de60f0942691053b95da785306fc6bb3c33a6adddfb6cf62a400c5ba0f522084f7613f7f884bd5d04f7cd19b9a5bab5cf564645c8381c9f1caa29feaa8115c43
@@ -1,3 +1,5 @@
1
1
  = Viewy
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ = NOTE this is only for use with postgres 9.4 or higher.
4
+
5
+ This project rocks and uses MIT-LICENSE.
@@ -1,4 +1,8 @@
1
- # desc "Explaining what the task does"
2
- # task :viewy do
3
- # # Task goes here
4
- # end
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Viewy
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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.5
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-02 00:00:00.000000000 Z
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.4.5
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