pseudocephalopod 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/README.md +6 -0
- data/Rakefile +1 -0
- data/lib/pseudocephalopod/caching.rb +4 -12
- data/lib/pseudocephalopod/slug_history.rb +5 -8
- data/lib/pseudocephalopod/version.rb +2 -2
- data/lib/pseudocephalopod.rb +16 -9
- data/pseudocephalopod.gemspec +7 -4
- metadata +44 -14
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source :gemcutter
|
2
2
|
|
3
3
|
# Setup gems
|
4
|
-
gem "activerecord", "= 3.0.0.
|
4
|
+
gem "activerecord", "= 3.0.0.beta4"
|
5
5
|
gem "reversible_data"
|
6
6
|
gem "uuid"
|
7
7
|
gem "sqlite3-ruby", :require => "sqlite3"
|
@@ -15,4 +15,4 @@ gem "flay", :require => nil
|
|
15
15
|
gem "flog", :require => nil
|
16
16
|
gem "rake", :require => nil
|
17
17
|
gem "Saikuro", :require => nil
|
18
|
-
gem "jeweler", :require => nil
|
18
|
+
gem "jeweler", :require => nil
|
data/README.md
CHANGED
@@ -104,6 +104,12 @@ To run tests, simply do the following:
|
|
104
104
|
|
105
105
|
And it's ready!
|
106
106
|
|
107
|
+
## Contributors ##
|
108
|
+
|
109
|
+
Thanks to the following who contributed functionality / bug fixes:
|
110
|
+
|
111
|
+
* [Matt Pruitt](http://github.com/guitsaru)
|
112
|
+
|
107
113
|
## Note on Patches/Pull Requests ##
|
108
114
|
|
109
115
|
* Fork the project.
|
data/Rakefile
CHANGED
@@ -18,6 +18,7 @@ begin
|
|
18
18
|
gem.homepage = "http://github.com/Sutto/pseudocephalopod"
|
19
19
|
gem.authors = ["Darcy Laycock"]
|
20
20
|
gem.add_dependency "activerecord", ">= 3.0.0.beta2"
|
21
|
+
gem.add_dependency "activesupport", ">= 3.0.0.beta2"
|
21
22
|
gem.add_dependency "uuid"
|
22
23
|
gem.add_development_dependency "shoulda", ">= 0"
|
23
24
|
gem.add_development_dependency "reversible_data"
|
@@ -5,22 +5,14 @@ module Pseudocephalopod
|
|
5
5
|
# Usually included by passing the :cache option as true (by default it is
|
6
6
|
# true, you can disable by passing :cache as false or nil).
|
7
7
|
module Caching
|
8
|
+
extend ActiveSupport::Concern
|
8
9
|
|
9
|
-
|
10
|
-
attr_accessor :cache_expires_in
|
11
|
-
end
|
12
|
-
|
10
|
+
mattr_accessor :cache_expires_in
|
13
11
|
# Cache for 10 minutes by default.
|
14
12
|
self.cache_expires_in = 600
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
parent.class_eval do
|
20
|
-
include InstanceMethods
|
21
|
-
extend ClassMethods
|
22
|
-
after_save :globally_cache_slug
|
23
|
-
end
|
14
|
+
included do
|
15
|
+
after_save :globally_cache_slug
|
24
16
|
end
|
25
17
|
|
26
18
|
module InstanceMethods
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Pseudocephalopod
|
2
2
|
module SlugHistory
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
after_save :record_slug_changes
|
9
|
-
after_destroy :remove_slug_history!
|
10
|
-
end
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
after_save :record_slug_changes
|
7
|
+
after_destroy :remove_slug_history!
|
11
8
|
end
|
12
9
|
|
13
10
|
module InstanceMethods
|
data/lib/pseudocephalopod.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_record'
|
1
3
|
require 'uuid'
|
2
4
|
|
5
|
+
require 'active_support/dependencies/autoload'
|
6
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
7
|
+
require 'active_support/concern'
|
8
|
+
|
3
9
|
module Pseudocephalopod
|
10
|
+
extend ActiveSupport::Autoload
|
11
|
+
|
12
|
+
mattr_accessor :cache_key_prefix, :cache
|
4
13
|
|
5
14
|
class << self
|
6
15
|
|
7
|
-
attr_accessor :cache_key_prefix, :cache
|
8
|
-
|
9
16
|
def with_counter(prefix, counter = 0)
|
10
17
|
counter < 1 ? prefix : "#{prefix}--#{counter}"
|
11
18
|
end
|
@@ -15,7 +22,7 @@ module Pseudocephalopod
|
|
15
22
|
slug = self.with_counter(prefix, counter)
|
16
23
|
while scope.with_cached_slug(slug).exists?
|
17
24
|
counter += 1
|
18
|
-
slug
|
25
|
+
slug = self.with_counter(prefix, counter)
|
19
26
|
end
|
20
27
|
slug
|
21
28
|
end
|
@@ -58,12 +65,12 @@ module Pseudocephalopod
|
|
58
65
|
|
59
66
|
self.cache_key_prefix ||= "cached-slugs"
|
60
67
|
|
61
|
-
autoload :Caching
|
62
|
-
autoload :Scopes
|
63
|
-
autoload :Finders
|
64
|
-
autoload :SlugHistory
|
65
|
-
autoload :Slug
|
66
|
-
autoload :MemoryCache
|
68
|
+
autoload :Caching
|
69
|
+
autoload :Scopes
|
70
|
+
autoload :Finders
|
71
|
+
autoload :SlugHistory
|
72
|
+
autoload :Slug
|
73
|
+
autoload :MemoryCache
|
67
74
|
|
68
75
|
require 'pseudocephalopod/active_record_methods'
|
69
76
|
ActiveRecord::Base.extend Pseudocephalopod::ActiveRecordMethods
|
data/pseudocephalopod.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pseudocephalopod}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Darcy Laycock"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-11}
|
13
13
|
s.description = %q{Super simple slugs for ActiveRecord 3.0 and higher, with support for slug history}
|
14
14
|
s.email = %q{sutto@sutto.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.homepage = %q{http://github.com/Sutto/pseudocephalopod}
|
50
50
|
s.rdoc_options = ["--charset=UTF-8"]
|
51
51
|
s.require_paths = ["lib"]
|
52
|
-
s.rubygems_version = %q{1.3.
|
52
|
+
s.rubygems_version = %q{1.3.7}
|
53
53
|
s.summary = %q{Super simple slugs for ActiveRecord 3.0 and higher, with support for slug history}
|
54
54
|
s.test_files = [
|
55
55
|
"test/caching_test.rb",
|
@@ -64,19 +64,22 @@ Gem::Specification.new do |s|
|
|
64
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
65
|
s.specification_version = 3
|
66
66
|
|
67
|
-
if Gem::Version.new(Gem::
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
68
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0.beta2"])
|
69
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0.beta2"])
|
69
70
|
s.add_runtime_dependency(%q<uuid>, [">= 0"])
|
70
71
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
71
72
|
s.add_development_dependency(%q<reversible_data>, [">= 0"])
|
72
73
|
else
|
73
74
|
s.add_dependency(%q<activerecord>, [">= 3.0.0.beta2"])
|
75
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0.beta2"])
|
74
76
|
s.add_dependency(%q<uuid>, [">= 0"])
|
75
77
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
76
78
|
s.add_dependency(%q<reversible_data>, [">= 0"])
|
77
79
|
end
|
78
80
|
else
|
79
81
|
s.add_dependency(%q<activerecord>, [">= 3.0.0.beta2"])
|
82
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0.beta2"])
|
80
83
|
s.add_dependency(%q<uuid>, [">= 0"])
|
81
84
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
82
85
|
s.add_dependency(%q<reversible_data>, [">= 0"])
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudocephalopod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Darcy Laycock
|
@@ -14,60 +15,85 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-06-11 00:00:00 +08:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
+
prerelease: false
|
22
23
|
type: :runtime
|
24
|
+
name: activerecord
|
23
25
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
24
27
|
requirements:
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: -1848230022
|
27
31
|
segments:
|
28
32
|
- 3
|
29
33
|
- 0
|
30
34
|
- 0
|
31
35
|
- beta2
|
32
36
|
version: 3.0.0.beta2
|
33
|
-
prerelease: false
|
34
37
|
requirement: *id001
|
35
38
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
39
|
+
prerelease: false
|
37
40
|
type: :runtime
|
41
|
+
name: activesupport
|
38
42
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
39
44
|
requirements:
|
40
45
|
- - ">="
|
41
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: -1848230022
|
42
48
|
segments:
|
49
|
+
- 3
|
43
50
|
- 0
|
44
|
-
|
45
|
-
|
51
|
+
- 0
|
52
|
+
- beta2
|
53
|
+
version: 3.0.0.beta2
|
46
54
|
requirement: *id002
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
|
-
|
49
|
-
type: :
|
56
|
+
prerelease: false
|
57
|
+
type: :runtime
|
58
|
+
name: uuid
|
50
59
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
51
61
|
requirements:
|
52
62
|
- - ">="
|
53
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
54
65
|
segments:
|
55
66
|
- 0
|
56
67
|
version: "0"
|
57
|
-
prerelease: false
|
58
68
|
requirement: *id003
|
59
69
|
- !ruby/object:Gem::Dependency
|
60
|
-
|
70
|
+
prerelease: false
|
61
71
|
type: :development
|
72
|
+
name: shoulda
|
62
73
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
63
75
|
requirements:
|
64
76
|
- - ">="
|
65
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
66
79
|
segments:
|
67
80
|
- 0
|
68
81
|
version: "0"
|
69
|
-
prerelease: false
|
70
82
|
requirement: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
type: :development
|
86
|
+
name: reversible_data
|
87
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirement: *id005
|
71
97
|
description: Super simple slugs for ActiveRecord 3.0 and higher, with support for slug history
|
72
98
|
email: sutto@sutto.net
|
73
99
|
executables: []
|
@@ -116,23 +142,27 @@ rdoc_options:
|
|
116
142
|
require_paths:
|
117
143
|
- lib
|
118
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
119
146
|
requirements:
|
120
147
|
- - ">="
|
121
148
|
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
122
150
|
segments:
|
123
151
|
- 0
|
124
152
|
version: "0"
|
125
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
126
155
|
requirements:
|
127
156
|
- - ">="
|
128
157
|
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
129
159
|
segments:
|
130
160
|
- 0
|
131
161
|
version: "0"
|
132
162
|
requirements: []
|
133
163
|
|
134
164
|
rubyforge_project:
|
135
|
-
rubygems_version: 1.3.
|
165
|
+
rubygems_version: 1.3.7
|
136
166
|
signing_key:
|
137
167
|
specification_version: 3
|
138
168
|
summary: Super simple slugs for ActiveRecord 3.0 and higher, with support for slug history
|