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 CHANGED
@@ -1,3 +1,4 @@
1
1
  .rvmrc
2
2
  *.swp
3
3
  .rvmrc
4
+ Gemfile.lock
@@ -4,8 +4,8 @@ module Seofy
4
4
  def seofy(options={})
5
5
  init_seofy_config(options)
6
6
  include ::Seofy::ActiveRecord::InstanceMethods
7
- before_save :seofy_before_save
8
- after_save :seofy_after_save
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 seofy_before_save
39
- self.class.seofy_adapter.before_save(self)
38
+ def seofy_before_create
39
+ self.class.seofy_adapter.before_create(self)
40
40
  end
41
41
 
42
- def seofy_after_save
43
- self.class.seofy_adapter.after_save(self)
42
+ def seofy_after_create
43
+ self.class.seofy_adapter.after_create(self)
44
44
  end
45
45
 
46
46
  end
@@ -15,11 +15,11 @@ module Seofy
15
15
  raise "not implement"
16
16
  end
17
17
 
18
- def before_save(inst)
18
+ def before_create(inst)
19
19
  set_seofy_slug(inst)
20
20
  end
21
21
 
22
- def after_save(inst)
22
+ def after_create(inst)
23
23
  # do nothing
24
24
  end
25
25
  end
@@ -3,6 +3,7 @@ module Seofy
3
3
  attr_reader :klasses
4
4
  def initialize
5
5
  @klasses = ENV["MODELS"]
6
+ raise "Please provide MODELS" if @klasses.empty?
6
7
  end
7
8
 
8
9
  def each_model
@@ -1,3 +1,3 @@
1
1
  module Seofy
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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(:after_save)
15
- @klass.should_receive(:before_save)
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(:before_save => true)
75
- @klass.should_receive(:seofy_adapter).and_return double(:after_save => true)
76
- inst.seofy_before_save
77
- inst.seofy_after_save
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(:before_save) }
10
- it { should be_respond_to(:after_save) }
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.before_save("anything")
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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
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-24 00:00:00 +08:00
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
@@ -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