mm-sluggable 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +18 -9
  3. data/lib/mm-sluggable.rb +13 -2
  4. metadata +11 -17
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed0d240b072ab3d040653f0fc6c8c70117782b31
4
+ data.tar.gz: f66703ddfbb1154cb53b30b924e27b4025402774
5
+ SHA512:
6
+ metadata.gz: 82458ac3a347d0fdc5eae9b621590df6516e421347741acbdad6b173425b952356d4470efae4b468595d1cb2c149b3c67365ccefe01848fac4a5fe0f53d6aef3
7
+ data.tar.gz: f59cad27dd54fb69ae658f7fcbb724fa5b3d2119f6336d3c765fbf076cd84095497206c1511d9815de6b0da201b1972925c7a0927ed06b5765a066760530e40a
data/Rakefile CHANGED
@@ -1,10 +1,14 @@
1
1
  require "rubygems"
2
- require "rake/gempackagetask"
3
- require "rake/rdoctask"
2
+ require "rubygems/package_task"
3
+ require "rdoc/task"
4
4
 
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec)
7
- task :default => :spec
5
+ require "rspec"
6
+ require "rspec/core/rake_task"
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.rspec_opts = %w(--format documentation --colour)
9
+ end
10
+
11
+ task :default => ["spec"]
8
12
 
9
13
  # This builds the actual gem. For details of what all these options
10
14
  # mean, and other ones you can add, check the documentation here:
@@ -15,7 +19,7 @@ spec = Gem::Specification.new do |s|
15
19
 
16
20
  # Change these as appropriate
17
21
  s.name = "mm-sluggable"
18
- s.version = "0.3.0"
22
+ s.version = "0.3.1"
19
23
  s.summary = "Tiny plugin for MongoMapper to cache a slugged version of a field"
20
24
  s.author = "Richard Livsey"
21
25
  s.email = "richard@livsey.org"
@@ -46,7 +50,7 @@ end
46
50
  #
47
51
  # To publish your gem online, install the 'gemcutter' gem; Read more
48
52
  # about that here: http://gemcutter.org/pages/gem_docs
49
- Rake::GemPackageTask.new(spec) do |pkg|
53
+ Gem::PackageTask.new(spec) do |pkg|
50
54
  pkg.gem_spec = spec
51
55
  end
52
56
 
@@ -56,10 +60,15 @@ task :gemspec do
56
60
  File.open(file, "w") {|f| f << spec.to_ruby }
57
61
  end
58
62
 
63
+ # If you don't want to generate the .gemspec file, just remove this line. Reasons
64
+ # why you might want to generate a gemspec:
65
+ # - using bundler with a git source
66
+ # - building the gem without rake (i.e. gem build blah.gemspec)
67
+ # - maybe others?
59
68
  task :package => :gemspec
60
69
 
61
70
  # Generate documentation
62
- Rake::RDocTask.new do |rd|
71
+ RDoc::Task.new do |rd|
63
72
  rd.main = "README.rdoc"
64
73
  rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
65
74
  rd.rdoc_dir = "rdoc"
@@ -68,4 +77,4 @@ end
68
77
  desc 'Clear out RDoc and generated packages'
69
78
  task :clean => [:clobber_rdoc, :clobber_package] do
70
79
  rm "#{spec.name}.gemspec"
71
- end
80
+ end
data/lib/mm-sluggable.rb CHANGED
@@ -30,7 +30,17 @@ module MongoMapper
30
30
  end
31
31
 
32
32
  def set_slug
33
- options = self.class.slug_options
33
+ klass = self.class
34
+ while klass.respond_to?(:single_collection_parent)
35
+ superclass = klass.single_collection_parent
36
+ if superclass && superclass.respond_to?(:slug_options)
37
+ klass = superclass
38
+ else
39
+ break
40
+ end
41
+ end
42
+
43
+ options = klass.slug_options
34
44
  return unless self.send(options[:key]).blank?
35
45
 
36
46
  to_slug = self[options[:to_slug]]
@@ -44,7 +54,8 @@ module MongoMapper
44
54
 
45
55
  # todo - remove the loop and use regex instead so we can do it in one query
46
56
  i = options[:start]
47
- while self.class.first(conds)
57
+
58
+ while klass.first(conds)
48
59
  conds[options[:key]] = the_slug = "#{raw_slug}-#{i}"
49
60
  i += 1
50
61
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-sluggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Richard Livsey
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-05-18 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mongo_mapper
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.9.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description:
@@ -56,6 +51,7 @@ files:
56
51
  - lib/mm-sluggable.rb
57
52
  homepage: http://github.com/rlivsey/mm-sluggable
58
53
  licenses: []
54
+ metadata: {}
59
55
  post_install_message:
60
56
  rdoc_options:
61
57
  - --main
@@ -63,21 +59,19 @@ rdoc_options:
63
59
  require_paths:
64
60
  - lib
65
61
  required_ruby_version: !ruby/object:Gem::Requirement
66
- none: false
67
62
  requirements:
68
- - - ! '>='
63
+ - - '>='
69
64
  - !ruby/object:Gem::Version
70
65
  version: '0'
71
66
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
67
  requirements:
74
- - - ! '>='
68
+ - - '>='
75
69
  - !ruby/object:Gem::Version
76
70
  version: '0'
77
71
  requirements: []
78
72
  rubyforge_project:
79
- rubygems_version: 1.8.23
73
+ rubygems_version: 2.1.11
80
74
  signing_key:
81
- specification_version: 3
75
+ specification_version: 4
82
76
  summary: Tiny plugin for MongoMapper to cache a slugged version of a field
83
77
  test_files: []