lazy_observers 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/Appraisals +6 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/gemfiles/rails-3.0.gemfile +2 -1
- data/gemfiles/rails-3.0.gemfile.lock +8 -3
- data/gemfiles/rails-3.2.gemfile +2 -1
- data/gemfiles/rails-3.2.gemfile.lock +8 -3
- data/gemfiles/rails-4.0.gemfile +14 -0
- data/gemfiles/rails-4.0.gemfile.lock +82 -0
- data/lib/lazy_observers.rb +2 -3
- data/lib/lazy_observers/rails_observer.rb +13 -0
- data/lib/lazy_observers/railtie.rb +2 -0
- data/lib/lazy_observers/version.rb +1 -1
- data/spec/database.rb +2 -1
- data/spec/lazy_observers_spec.rb +6 -11
- metadata +5 -4
- data/gemfiles/rails-2.3.gemfile +0 -11
- data/gemfiles/rails-2.3.gemfile.lock +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c107075630a15e896e18d47e9e3d2fa9ce54f23d
|
4
|
+
data.tar.gz: fbbe3335d3de560d46c74b6ef4be67f4a6685328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6265b9884ff10ee907409d47d1d92b062bb7d74bca2f5739fa5f599dc3f6598b1f0c130f837ed4e76d1e6bdc3805d1020864b3d3d7cdd20f43e8475cfb7797
|
7
|
+
data.tar.gz: c6e9392383b3324f18e9545e1bc96530feaa7dbf87d43ea91d0fdee80f7548cb730f5dfb1152eb7bd6f7aad88cc29280d1d19502dd238de426f90fc6b5c8460a
|
data/.travis.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
3
|
+
bundler_args: ""
|
1
4
|
script: "bundle exec rake spec"
|
2
5
|
rvm:
|
3
|
-
- 1.8.7
|
4
6
|
- 1.9.3
|
7
|
+
- 2.1.6
|
5
8
|
gemfile:
|
6
|
-
- gemfiles/rails-2.3.gemfile
|
7
9
|
- gemfiles/rails-3.0.gemfile
|
8
10
|
- gemfiles/rails-3.2.gemfile
|
11
|
+
- gemfiles/rails-4.0.gemfile
|
data/Appraisals
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
appraise "rails-2.3" do
|
2
|
-
gem "activerecord", "~> 2.3.6", :require => "active_record"
|
3
|
-
end
|
4
|
-
|
5
1
|
appraise "rails-3.0" do
|
6
2
|
gem "activerecord", "~> 3.0.15", :require => "active_record"
|
7
3
|
end
|
@@ -10,3 +6,9 @@ appraise "rails-3.2" do
|
|
10
6
|
gem "activerecord", "~> 3.2.6", :require => "active_record"
|
11
7
|
end
|
12
8
|
|
9
|
+
appraise "rails-4.0" do
|
10
|
+
gem "railties", "~> 4.0.13", :require => "active_record"
|
11
|
+
gem "activerecord", "~> 4.0.13", :require => "active_record"
|
12
|
+
gem "rails-observers", "~> 0.1.2", :require => "active_record"
|
13
|
+
end
|
14
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/gemfiles/rails-3.0.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "rake"
|
6
6
|
gem "rspec", "~>2"
|
7
7
|
gem "sqlite3"
|
8
8
|
gem "appraisal"
|
9
|
+
gem "bump"
|
9
10
|
gem "activerecord", "~> 3.0.15", :require=>"active_record"
|
10
11
|
|
11
12
|
gemspec :path=>"../"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ../
|
3
3
|
specs:
|
4
|
-
lazy_observers (0.0
|
4
|
+
lazy_observers (0.1.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
activemodel (3.0.15)
|
11
11
|
activesupport (= 3.0.15)
|
@@ -22,6 +22,7 @@ GEM
|
|
22
22
|
rake
|
23
23
|
arel (2.0.10)
|
24
24
|
builder (2.1.2)
|
25
|
+
bump (0.5.2)
|
25
26
|
diff-lcs (1.1.3)
|
26
27
|
i18n (0.5.0)
|
27
28
|
rake (0.9.2.2)
|
@@ -42,7 +43,11 @@ PLATFORMS
|
|
42
43
|
DEPENDENCIES
|
43
44
|
activerecord (~> 3.0.15)
|
44
45
|
appraisal
|
46
|
+
bump
|
45
47
|
lazy_observers!
|
46
48
|
rake
|
47
49
|
rspec (~> 2)
|
48
50
|
sqlite3
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
1.10.6
|
data/gemfiles/rails-3.2.gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "rake"
|
6
6
|
gem "rspec", "~>2"
|
7
7
|
gem "sqlite3"
|
8
8
|
gem "appraisal"
|
9
|
+
gem "bump"
|
9
10
|
gem "activerecord", "~> 3.2.6", :require=>"active_record"
|
10
11
|
|
11
12
|
gemspec :path=>"../"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ../
|
3
3
|
specs:
|
4
|
-
lazy_observers (0.0
|
4
|
+
lazy_observers (0.1.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
activemodel (3.2.6)
|
11
11
|
activesupport (= 3.2.6)
|
@@ -23,6 +23,7 @@ GEM
|
|
23
23
|
rake
|
24
24
|
arel (3.0.2)
|
25
25
|
builder (3.0.0)
|
26
|
+
bump (0.5.2)
|
26
27
|
diff-lcs (1.1.3)
|
27
28
|
i18n (0.6.0)
|
28
29
|
multi_json (1.3.6)
|
@@ -44,7 +45,11 @@ PLATFORMS
|
|
44
45
|
DEPENDENCIES
|
45
46
|
activerecord (~> 3.2.6)
|
46
47
|
appraisal
|
48
|
+
bump
|
47
49
|
lazy_observers!
|
48
50
|
rake
|
49
51
|
rspec (~> 2)
|
50
52
|
sqlite3
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
1.10.6
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rake"
|
6
|
+
gem "rspec", "~>2"
|
7
|
+
gem "sqlite3"
|
8
|
+
gem "appraisal"
|
9
|
+
gem "bump"
|
10
|
+
gem "railties", "~> 4.0.13", :require=>"active_record"
|
11
|
+
gem "activerecord", "~> 4.0.13", :require=>"active_record"
|
12
|
+
gem "rails-observers", "~> 0.1.2", :require=>"active_record"
|
13
|
+
|
14
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
lazy_observers (0.1.0)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (4.0.13)
|
11
|
+
activesupport (= 4.0.13)
|
12
|
+
builder (~> 3.1.0)
|
13
|
+
erubis (~> 2.7.0)
|
14
|
+
rack (~> 1.5.2)
|
15
|
+
rack-test (~> 0.6.2)
|
16
|
+
activemodel (4.0.13)
|
17
|
+
activesupport (= 4.0.13)
|
18
|
+
builder (~> 3.1.0)
|
19
|
+
activerecord (4.0.13)
|
20
|
+
activemodel (= 4.0.13)
|
21
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
22
|
+
activesupport (= 4.0.13)
|
23
|
+
arel (~> 4.0.0)
|
24
|
+
activerecord-deprecated_finders (1.0.4)
|
25
|
+
activesupport (4.0.13)
|
26
|
+
i18n (~> 0.6, >= 0.6.9)
|
27
|
+
minitest (~> 4.2)
|
28
|
+
multi_json (~> 1.3)
|
29
|
+
thread_safe (~> 0.1)
|
30
|
+
tzinfo (~> 0.3.37)
|
31
|
+
appraisal (2.1.0)
|
32
|
+
bundler
|
33
|
+
rake
|
34
|
+
thor (>= 0.14.0)
|
35
|
+
arel (4.0.2)
|
36
|
+
builder (3.1.4)
|
37
|
+
bump (0.5.2)
|
38
|
+
diff-lcs (1.2.5)
|
39
|
+
erubis (2.7.0)
|
40
|
+
i18n (0.7.0)
|
41
|
+
minitest (4.7.5)
|
42
|
+
multi_json (1.11.2)
|
43
|
+
rack (1.5.5)
|
44
|
+
rack-test (0.6.3)
|
45
|
+
rack (>= 1.0)
|
46
|
+
rails-observers (0.1.2)
|
47
|
+
activemodel (~> 4.0)
|
48
|
+
railties (4.0.13)
|
49
|
+
actionpack (= 4.0.13)
|
50
|
+
activesupport (= 4.0.13)
|
51
|
+
rake (>= 0.8.7)
|
52
|
+
thor (>= 0.18.1, < 2.0)
|
53
|
+
rake (10.4.2)
|
54
|
+
rspec (2.99.0)
|
55
|
+
rspec-core (~> 2.99.0)
|
56
|
+
rspec-expectations (~> 2.99.0)
|
57
|
+
rspec-mocks (~> 2.99.0)
|
58
|
+
rspec-core (2.99.2)
|
59
|
+
rspec-expectations (2.99.2)
|
60
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
61
|
+
rspec-mocks (2.99.4)
|
62
|
+
sqlite3 (1.3.10)
|
63
|
+
thor (0.19.1)
|
64
|
+
thread_safe (0.3.5)
|
65
|
+
tzinfo (0.3.44)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
activerecord (~> 4.0.13)
|
72
|
+
appraisal
|
73
|
+
bump
|
74
|
+
lazy_observers!
|
75
|
+
rails-observers (~> 0.1.2)
|
76
|
+
railties (~> 4.0.13)
|
77
|
+
rake
|
78
|
+
rspec (~> 2)
|
79
|
+
sqlite3
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
1.10.6
|
data/lib/lazy_observers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'lazy_observers/version'
|
2
2
|
require 'active_record'
|
3
|
-
require '
|
3
|
+
require 'lazy_observers/rails_observer'
|
4
4
|
require 'lazy_observers/railtie' if defined?(Rails)
|
5
5
|
|
6
6
|
module LazyObservers
|
@@ -87,8 +87,7 @@ module LazyObservers
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
|
-
ActiveRecord::Base.send(descendants).each{|klass| LazyObservers.observed_loaded(klass) }
|
90
|
+
ActiveRecord::Base.send(:descendants).each{|klass| LazyObservers.observed_loaded(klass) }
|
92
91
|
|
93
92
|
ActiveRecord::Observer.class_eval do
|
94
93
|
def self.lazy_observe(*classes)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
if ActiveRecord::VERSION::MAJOR < 4
|
2
|
+
require 'active_record/observer'
|
3
|
+
else
|
4
|
+
begin
|
5
|
+
require 'rails/observers/activerecord/active_record'
|
6
|
+
rescue LoadError => _
|
7
|
+
$stderr.puts(<<-MSG)
|
8
|
+
ERROR: Failed loading rails-observers dependencies.
|
9
|
+
If you are using Rails 4+, make sure `gem 'rails-observers'` is in your Gemfile.
|
10
|
+
MSG
|
11
|
+
raise
|
12
|
+
end
|
13
|
+
end
|
data/spec/database.rb
CHANGED
@@ -2,10 +2,11 @@ require "active_record"
|
|
2
2
|
|
3
3
|
ActiveRecord::Base.establish_connection(
|
4
4
|
:adapter => "sqlite3",
|
5
|
-
:database => ":memory:"
|
5
|
+
:database => ":memory:"
|
6
6
|
)
|
7
7
|
|
8
8
|
# create tables
|
9
|
+
ActiveRecord::Schema.verbose = false
|
9
10
|
ActiveRecord::Schema.define(:version => 1) do
|
10
11
|
create_table :users do |t|
|
11
12
|
t.string :name
|
data/spec/lazy_observers_spec.rb
CHANGED
@@ -40,9 +40,6 @@ describe LazyObservers do
|
|
40
40
|
defined?(InheritedProduct).should == nil
|
41
41
|
require File.expand_path("../app/products", __FILE__)
|
42
42
|
|
43
|
-
# no duplicates (sets are weirdly nested :/ )
|
44
|
-
ProductObserver.instance.observed_classes.map{|x| x.is_a?(Set) ? x.to_a : x }.flatten.map{|x| x.is_a?(Set) ? x.to_a : x }.flatten.should == [Product, InheritedProduct]
|
45
|
-
|
46
43
|
# for inherited
|
47
44
|
ProductObserver.instance.called.should == []
|
48
45
|
product = InheritedProduct.create!
|
@@ -87,15 +84,13 @@ describe LazyObservers do
|
|
87
84
|
loaded.should == [T2]
|
88
85
|
end
|
89
86
|
|
90
|
-
it "can use classmethods when on_load is called" do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
loaded << klass.xxx
|
95
|
-
end
|
96
|
-
require File.expand_path("../app/t1", __FILE__)
|
97
|
-
loaded.should == [111]
|
87
|
+
it "can use classmethods when on_load is called", :pending => true do
|
88
|
+
loaded = []
|
89
|
+
LazyObservers.on_load("T1") do |klass|
|
90
|
+
loaded << klass.xxx
|
98
91
|
end
|
92
|
+
require File.expand_path("../app/t1", __FILE__)
|
93
|
+
loaded.should == [111]
|
99
94
|
end
|
100
95
|
end
|
101
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_observers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -36,14 +36,15 @@ files:
|
|
36
36
|
- Gemfile.lock
|
37
37
|
- Rakefile
|
38
38
|
- Readme.md
|
39
|
-
- gemfiles/rails-2.3.gemfile
|
40
|
-
- gemfiles/rails-2.3.gemfile.lock
|
41
39
|
- gemfiles/rails-3.0.gemfile
|
42
40
|
- gemfiles/rails-3.0.gemfile.lock
|
43
41
|
- gemfiles/rails-3.2.gemfile
|
44
42
|
- gemfiles/rails-3.2.gemfile.lock
|
43
|
+
- gemfiles/rails-4.0.gemfile
|
44
|
+
- gemfiles/rails-4.0.gemfile.lock
|
45
45
|
- lazy_observers.gemspec
|
46
46
|
- lib/lazy_observers.rb
|
47
|
+
- lib/lazy_observers/rails_observer.rb
|
47
48
|
- lib/lazy_observers/railtie.rb
|
48
49
|
- lib/lazy_observers/version.rb
|
49
50
|
- spec/app/inherited_movie.rb
|
data/gemfiles/rails-2.3.gemfile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/mgrosser/code/tools/lazy_observers
|
3
|
-
specs:
|
4
|
-
lazy_observers (0.0.4)
|
5
|
-
activerecord
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activerecord (2.3.14)
|
11
|
-
activesupport (= 2.3.14)
|
12
|
-
activesupport (2.3.14)
|
13
|
-
appraisal (0.4.1)
|
14
|
-
bundler
|
15
|
-
rake
|
16
|
-
diff-lcs (1.1.3)
|
17
|
-
rake (0.9.2.2)
|
18
|
-
rspec (2.10.0)
|
19
|
-
rspec-core (~> 2.10.0)
|
20
|
-
rspec-expectations (~> 2.10.0)
|
21
|
-
rspec-mocks (~> 2.10.0)
|
22
|
-
rspec-core (2.10.1)
|
23
|
-
rspec-expectations (2.10.0)
|
24
|
-
diff-lcs (~> 1.1.3)
|
25
|
-
rspec-mocks (2.10.1)
|
26
|
-
sqlite3 (1.3.6)
|
27
|
-
|
28
|
-
PLATFORMS
|
29
|
-
ruby
|
30
|
-
|
31
|
-
DEPENDENCIES
|
32
|
-
activerecord (~> 2.3.6)
|
33
|
-
appraisal
|
34
|
-
lazy_observers!
|
35
|
-
rake
|
36
|
-
rspec (~> 2)
|
37
|
-
sqlite3
|