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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f0ee11116381b3e24a955f962973bda7198984b
4
- data.tar.gz: a10c2275d5ebc3475f2c95633e13595d1ecd34b3
3
+ metadata.gz: e7d2fea76ae1289aec7b5d52e7d4f5c9f97c7c1b
4
+ data.tar.gz: a65edfb1ac37134fc14d5b1775231421ecd56a52
5
5
  SHA512:
6
- metadata.gz: 5b25d0056ce67fa436c15a7813873a57767429f6329a2ce99564fa7625f4fe417084db1138a2753b6de42e74ffae9755302ec4957393f07edf24402f7023a25c
7
- data.tar.gz: dad171b682434a8d8ec046c27a474570ade5dbb8d449b901774c7575779111731b08373d83b89483c40ee85f753cb3e4dec550dcd25746f8e0d2161fe7db7636
6
+ metadata.gz: 283890959d97e56b37edceabc0b9681cac2cf28c87932330a28842cab58dc62f0122c7875d820946a75650d61a74e2bdbda502156a261a140bb154171f0cc2ba
7
+ data.tar.gz: a16787c3fe96a39f0bfc53c97bb1dd4b89de204fff909aeb0cf44d78e8733971ce0fefab89c61f98b7790e7762067c325dde427e904ef0aca31317794d5ebbae
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superslug (1.0.0)
4
+ superslug (1.2.0)
5
5
  rails (~> 4.1.0)
6
6
 
7
7
  GEM
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
- The only option is `separator`, which defines the character with which to fill
45
- blank spaces in the string. For example, if it is a hyphen, then `Hello World`
46
- becomes `hello-world`. See below for an example.
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
 
@@ -1,5 +1,5 @@
1
1
  require 'superslug/version'
2
- require 'superslug/superslug'
2
+ require 'superslug/has_superslug'
3
3
 
4
4
  module SuperSlug
5
5
  end
@@ -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
- superslug = send(dest).blank? ? self.send(source) : self.send(dest)
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'
@@ -1,3 +1,3 @@
1
1
  module SuperSlug
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.0
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-04-27 00:00:00.000000000 Z
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/superslug.rb
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.2.0
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