slugr 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 +4 -4
- data/README.md +10 -1
- data/lib/slugr.rb +2 -5
- data/lib/slugr/version.rb +1 -1
- data/lib/string.rb +7 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b2dcf43275ed11bb0a8fffa27605e2496a9584e675ff855045a864874c5380
|
4
|
+
data.tar.gz: fb08717b97008e42db5fe20208ef43294f98f70fbc04e7a60c4ff5de15de2e71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a20135210fd3dc0e75aa365c0e471613eb14f949662b14a8a771d4d8ec6e6a6462ebe20b696988138c4d32982c9310b357ce1072e6b1f97906e628192df749e
|
7
|
+
data.tar.gz: 59d2d6a50d0299214780d8a9b81a7e5033982b02da7d9c80cde9fd88fd46d876059dda411b304701dce256c5817abe73cf71e2aa90ea4c45e7327984b40db929
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Slugr
|
2
2
|
|
3
|
-
Slugr is a gem to automatically create ActiveRecord object slugs for use in permalinks based on a title, name, headline, or some other unique and descriptive string field.
|
3
|
+
Slugr is a gem to automatically create ActiveRecord object slugs for use in permalinks based on a title, name, headline, or some other unique and descriptive string field. It also provides a slug convenience method to the String class.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -97,6 +97,15 @@ Slugr will do its best to normalize diacritics (accented characters) to its non
|
|
97
97
|
artist = Artist.create(name: "Mötley Crüe") # slug: "motley-crue"
|
98
98
|
```
|
99
99
|
|
100
|
+
### String extension
|
101
|
+
|
102
|
+
Slugr extends the String class with a slug method.
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
> "Côte d'Ivoire".slug
|
106
|
+
=> "cote-divoire"
|
107
|
+
```
|
108
|
+
|
100
109
|
## Development
|
101
110
|
|
102
111
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/slugr.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
require "slugr/version"
|
2
|
+
require "string"
|
2
3
|
|
3
4
|
module Slugr
|
4
5
|
|
5
6
|
def self.included(base)
|
6
7
|
base.extend(ClassMethods)
|
7
8
|
|
8
|
-
def slug_for_string streng
|
9
|
-
return streng.gsub(/('|’)/, '').mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').parameterize.to_s
|
10
|
-
end
|
11
|
-
|
12
9
|
def set_slug
|
13
10
|
return if (streng = self.send(self.source).to_s).blank?
|
14
11
|
return if only_set_slug_if_empty && self.send(self.target).present?
|
15
|
-
self.send("#{self.target.to_s}=",
|
12
|
+
self.send("#{self.target.to_s}=", streng.to_s.slug)
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
data/lib/slugr/version.rb
CHANGED
data/lib/string.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Edlund
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- bin/setup
|
103
103
|
- lib/slugr.rb
|
104
104
|
- lib/slugr/version.rb
|
105
|
+
- lib/string.rb
|
105
106
|
- slugr.gemspec
|
106
107
|
homepage: https://github.com/arcticleo/slugr
|
107
108
|
licenses:
|
@@ -122,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
- !ruby/object:Gem::Version
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
|
-
|
126
|
-
rubygems_version: 2.7.6
|
126
|
+
rubygems_version: 3.0.3
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Smooth cruisin' permalink slugs for ActiveRecord objects.
|