seofy 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/seofy/active_record.rb +6 -6
- data/lib/seofy/adapters/base.rb +2 -2
- data/lib/seofy/task_runner.rb +1 -0
- data/lib/seofy/version.rb +1 -1
- data/spec/lib/seofy/active_record_spec.rb +6 -6
- data/spec/lib/seofy/adapters/base_spec.rb +3 -3
- data/spec/lib/seofy/task_runner_spec.rb +6 -0
- metadata +4 -5
- data/Gemfile.lock +0 -50
data/.gitignore
CHANGED
data/lib/seofy/active_record.rb
CHANGED
@@ -4,8 +4,8 @@ module Seofy
|
|
4
4
|
def seofy(options={})
|
5
5
|
init_seofy_config(options)
|
6
6
|
include ::Seofy::ActiveRecord::InstanceMethods
|
7
|
-
|
8
|
-
|
7
|
+
before_create :seofy_before_create
|
8
|
+
after_create :seofy_after_create
|
9
9
|
end
|
10
10
|
|
11
11
|
def init_seofy_config(options={})
|
@@ -35,12 +35,12 @@ module Seofy
|
|
35
35
|
self.send(self.class.seofy_config.source).to_s
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
self.class.seofy_adapter.
|
38
|
+
def seofy_before_create
|
39
|
+
self.class.seofy_adapter.before_create(self)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
self.class.seofy_adapter.
|
42
|
+
def seofy_after_create
|
43
|
+
self.class.seofy_adapter.after_create(self)
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
data/lib/seofy/adapters/base.rb
CHANGED
data/lib/seofy/task_runner.rb
CHANGED
data/lib/seofy/version.rb
CHANGED
@@ -11,8 +11,8 @@ describe Seofy::ActiveRecord do
|
|
11
11
|
@klass = Class.new
|
12
12
|
@klass.extend Seofy::ActiveRecord::ClassMethods
|
13
13
|
@klass.should_receive(:init_seofy_config)
|
14
|
-
@klass.should_receive(:
|
15
|
-
@klass.should_receive(:
|
14
|
+
@klass.should_receive(:after_create)
|
15
|
+
@klass.should_receive(:before_create)
|
16
16
|
@klass.seofy
|
17
17
|
end
|
18
18
|
|
@@ -71,10 +71,10 @@ describe Seofy::ActiveRecord do
|
|
71
71
|
|
72
72
|
it "should ask adapter handle callback" do
|
73
73
|
inst = @klass.new
|
74
|
-
@klass.should_receive(:seofy_adapter).and_return double(:
|
75
|
-
@klass.should_receive(:seofy_adapter).and_return double(:
|
76
|
-
inst.
|
77
|
-
inst.
|
74
|
+
@klass.should_receive(:seofy_adapter).and_return double(:before_create => true)
|
75
|
+
@klass.should_receive(:seofy_adapter).and_return double(:after_create => true)
|
76
|
+
inst.seofy_before_create
|
77
|
+
inst.seofy_after_create
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -6,15 +6,15 @@ describe Seofy::Adapters::Base do
|
|
6
6
|
|
7
7
|
it { should be_respond_to(:seofy_slug) }
|
8
8
|
it { should be_respond_to(:set_seofy_slug) }
|
9
|
-
it { should be_respond_to(:
|
10
|
-
it { should be_respond_to(:
|
9
|
+
it { should be_respond_to(:before_create) }
|
10
|
+
it { should be_respond_to(:after_create) }
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#before_save" do
|
14
14
|
it "should set_seofy_slug" do
|
15
15
|
adapter = Seofy::Adapters::Base.new
|
16
16
|
adapter.should_receive(:set_seofy_slug)
|
17
|
-
adapter.
|
17
|
+
adapter.before_create("anything")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -2,6 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Seofy::TaskRunner do
|
4
4
|
|
5
|
+
it "should raise exception if no env MODELS" do
|
6
|
+
lambda {
|
7
|
+
Seofy::TaskRunner.new
|
8
|
+
}.should raise_error
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "#update_all" do
|
6
12
|
it "should update all slugs" do
|
7
13
|
s1 = Store.create!("store 1")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Allen Wei
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-25 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -137,7 +137,6 @@ files:
|
|
137
137
|
- .gitignore
|
138
138
|
- .travis.yml
|
139
139
|
- Gemfile
|
140
|
-
- Gemfile.lock
|
141
140
|
- Guardfile
|
142
141
|
- README.md
|
143
142
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
seofy (0.0.2)
|
5
|
-
activerecord (~> 3.0.0)
|
6
|
-
activesupport (~> 3.0.0)
|
7
|
-
babosa (~> 0.3.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: http://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activemodel (3.0.7)
|
13
|
-
activesupport (= 3.0.7)
|
14
|
-
builder (~> 2.1.2)
|
15
|
-
i18n (~> 0.5.0)
|
16
|
-
activerecord (3.0.7)
|
17
|
-
activemodel (= 3.0.7)
|
18
|
-
activesupport (= 3.0.7)
|
19
|
-
arel (~> 2.0.2)
|
20
|
-
tzinfo (~> 0.3.23)
|
21
|
-
activesupport (3.0.7)
|
22
|
-
arel (2.0.10)
|
23
|
-
babosa (0.3.4)
|
24
|
-
builder (2.1.2)
|
25
|
-
diff-lcs (1.1.2)
|
26
|
-
growl (1.0.3)
|
27
|
-
guard (0.3.4)
|
28
|
-
thor (~> 0.14.6)
|
29
|
-
i18n (0.5.0)
|
30
|
-
rspec (2.5.0)
|
31
|
-
rspec-core (~> 2.5.0)
|
32
|
-
rspec-expectations (~> 2.5.0)
|
33
|
-
rspec-mocks (~> 2.5.0)
|
34
|
-
rspec-core (2.5.2)
|
35
|
-
rspec-expectations (2.5.0)
|
36
|
-
diff-lcs (~> 1.1.2)
|
37
|
-
rspec-mocks (2.5.0)
|
38
|
-
sqlite3 (1.3.3)
|
39
|
-
thor (0.14.6)
|
40
|
-
tzinfo (0.3.27)
|
41
|
-
|
42
|
-
PLATFORMS
|
43
|
-
ruby
|
44
|
-
|
45
|
-
DEPENDENCIES
|
46
|
-
growl
|
47
|
-
guard
|
48
|
-
rspec (~> 2.5.0)
|
49
|
-
seofy!
|
50
|
-
sqlite3
|