activerecord_snapshot_view 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/lib/activerecord_snapshot_view/snapshot_view.rb +17 -10
- data/spec/activerecord_snapshot_view_spec.rb +12 -0
- data/spec/spec_helper.rb +2 -2
- metadata +47 -8
- data/spec/activerecord_snapshot_view.rb +0 -7
data/Rakefile
CHANGED
@@ -13,7 +13,9 @@ begin
|
|
13
13
|
gem.email = "mccraigmccraig@googlemail.com"
|
14
14
|
gem.homepage = "http://github.com/mccraigmccraig/activerecord_snapshot_view"
|
15
15
|
gem.authors = ["mccraig mccraig of the clan mccraig"]
|
16
|
+
gem.add_dependency "activerecord", ">= 2.3.9"
|
16
17
|
gem.add_development_dependency "rspec"
|
18
|
+
gem.add_development_dependency "rr", ">= 0.10.5"
|
17
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
20
|
end
|
19
21
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.5
|
@@ -10,13 +10,17 @@
|
|
10
10
|
# version table in the database
|
11
11
|
|
12
12
|
# AssocationReflection caches table names... we have to undo this
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
module ActiveRecord
|
14
|
+
module Reflection
|
15
|
+
class AssociationReflection
|
16
|
+
def table_name
|
17
|
+
klass.table_name
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
def quoted_table_name
|
21
|
+
klass.quoted_table_name
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -30,19 +34,22 @@ module ActiveRecord
|
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
37
|
+
def self.class_from_symbol(sym)
|
38
|
+
eval(sym.to_s.camelize)
|
39
|
+
end
|
40
|
+
|
33
41
|
# prepare a SnapshotView model for migration... move all data to the
|
34
42
|
# base table, make that current, and remove the other store tables.
|
35
43
|
# if the model no longer exists, or is no longer a SnapshotView,
|
36
44
|
# catch any errors
|
37
|
-
def self.prepare_to_migrate(
|
38
|
-
klassname = model.to_s.singularize.camelize
|
45
|
+
def self.prepare_to_migrate(model_sym)
|
39
46
|
begin
|
40
|
-
klass =
|
47
|
+
klass = class_from_symbol(model_sym)
|
41
48
|
if klass.ancestors.include?(ActiveRecord::SnapshotView)
|
42
49
|
klass.prepare_to_migrate
|
43
50
|
end
|
44
51
|
rescue
|
45
|
-
$stderr << "model: #{
|
52
|
+
$stderr << "model: #{model_sym} no longer exists?\n"
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "ActiverecordSnapshotView" do
|
4
|
+
describe "prepare_to_migrate" do
|
5
|
+
describe "class from symbol" do
|
6
|
+
it "should return a class given a symbol" do
|
7
|
+
ActiveRecord::SnapshotView.class_from_symbol(:object).should == Object
|
8
|
+
ActiveRecord::SnapshotView.class_from_symbol(:"active_record/snapshot_view").should == ActiveRecord::SnapshotView
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require '
|
3
|
+
require 'activerecord_snapshot_view'
|
4
4
|
require 'spec'
|
5
5
|
require 'spec/autorun'
|
6
6
|
|
7
7
|
Spec::Runner.configure do |config|
|
8
|
-
|
8
|
+
config.mock_with :rr
|
9
9
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_snapshot_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 11
|
8
|
-
-
|
9
|
-
version: 0.11.
|
9
|
+
- 5
|
10
|
+
version: 0.11.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- mccraig mccraig of the clan mccraig
|
@@ -14,21 +15,55 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-03 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: activerecord
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 17
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 9
|
34
|
+
version: 2.3.9
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
24
42
|
requirements:
|
25
43
|
- - ">="
|
26
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
27
46
|
segments:
|
28
47
|
- 0
|
29
48
|
version: "0"
|
30
49
|
type: :development
|
31
|
-
version_requirements: *
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rr
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 61
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
- 10
|
63
|
+
- 5
|
64
|
+
version: 0.10.5
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
32
67
|
description: |-
|
33
68
|
manage snapshot materialized views for ActiveRecord. multiple
|
34
69
|
versions of each view are maintained, a live version, a working
|
@@ -51,7 +86,7 @@ files:
|
|
51
86
|
- VERSION
|
52
87
|
- lib/activerecord_snapshot_view.rb
|
53
88
|
- lib/activerecord_snapshot_view/snapshot_view.rb
|
54
|
-
- spec/
|
89
|
+
- spec/activerecord_snapshot_view_spec.rb
|
55
90
|
- spec/spec_helper.rb
|
56
91
|
has_rdoc: true
|
57
92
|
homepage: http://github.com/mccraigmccraig/activerecord_snapshot_view
|
@@ -63,26 +98,30 @@ rdoc_options:
|
|
63
98
|
require_paths:
|
64
99
|
- lib
|
65
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
66
102
|
requirements:
|
67
103
|
- - ">="
|
68
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
69
106
|
segments:
|
70
107
|
- 0
|
71
108
|
version: "0"
|
72
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
73
111
|
requirements:
|
74
112
|
- - ">="
|
75
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
76
115
|
segments:
|
77
116
|
- 0
|
78
117
|
version: "0"
|
79
118
|
requirements: []
|
80
119
|
|
81
120
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.3.
|
121
|
+
rubygems_version: 1.3.7
|
83
122
|
signing_key:
|
84
123
|
specification_version: 3
|
85
124
|
summary: snapshot materialized view support for ActiveRecord
|
86
125
|
test_files:
|
87
|
-
- spec/
|
126
|
+
- spec/activerecord_snapshot_view_spec.rb
|
88
127
|
- spec/spec_helper.rb
|