gastropod 0.1.0 → 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.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Simple library for generating slugs
4
4
 
5
+ ![Code Climate](https://codeclimate.com/github/vigetlabs/gastropod.png)
6
+
5
7
  ![gastropod](http://i.imgur.com/5UhkBfI.jpg)
6
8
 
7
9
  ## Install
@@ -43,7 +45,7 @@ Simple library for generating slugs
43
45
 
44
46
  ## Customisation
45
47
 
46
- If you aren't using ActiveRecord, you will likely want to override the class method 'slug_finder'
48
+ Override the instance method 'slug_finder' for custom scoping
47
49
 
48
50
  ## Contributing
49
51
 
data/lib/gastropod.rb CHANGED
@@ -14,10 +14,6 @@ module Gastropod
14
14
  @slug_source_attribute
15
15
  end
16
16
 
17
- def slug_finder
18
- instance_variable_defined?("@slug_finder") ? @slug_finder : default_slug_finder
19
- end
20
-
21
17
  def default_slug_finder
22
18
  lambda {|value| where(:slug => value) }
23
19
  end
@@ -30,6 +26,10 @@ module Gastropod
30
26
 
31
27
  private
32
28
 
29
+ def slug_finder
30
+ self.class.default_slug_finder
31
+ end
32
+
33
33
  def slug_source
34
34
  send self.class.slug_source_attribute
35
35
  end
@@ -46,10 +46,11 @@ module Gastropod
46
46
  possible_slug = slug_from_source
47
47
 
48
48
  index = 2
49
- while self.class.slug_finder.call(possible_slug).any?
49
+ while slug_finder.call(possible_slug).any?
50
50
  possible_slug = slug_from_source + "-#{index}"
51
- index+= 1
51
+ index += 1
52
52
  end
53
+
53
54
  possible_slug
54
55
  end
55
56
  end
@@ -1,3 +1,3 @@
1
1
  module Gastropod
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gastropod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-22 00:00:00.000000000 Z
13
+ date: 2013-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord