mm-sluggable 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/Rakefile +7 -11
  2. data/lib/mm-sluggable.rb +7 -5
  3. metadata +25 -9
data/Rakefile CHANGED
@@ -2,15 +2,9 @@ require "rubygems"
2
2
  require "rake/gempackagetask"
3
3
  require "rake/rdoctask"
4
4
 
5
- require "spec"
6
- require "spec/rake/spectask"
7
- Spec::Rake::SpecTask.new do |t|
8
- t.spec_opts = %w(--format specdoc --colour)
9
- t.libs = ["spec"]
10
- end
11
-
12
-
13
- task :default => ["spec"]
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
14
8
 
15
9
  # This builds the actual gem. For details of what all these options
16
10
  # mean, and other ones you can add, check the documentation here:
@@ -21,7 +15,7 @@ spec = Gem::Specification.new do |s|
21
15
 
22
16
  # Change these as appropriate
23
17
  s.name = "mm-sluggable"
24
- s.version = "0.1.1"
18
+ s.version = "0.2.0"
25
19
  s.summary = "Tiny plugin for MongoMapper to cache a slugged version of a field"
26
20
  s.author = "Richard Livsey"
27
21
  s.email = "richard@livsey.org"
@@ -39,6 +33,8 @@ spec = Gem::Specification.new do |s|
39
33
  # relevant versions
40
34
  # s.add_dependency("some_other_gem", "~> 0.1.0")
41
35
 
36
+ s.add_dependency("mongo_mapper", ">= 0.9.0")
37
+
42
38
  # If your tests use any gems, include them here
43
39
  s.add_development_dependency("rspec")
44
40
  end
@@ -48,7 +44,7 @@ end
48
44
  # be automatically building a gem for this project. If you're not
49
45
  # using GitHub, edit as appropriate.
50
46
  #
51
- # To publish your gem online, install the 'gemcutter' gem; Read more
47
+ # To publish your gem online, install the 'gemcutter' gem; Read more
52
48
  # about that here: http://gemcutter.org/pages/gem_docs
53
49
  Rake::GemPackageTask.new(spec) do |pkg|
54
50
  pkg.gem_spec = spec
data/lib/mm-sluggable.rb CHANGED
@@ -3,9 +3,7 @@ require 'mongo_mapper'
3
3
  module MongoMapper
4
4
  module Plugins
5
5
  module Sluggable
6
- def self.included(model)
7
- model.plugin self
8
- end
6
+ extend ActiveSupport::Concern
9
7
 
10
8
  module ClassMethods
11
9
  def sluggable(to_slug = :title, options = {})
@@ -17,12 +15,16 @@ module MongoMapper
17
15
  :index => true,
18
16
  :method => :parameterize,
19
17
  :scope => nil,
20
- :callback => :before_validation_on_create
18
+ :callback => [:before_validation, {:on => :create}]
21
19
  }.merge(options)
22
20
 
23
21
  key slug_options[:key], String, :index => slug_options[:index]
24
22
 
25
- self.send(slug_options[:callback], :set_slug)
23
+ if slug_options[:callback].is_a?(Array)
24
+ self.send(slug_options[:callback][0], :set_slug, slug_options[:callback][1])
25
+ else
26
+ self.send(slug_options[:callback], :set_slug)
27
+ end
26
28
  end
27
29
  end
28
30
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-sluggable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Livsey
@@ -15,13 +15,29 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 +00:00
18
+ date: 2011-03-09 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: mongo_mapper
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 59
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 0
34
+ version: 0.9.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
43
  - - ">="
@@ -31,7 +47,7 @@ dependencies:
31
47
  - 0
32
48
  version: "0"
33
49
  type: :development
34
- version_requirements: *id001
50
+ version_requirements: *id002
35
51
  description:
36
52
  email: richard@livsey.org
37
53
  executables: []
@@ -76,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
92
  requirements: []
77
93
 
78
94
  rubyforge_project:
79
- rubygems_version: 1.3.7
95
+ rubygems_version: 1.4.1
80
96
  signing_key:
81
97
  specification_version: 3
82
98
  summary: Tiny plugin for MongoMapper to cache a slugged version of a field