pg_gnostic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/Rakefile +2 -1
- data/lib/pg_gnostic/view_definition.rb +4 -0
- data/lib/pg_gnostic.rb +1 -0
- data/tasks/pg_gnostic_tasks.rake +3 -1
- data/test/view_definition_test.rb +9 -0
- metadata +27 -20
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -26,9 +26,10 @@ end
|
|
26
26
|
|
27
27
|
PKG_FILES = FileList[ '[a-zA-Z]*', 'generators/**/*', 'lib/**/*', 'rails/**/*', 'tasks/**/*', 'test/**/*' ]
|
28
28
|
|
29
|
+
require 'lib/pg_gnostic'
|
29
30
|
spec = Gem::Specification.new do |s|
|
30
31
|
s.name = "pg_gnostic"
|
31
|
-
s.version =
|
32
|
+
s.version = PgGnostic::VERSION
|
32
33
|
s.author = "niquola"
|
33
34
|
s.email = "niquola@gmail.com"
|
34
35
|
s.homepage = "http://github.com/niquola/pg_gnostic"
|
@@ -62,6 +62,10 @@ module PgGnostic
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def clear_declarations
|
66
|
+
@views={}
|
67
|
+
end
|
68
|
+
|
65
69
|
def create_view(name,opts={})
|
66
70
|
raise "View with name #{name} already registered" if views.key? name
|
67
71
|
opts[:depends_on] = to_arr opts[:depends_on] if opts.key? :depends_on
|
data/lib/pg_gnostic.rb
CHANGED
data/tasks/pg_gnostic_tasks.rake
CHANGED
@@ -69,13 +69,14 @@ namespace :pg do
|
|
69
69
|
|
70
70
|
rescue
|
71
71
|
$stderr.puts "It seems database #{config["database"]} already exists. Please drop it by hands (rake db:drop) before restore backup."
|
72
|
-
$stderr.puts
|
72
|
+
$stderr.puts $!
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
desc "drop views"
|
77
77
|
task :drop_views=>:environment do
|
78
78
|
#ActiveRecord::Base.logger=Logger.new STDOUT
|
79
|
+
PgGnostic::ViewDefinition.clear_declarations
|
79
80
|
PgGnostic::ViewDefinition.load_declarations(File.join(RAILS_ROOT,'db','views'))
|
80
81
|
PgGnostic::ViewDefinition.delete_all
|
81
82
|
end
|
@@ -83,6 +84,7 @@ namespace :pg do
|
|
83
84
|
desc "update views"
|
84
85
|
task :views=>:environment do
|
85
86
|
#ActiveRecord::Base.logger=Logger.new STDOUT
|
87
|
+
PgGnostic::ViewDefinition.clear_declarations
|
86
88
|
PgGnostic::ViewDefinition.load_declarations File.join(RAILS_ROOT,'db','views')
|
87
89
|
PgGnostic::ViewDefinition.update
|
88
90
|
end
|
@@ -42,4 +42,13 @@ class PgGnosticViewUtilsTest < ActiveSupport::TestCase
|
|
42
42
|
assert_not_contain_field(OtherUser,'crypted_password')
|
43
43
|
assert_not_contain_field(OtherUser,'deleted_at')
|
44
44
|
end
|
45
|
+
|
46
|
+
def test_clear_definitions
|
47
|
+
pg = PgGnostic::ViewDefinition
|
48
|
+
assert( pg.views.length > 0, 'ensure we have declarations')
|
49
|
+
pg.clear_declarations
|
50
|
+
assert( pg.views.length == 0, 'must be clear')
|
51
|
+
pg.load_declarations path('db/views')
|
52
|
+
assert( pg.views.length > 0, 'ensure we load them again')
|
53
|
+
end
|
45
54
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_gnostic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- niquola
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-27 00:00:00 +04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: kung_figure
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - "="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 0
|
@@ -41,31 +44,31 @@ extra_rdoc_files:
|
|
41
44
|
- README.rdoc
|
42
45
|
files:
|
43
46
|
- Rakefile
|
44
|
-
- README.rdoc
|
45
47
|
- MIT-LICENSE
|
46
|
-
-
|
47
|
-
- generators/pg_view/templates/view.rb
|
48
|
-
- generators/pg_view/templates/view.sql
|
49
|
-
- generators/pg_view/templates/model.rb
|
48
|
+
- README.rdoc
|
50
49
|
- generators/pg_view/USAGE
|
51
|
-
-
|
50
|
+
- generators/pg_view/templates/model.rb
|
51
|
+
- generators/pg_view/templates/view.sql
|
52
|
+
- generators/pg_view/templates/view.rb
|
53
|
+
- generators/pg_view/pg_view_generator.rb
|
52
54
|
- lib/pg_gnostic/config.rb
|
53
|
-
- lib/pg_gnostic/tasks.rb
|
54
55
|
- lib/pg_gnostic/view_definition.rb
|
56
|
+
- lib/pg_gnostic/tasks.rb
|
57
|
+
- lib/pg_gnostic.rb
|
55
58
|
- tasks/pg_gnostic_tasks.rake
|
56
|
-
- test/view_generator_test.rb
|
57
|
-
- test/pg_gnostic_test.rb
|
58
|
-
- test/database.yml
|
59
|
-
- test/db/views/users.rb
|
60
|
-
- test/db/views/other_users.sql
|
61
|
-
- test/db/schema.rb
|
62
|
-
- test/rails_root/app/model/views/role.rb
|
63
59
|
- test/rails_root/app/model/views/user.rb
|
64
|
-
- test/rails_root/
|
60
|
+
- test/rails_root/app/model/views/role.rb
|
65
61
|
- test/rails_root/db/views/roles.sql
|
62
|
+
- test/rails_root/db/views/users.rb
|
66
63
|
- test/config_test.rb
|
67
|
-
- test/view_definition_test.rb
|
68
64
|
- test/test_helper.rb
|
65
|
+
- test/pg_gnostic_test.rb
|
66
|
+
- test/database.yml
|
67
|
+
- test/view_definition_test.rb
|
68
|
+
- test/view_generator_test.rb
|
69
|
+
- test/db/schema.rb
|
70
|
+
- test/db/views/other_users.sql
|
71
|
+
- test/db/views/users.rb
|
69
72
|
has_rdoc: true
|
70
73
|
homepage: http://github.com/niquola/pg_gnostic
|
71
74
|
licenses: []
|
@@ -76,23 +79,27 @@ rdoc_options: []
|
|
76
79
|
require_paths:
|
77
80
|
- lib
|
78
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
79
83
|
requirements:
|
80
84
|
- - ">="
|
81
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
82
87
|
segments:
|
83
88
|
- 0
|
84
89
|
version: "0"
|
85
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
86
92
|
requirements:
|
87
93
|
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
89
96
|
segments:
|
90
97
|
- 0
|
91
98
|
version: "0"
|
92
99
|
requirements: []
|
93
100
|
|
94
101
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.7
|
96
103
|
signing_key:
|
97
104
|
specification_version: 3
|
98
105
|
summary: Rails plugin for postgres
|