effective_slugs 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dfb5564879f29db8bf15459160f2e29a4307845
4
- data.tar.gz: 4a995a792f311a2aa13675bcf71a364f21433272
3
+ metadata.gz: ca6f1bdd031ce20260513fdf6929663c8cbdedcf
4
+ data.tar.gz: cc5d68efab2b88fd6eabc3152a82b67da3398d3f
5
5
  SHA512:
6
- metadata.gz: a263b6aa15b529a7da2dbe4cc69c3e17b4f8f1113efd4bb34cced03322d717b40b809afc2721bdb7f4a2fc40f8461aefbe2458b53adda7dc9012fca92e2d11a2
7
- data.tar.gz: 29f798fe97ebcb6ccbff2a05eab7fb75f3059465abf96e63a7b741e7525812639b20699c7661cfb4d86b4820d92a8a3b200bdb774d6d10cb68370fbfd48fc96d
6
+ metadata.gz: b07e70814443dfc738592c659db45f70f94d34e8d4b9a40daab2af59b34550ee02217f6e631fb2f817d6f5124e2d7bb2103b57e1fbdec43829ed3c17cc165d9d
7
+ data.tar.gz: d79e02248e6300db36d7b9807c21e714a835fd8543588d93694c4957445646dd4afb75fd82fa4c5203e0b2b4628b79071dda53f1b20485b891dfb0680fc1565d
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Effective Slugs
2
2
 
3
- Automatically generate URL-appropriate slugs when saving a record. Rails 3 only.
3
+ Automatically generate URL-appropriate slugs when saving a record.
4
4
 
5
- Also overrides ActiveRecord .find() methods to accept the slug, or an id as the parameter.
5
+ Also overrides ActiveRecord's .find() method to accept the slug, or an id as the parameter.
6
6
 
7
- Rails >= 3.2.x, Ruby >= 1.9.x. Has not been tested/developed for Rails4.
7
+ Rails 3.2.x and Rails 4.
8
8
 
9
9
 
10
10
  ## Getting Started
@@ -72,7 +72,7 @@ def should_generate_new_slug?
72
72
  end
73
73
  ```
74
74
 
75
- The slug is generated based on the slug_source instance method, which can also be overridden by adding the following instance method to the model:
75
+ The slug is generated based on an object's `slug_source` method, which can also be overridden by adding the following to the model:
76
76
 
77
77
  ```ruby
78
78
  def slug_source
@@ -67,7 +67,6 @@ module ActsAsSluggable
67
67
  else
68
68
  validates_uniqueness_of :slug
69
69
  end
70
-
71
70
  end
72
71
 
73
72
  def set_slug
@@ -101,8 +100,25 @@ module ActsAsSluggable
101
100
  end
102
101
 
103
102
  def to_param
104
- (slug.present? rescue false) ? "#{id}-#{slug_was}" : super
103
+ (slug.present? rescue false) ? slug_was : super
104
+ end
105
+
106
+ module ClassMethods
107
+ def relation
108
+ super.tap { |relation| relation.extend(FinderMethods) }
109
+ end
110
+ end
111
+
112
+ module FinderMethods
113
+ def find(*args)
114
+ args.first.to_i > 0 ? super : find_by_slug(args)
115
+ end
116
+
117
+ def exists?(*args)
118
+ args.first.to_i > 0 ? super : (find_by_slug(args).present? rescue false)
119
+ end
105
120
  end
106
121
 
122
+
107
123
  end
108
124
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveSlugs
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -1,3 +1,3 @@
1
1
  EffectiveSlugs.setup do |config|
2
- config.excluded_slugs = %w(contact-us calendar cart destroy_cart moneris_postback search sitemap robots)
2
+ config.excluded_slugs = %w(home cart search sitemap robots)
3
3
  end
metadata CHANGED
@@ -1,31 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_slugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
27
- description: Automatically generate URL-appropriate slugs when saving a record. Rails
28
- 3 only.
26
+ version: 3.2.0
27
+ description: Automatically generate URL-appropriate slugs when saving a record.
29
28
  email:
30
29
  - info@codeandeffect.com
31
30
  executables: []
@@ -97,8 +96,7 @@ rubyforge_project:
97
96
  rubygems_version: 2.4.3
98
97
  signing_key:
99
98
  specification_version: 4
100
- summary: Automatically generate URL-appropriate slugs when saving a record. Rails
101
- 3 only.
99
+ summary: Automatically generate URL-appropriate slugs when saving a record.
102
100
  test_files:
103
101
  - spec/dummy/app/assets/javascripts/application.js
104
102
  - spec/dummy/app/assets/stylesheets/application.css