superslug 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -3
- data/lib/superslug.rb +1 -1
- data/lib/superslug/{superslug.rb → has_superslug.rb} +7 -2
- data/lib/superslug/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7d2fea76ae1289aec7b5d52e7d4f5c9f97c7c1b
|
4
|
+
data.tar.gz: a65edfb1ac37134fc14d5b1775231421ecd56a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283890959d97e56b37edceabc0b9681cac2cf28c87932330a28842cab58dc62f0122c7875d820946a75650d61a74e2bdbda502156a261a140bb154171f0cc2ba
|
7
|
+
data.tar.gz: a16787c3fe96a39f0bfc53c97bb1dd4b89de204fff909aeb0cf44d78e8733971ce0fefab89c61f98b7790e7762067c325dde427e904ef0aca31317794d5ebbae
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,9 +41,12 @@ while the destination (dest) column is *where the sluggified string is stored*.
|
|
41
41
|
|
42
42
|
### Options
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
* **separator**: Defines the character with which to fill blank spaces in the
|
45
|
+
string. For example, if it is a hyphen, then `Hello World` becomes `hello-
|
46
|
+
world`. See below for an example.
|
47
|
+
* **force_update**: If `true`, the destination column (slug) will always be set
|
48
|
+
when the record is saved. Otherwise, it doesn't change once it is first
|
49
|
+
created, unless manually set.
|
47
50
|
|
48
51
|
### Example
|
49
52
|
|
data/lib/superslug.rb
CHANGED
@@ -31,8 +31,13 @@ class << ActiveRecord::Base
|
|
31
31
|
# reference the separator option
|
32
32
|
separator = options[:separator].present? ? options[:separator] : '-'
|
33
33
|
# Set the slug column to the source column if it's
|
34
|
-
# empty
|
35
|
-
|
34
|
+
# empty, or always set it to the source if overridden
|
35
|
+
# in options
|
36
|
+
if options[:force_update] == true
|
37
|
+
superslug = self.send(source)
|
38
|
+
else
|
39
|
+
superslug = send(dest).blank? ? self.send(source) : self.send(dest)
|
40
|
+
end
|
36
41
|
# make lower case
|
37
42
|
superslug = superslug.downcase
|
38
43
|
# replace ampersands with 'and'
|
data/lib/superslug/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superslug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Warren Harrison
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
56
|
- lib/superslug.rb
|
57
|
-
- lib/superslug/
|
57
|
+
- lib/superslug/has_superslug.rb
|
58
58
|
- lib/superslug/version.rb
|
59
59
|
- superslug.gemspec
|
60
60
|
homepage: https://github.com/seancdavis/mark_it_zero
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.4.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Automate slug creation in your rails app
|