stringex_friendly_id 0.0.1
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/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/lib/stringex_friendly_id.rb +4 -0
- data/lib/stringex_friendly_id/patch.rb +8 -0
- data/lib/stringex_friendly_id/version.rb +3 -0
- data/stringex_friendly_id.gemspec +26 -0
- data/test/db.rb +13 -0
- data/test/slug_test.rb +17 -0
- data/test/test_helper.rb +4 -0
- metadata +149 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
stringex_friendly_id (0.0.1)
|
5
|
+
friendly_id
|
6
|
+
stringex
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.2.11)
|
12
|
+
activesupport (= 3.2.11)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
activerecord (3.2.11)
|
15
|
+
activemodel (= 3.2.11)
|
16
|
+
activesupport (= 3.2.11)
|
17
|
+
arel (~> 3.0.2)
|
18
|
+
tzinfo (~> 0.3.29)
|
19
|
+
activesupport (3.2.11)
|
20
|
+
i18n (~> 0.6)
|
21
|
+
multi_json (~> 1.0)
|
22
|
+
arel (3.0.2)
|
23
|
+
builder (3.0.4)
|
24
|
+
friendly_id (4.0.9)
|
25
|
+
i18n (0.6.1)
|
26
|
+
multi_json (1.5.0)
|
27
|
+
rake (10.0.3)
|
28
|
+
sqlite3 (1.3.7)
|
29
|
+
stringex (1.5.1)
|
30
|
+
tzinfo (0.3.35)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
activerecord (>= 3.0.0)
|
37
|
+
rake
|
38
|
+
sqlite3
|
39
|
+
stringex_friendly_id!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Lasse Bunk
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
StringexFriendlyId
|
2
|
+
==================
|
3
|
+
|
4
|
+
StringexFriendlyId combines [Stringex](https://github.com/rsl/stringex) with [FriendlyId](https://github.com/norman/friendly_id) giving you access to FriendlyId's slugging magic combined with Stringex's ingenious transliterations.
|
5
|
+
|
6
|
+
With FriendlyId standalone, you normally get URLs like:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
"it's nothing at all" => "it-s-nothing-at-all"
|
10
|
+
"rock & roll" => "rock-roll"
|
11
|
+
"$12 worth of Ruby power" => "12-worth-of-ruby-power"
|
12
|
+
"10% off if you act now" => "10-off-if-you-act-now"
|
13
|
+
"tell your readers 你好" => "tell-your-readers"
|
14
|
+
```
|
15
|
+
|
16
|
+
With StringexFriendlyId, you get URLs like these instead:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
"it's nothing at all" => "its-nothing-at-all"
|
20
|
+
"rock & roll" => "rock-and-roll"
|
21
|
+
"$12 worth of Ruby power" => "12-dollars-worth-of-ruby-power"
|
22
|
+
"10% off if you act now" => "10-percent-off-if-you-act-now"
|
23
|
+
"tell your readers 你好" => "tell-your-readers-ni-hao"
|
24
|
+
```
|
25
|
+
|
26
|
+
Just by including this gem and using FriendlyId [like you normally would](https://github.com/norman/friendly_id#rails-quickstart).
|
27
|
+
|
28
|
+
Installation
|
29
|
+
------------
|
30
|
+
|
31
|
+
In your *Gemfile*:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'stringex_friendly_id'
|
35
|
+
```
|
36
|
+
|
37
|
+
Then run:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ bundle install
|
41
|
+
```
|
42
|
+
|
43
|
+
You don't need to include FriendlyId or Stringex – they will be included by StringexFriendlyId.
|
44
|
+
|
45
|
+
Usage
|
46
|
+
-----
|
47
|
+
|
48
|
+
Just use FriendlyId [like you normally would](https://github.com/norman/friendly_id#rails-quickstart). Stringex's transliteration magic was enabled when you included the gem in your Gemfile.
|
49
|
+
|
50
|
+
Contributing
|
51
|
+
------------
|
52
|
+
|
53
|
+
1. Fork the repo
|
54
|
+
2. Create a feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a pull request
|
58
|
+
|
59
|
+
Copyright © 2013 Lasse Bunk, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stringex_friendly_id/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "stringex_friendly_id"
|
8
|
+
gem.version = StringexFriendlyId::VERSION
|
9
|
+
gem.authors = ["Lasse Bunk"]
|
10
|
+
gem.email = ["lassebunk@gmail.com"]
|
11
|
+
gem.description = %q{StringexFriendlyId is a gem for using Stringex's ingenious unicode transliterations with FriendlyId's slugging magic.}
|
12
|
+
gem.summary = %q{Stringex transliterations combined with FriendlyId slugging functionality.}
|
13
|
+
gem.homepage = "https://github.com/lassebunk/stringex_friendly_id"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.test_files = gem.files.grep(%r{^test/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "friendly_id"
|
21
|
+
gem.add_dependency "stringex"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rake"
|
24
|
+
gem.add_development_dependency "activerecord", ">= 3.0.0"
|
25
|
+
gem.add_development_dependency "sqlite3"
|
26
|
+
end
|
data/test/db.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "active_record"
|
2
|
+
|
3
|
+
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
|
4
|
+
|
5
|
+
ActiveRecord::Migration.create_table :articles do |t|
|
6
|
+
t.string :title
|
7
|
+
t.string :slug
|
8
|
+
end
|
9
|
+
|
10
|
+
class Article < ActiveRecord::Base
|
11
|
+
extend FriendlyId
|
12
|
+
friendly_id :title, :use => :slugged
|
13
|
+
end
|
data/test/slug_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SlugTest < Test::Unit::TestCase
|
5
|
+
def test_slug_generation
|
6
|
+
{
|
7
|
+
"it's nothing at all" => "its-nothing-at-all",
|
8
|
+
"rock & roll" => "rock-and-roll",
|
9
|
+
"$12 worth of Ruby power" => "12-dollars-worth-of-ruby-power",
|
10
|
+
"10% off if you act now" => "10-percent-off-if-you-act-now",
|
11
|
+
"tell your readers 你好" => "tell-your-readers-ni-hao"
|
12
|
+
}.each do |title, slug|
|
13
|
+
article = Article.create! :title => title
|
14
|
+
assert_equal slug, article.slug
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stringex_friendly_id
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lasse Bunk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: friendly_id
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: stringex
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: activerecord
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.0.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sqlite3
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: StringexFriendlyId is a gem for using Stringex's ingenious unicode transliterations
|
95
|
+
with FriendlyId's slugging magic.
|
96
|
+
email:
|
97
|
+
- lassebunk@gmail.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- .travis.yml
|
103
|
+
- Gemfile
|
104
|
+
- Gemfile.lock
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/stringex_friendly_id.rb
|
109
|
+
- lib/stringex_friendly_id/patch.rb
|
110
|
+
- lib/stringex_friendly_id/version.rb
|
111
|
+
- stringex_friendly_id.gemspec
|
112
|
+
- test/db.rb
|
113
|
+
- test/slug_test.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
homepage: https://github.com/lassebunk/stringex_friendly_id
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
hash: 2800358047302499544
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
hash: 2800358047302499544
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.8.25
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Stringex transliterations combined with FriendlyId slugging functionality.
|
146
|
+
test_files:
|
147
|
+
- test/db.rb
|
148
|
+
- test/slug_test.rb
|
149
|
+
- test/test_helper.rb
|