friendly_id_datamapper 3.1.0.beta1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +21 -0
- data/MIT-LICENSE +1 -1
- data/README.md +16 -10
- data/Rakefile +2 -2
- data/lib/friendly_id/datamapper_adapter/configuration.rb +9 -1
- data/lib/friendly_id/datamapper_adapter/slugged_model.rb +44 -49
- data/lib/friendly_id/datamapper_adapter/version.rb +2 -2
- data/test/test_helper.rb +9 -19
- metadata +51 -85
data/ChangeLog.md
CHANGED
@@ -3,6 +3,27 @@
|
|
3
3
|
* Table of Contents
|
4
4
|
{:toc}
|
5
5
|
|
6
|
+
## 3.2.0 (2011-08-08)
|
7
|
+
|
8
|
+
* Release offering compatibility with FriendlyId 3.2.x series.
|
9
|
+
* Release provides support for both DataMapper 1.0.x and 1.1.x series:
|
10
|
+
* Silence noisy deprecation warnings on DataMapper 1.1 (11a6dd5).
|
11
|
+
* Gemspec compatibility with RubyGems 1.7+:
|
12
|
+
* Fix Rake and RubyGems deprecation warnings (030df1f, 132e4ba).
|
13
|
+
* Optimize to use Rails extract_options method. Ignore Array keys when doing
|
14
|
+
lookup ([Josh Huckabee](http://github.com/jhuckabee), f11f206).
|
15
|
+
* Fix for orphaned slugs on deletion of a FriendlyId model instance, without
|
16
|
+
using dm-constraints (54d3a9c).
|
17
|
+
* Workaround an issue overriding DataMapper::Model#get on 1.9.2 that results in
|
18
|
+
"NotImplementedError - super from singleton method that is defined to multiple
|
19
|
+
classes is not supported" (0cd55ab).
|
20
|
+
|
21
|
+
Additionally this release establishes Continuous Integration, using the
|
22
|
+
excellent [Travis CI](http://travis-ci.org/) hosted CI service. This should lead
|
23
|
+
to more reliable future releases!
|
24
|
+
|
25
|
+
## 3.1.0 (not released)
|
26
|
+
|
6
27
|
## 3.1.0.beta1 (2010-09-13)
|
7
28
|
|
8
29
|
* Initial beta release.
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
# FriendlyId DataMapper Adapter
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[![Build Status](http://travis-ci.org/myabc/friendly_id_datamapper.png)](http://travis-ci.org/myabc/friendly_id_datamapper)
|
4
|
+
|
5
|
+
An adapter for [FriendlyId](http://norman.github.com/friendly_id) using
|
6
|
+
DataMapper.
|
5
7
|
|
6
8
|
## FriendlyId Features
|
7
9
|
|
8
10
|
It currently supports all of FriendlyId's features except:
|
9
11
|
|
10
12
|
* Rails Generator
|
11
|
-
* Support for multiple finders
|
12
13
|
|
13
|
-
Currently, only finds using `get`
|
14
|
+
Currently, only finds using `get` are supported.
|
14
15
|
|
15
16
|
@post = Post.get("this-is-a-title")
|
16
17
|
@post.friendly_id # this-is-a-title
|
17
18
|
|
18
19
|
## Compatibility
|
19
20
|
|
20
|
-
The FriendlyId DataMapper Adapter keeps in lock-step with major and
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
The FriendlyId DataMapper Adapter keeps in lock-step with major and minor
|
22
|
+
versions of the FriendlyId gem, i.e. `friendly_id_datamapper 3.2.x` is
|
23
|
+
compatible with `friendly_id 3.2.x series`. Patch and build versions are not
|
24
|
+
kept in lock-step.
|
24
25
|
|
25
26
|
## Usage
|
26
27
|
|
@@ -42,6 +43,12 @@ Patch and build versions are not kept in lock-step.
|
|
42
43
|
For more information on the available features, please see the
|
43
44
|
[FriendlyId Guide](http://norman.github.com/friendly_id/file.Guide.html).
|
44
45
|
|
46
|
+
## Known Issues
|
47
|
+
|
48
|
+
FriendlyId DataMapper Adapter is not yet compatible with Ruby 1.9.3, because of
|
49
|
+
an issue with a dependency `dm-do-adapter` and changes with the DateTime class,
|
50
|
+
after its reimplementation in C (namely, `DateTime#new!` no longer exists).
|
51
|
+
|
45
52
|
## Bugs
|
46
53
|
|
47
54
|
Please report them on the [Github issue tracker](http://github.com/myabc/friendly_id_datamapper/issues)
|
@@ -59,5 +66,4 @@ and add a test that reproduces the error you are experiencing.
|
|
59
66
|
|
60
67
|
## Credits
|
61
68
|
|
62
|
-
Copyright (c) 2010, released under the MIT license.
|
63
|
-
|
69
|
+
Copyright (c) 2010, 2011, released under the MIT license.
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "rake"
|
2
2
|
require "rake/testtask"
|
3
|
-
require
|
3
|
+
require 'rubygems/package_task'
|
4
4
|
require "rake/clean"
|
5
5
|
|
6
6
|
CLEAN << "pkg" << "doc" << "coverage" << ".yardoc"
|
7
7
|
|
8
|
-
|
8
|
+
Gem::PackageTask.new(eval(File.read("friendly_id_datamapper.gemspec"))) { |pkg| }
|
9
9
|
Rake::TestTask.new(:test) { |t| t.pattern = "test/*_test.rb" }
|
10
10
|
|
11
11
|
task :default => :test
|
@@ -57,11 +57,19 @@ module FriendlyId
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def associated_friendly_classes
|
60
|
-
|
60
|
+
configured_class_relationships.select { |relationship|
|
61
61
|
relationship.child_model.respond_to?(:friendly_id_config)
|
62
62
|
}.map(&:child_model)
|
63
63
|
end
|
64
64
|
|
65
|
+
def configured_class_relationships
|
66
|
+
unless (relationships = configured_class.relationships).is_a?(Hash)
|
67
|
+
relationships # DataMapper 1.1.x
|
68
|
+
else
|
69
|
+
relationships.values # DataMapper 1.0.x
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
65
73
|
end
|
66
74
|
end
|
67
75
|
end
|
@@ -41,63 +41,58 @@ module FriendlyId
|
|
41
41
|
|
42
42
|
after :update, :update_scope
|
43
43
|
after :update, :update_dependent_scopes
|
44
|
-
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
if options.respond_to?(:to_hash)
|
49
|
-
args.pop
|
50
|
-
options.to_hash.dup
|
51
|
-
else
|
52
|
-
{}
|
45
|
+
before(:destroy) do
|
46
|
+
slugs.destroy!
|
53
47
|
end
|
54
48
|
end
|
55
49
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
50
|
+
base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
51
|
+
def self.get(*key)
|
52
|
+
options = key.extract_options!
|
53
|
+
|
54
|
+
if key.size == 1
|
55
|
+
return super if key.first.is_a?(Array) || key.first.unfriendly_id?
|
56
|
+
name, sequence = key.first.to_s.parse_friendly_id
|
57
|
+
|
58
|
+
if !friendly_id_config.scope? && friendly_id_config.cache_column?
|
59
|
+
result = self.first(friendly_id_config.cache_column => key.first)
|
60
|
+
end
|
61
|
+
|
62
|
+
conditions = {
|
63
|
+
slugs.name => name,
|
64
|
+
slugs.sequence => sequence
|
65
|
+
}
|
66
|
+
conditions.merge!({
|
67
|
+
slugs.scope => (options[:scope].to_param if options[:scope] && options[:scope].respond_to?(:to_param))
|
68
|
+
}) if friendly_id_config.scope?
|
69
|
+
|
70
|
+
result ||= self.first(conditions)
|
71
|
+
return super unless result
|
72
|
+
result.friendly_id_status.name = name
|
73
|
+
result.friendly_id_status.sequence = sequence
|
74
|
+
result
|
75
|
+
else
|
76
|
+
super
|
65
77
|
end
|
66
|
-
|
67
|
-
conditions = {
|
68
|
-
slugs.name => name,
|
69
|
-
slugs.sequence => sequence
|
70
|
-
}
|
71
|
-
conditions.merge!({
|
72
|
-
slugs.scope => (options[:scope].to_param if options[:scope] && options[:scope].respond_to?(:to_param))
|
73
|
-
}) if friendly_id_config.scope?
|
74
|
-
|
75
|
-
result ||= self.first(conditions)
|
76
|
-
return super unless result
|
77
|
-
result.friendly_id_status.name = name
|
78
|
-
result.friendly_id_status.sequence = sequence
|
79
|
-
result
|
80
|
-
else
|
81
|
-
super
|
82
78
|
end
|
83
|
-
end
|
84
79
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
80
|
+
def self.get!(*key)
|
81
|
+
return super unless friendly_id_config.scope?
|
82
|
+
|
83
|
+
result = get(*key)
|
84
|
+
if result
|
85
|
+
result
|
86
|
+
else
|
87
|
+
options = key.extract_options!
|
88
|
+
scope = options[:scope]
|
89
|
+
message = "Could not find \#{self.name} with key \#{key.inspect}"
|
90
|
+
message << " and scope \#{scope.inspect}" if scope
|
91
|
+
message << ". Scope expected but none given." unless scope
|
92
|
+
raise(::DataMapper::ObjectNotFoundError, message)
|
93
|
+
end
|
98
94
|
end
|
99
|
-
|
100
|
-
|
95
|
+
RUBY
|
101
96
|
end
|
102
97
|
|
103
98
|
def slug
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
|
-
end
|
9
|
-
|
10
|
-
require "friendly_id"
|
11
|
-
require "friendly_id/test"
|
12
|
-
require "logger"
|
13
|
-
require "test/unit"
|
14
|
-
require "mocha"
|
1
|
+
$LOAD_PATH << './lib'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'mocha'
|
15
6
|
|
16
|
-
require '
|
7
|
+
require 'friendly_id'
|
8
|
+
require 'friendly_id/datamapper'
|
9
|
+
require 'friendly_id/test'
|
17
10
|
|
18
11
|
require 'dm-core'
|
19
12
|
require 'dm-validations'
|
@@ -26,12 +19,9 @@ require 'dm-active_model'
|
|
26
19
|
DataMapper::Logger.new('dm.log', :debug)
|
27
20
|
DataMapper.setup(:default, 'sqlite3::memory:')
|
28
21
|
|
29
|
-
$LOAD_PATH << './lib'
|
30
|
-
|
31
|
-
require 'friendly_id_datamapper'
|
32
22
|
require File.expand_path('../core', __FILE__)
|
33
23
|
require File.expand_path('../slugged', __FILE__)
|
34
|
-
|
35
24
|
require File.expand_path('../support/models', __FILE__)
|
25
|
+
|
36
26
|
DataMapper.finalize
|
37
27
|
DataMapper.auto_migrate!
|
metadata
CHANGED
@@ -1,95 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_id_datamapper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 3
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- beta1
|
10
|
-
version: 3.1.0.beta1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Norman Clarke
|
14
9
|
- Alex Coles
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
date: 2010-09-13 00:00:00 +02:00
|
13
|
+
date: 2011-08-08 00:00:00.000000000 +02:00
|
20
14
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
23
17
|
name: friendly_id
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &70132685181020 !ruby/object:Gem::Requirement
|
26
19
|
none: false
|
27
|
-
requirements:
|
20
|
+
requirements:
|
28
21
|
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
- 3
|
32
|
-
- 1
|
33
|
-
- 0
|
34
|
-
version: 3.1.0
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '3.2'
|
35
24
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: dm-core
|
39
25
|
prerelease: false
|
40
|
-
|
26
|
+
version_requirements: *70132685181020
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dm-core
|
29
|
+
requirement: &70132685180520 !ruby/object:Gem::Requirement
|
41
30
|
none: false
|
42
|
-
requirements:
|
31
|
+
requirements:
|
43
32
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
- 1
|
47
|
-
- 0
|
48
|
-
- 0
|
49
|
-
version: 1.0.0
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
50
35
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: dm-validations
|
54
36
|
prerelease: false
|
55
|
-
|
37
|
+
version_requirements: *70132685180520
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: dm-validations
|
40
|
+
requirement: &70132685180060 !ruby/object:Gem::Requirement
|
56
41
|
none: false
|
57
|
-
requirements:
|
42
|
+
requirements:
|
58
43
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
- 1
|
62
|
-
- 0
|
63
|
-
- 0
|
64
|
-
version: 1.0.0
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.0'
|
65
46
|
type: :runtime
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: dm-transactions
|
69
47
|
prerelease: false
|
70
|
-
|
48
|
+
version_requirements: *70132685180060
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: dm-transactions
|
51
|
+
requirement: &70132685179600 !ruby/object:Gem::Requirement
|
71
52
|
none: false
|
72
|
-
requirements:
|
53
|
+
requirements:
|
73
54
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
- 1
|
77
|
-
- 0
|
78
|
-
- 0
|
79
|
-
version: 1.0.0
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.0'
|
80
57
|
type: :runtime
|
81
|
-
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *70132685179600
|
82
60
|
description: An adapter for using DataMapper::Resource with FriendlyId.
|
83
|
-
email:
|
61
|
+
email:
|
84
62
|
- norman@njclarke.com
|
85
63
|
- alex@alexbcoles.com
|
86
64
|
executables: []
|
87
|
-
|
88
65
|
extensions: []
|
89
|
-
|
90
66
|
extra_rdoc_files: []
|
91
|
-
|
92
|
-
files:
|
67
|
+
files:
|
93
68
|
- lib/friendly_id/datamapper_adapter/configuration.rb
|
94
69
|
- lib/friendly_id/datamapper_adapter/simple_model.rb
|
95
70
|
- lib/friendly_id/datamapper_adapter/slug.rb
|
@@ -118,38 +93,29 @@ files:
|
|
118
93
|
has_rdoc: true
|
119
94
|
homepage: http://github.com/myabc/friendly_id_datamapper
|
120
95
|
licenses: []
|
121
|
-
|
122
96
|
post_install_message:
|
123
97
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
98
|
+
require_paths:
|
126
99
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
101
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
version: "0"
|
135
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
107
|
none: false
|
137
|
-
requirements:
|
138
|
-
- -
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
141
|
-
- 1
|
142
|
-
- 3
|
143
|
-
- 1
|
144
|
-
version: 1.3.1
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
145
112
|
requirements: []
|
146
|
-
|
147
|
-
|
148
|
-
rubygems_version: 1.3.7
|
113
|
+
rubyforge_project: ! '[none]'
|
114
|
+
rubygems_version: 1.6.2
|
149
115
|
signing_key:
|
150
116
|
specification_version: 3
|
151
117
|
summary: A DataMapper adapter for FriendlyId
|
152
|
-
test_files:
|
118
|
+
test_files:
|
153
119
|
- test/basic_slugged_model_test.rb
|
154
120
|
- test/cached_slug_test.rb
|
155
121
|
- test/custom_normalizer_test.rb
|