to_slug 1.0.6 → 1.0.7
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/.rvmrc +15 -0
- data/Gemfile.lock +2 -2
- data/lib/to_slug.rb +12 -0
- data/lib/to_slug/version.rb +1 -1
- data/spec/to_slug_spec.rb +5 -0
- data/to_slug.gemspec +1 -1
- metadata +7 -16
data/.rvmrc
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
rvm use 1.9.2@to_slug --create
|
2
|
+
if [ $(gem list bundler | grep bundler | wc -l) -lt 1 ]; then
|
3
|
+
gem install bundler --no-ri --no-rdoc
|
4
|
+
echo
|
5
|
+
echo "######################################"
|
6
|
+
echo "### Welcome to the to_slug gem ###"
|
7
|
+
echo "######################################"
|
8
|
+
echo
|
9
|
+
echo "To finish installation, run:"
|
10
|
+
echo
|
11
|
+
echo " bundle"
|
12
|
+
echo
|
13
|
+
echo "Run rake -T for help"
|
14
|
+
echo
|
15
|
+
fi
|
data/Gemfile.lock
CHANGED
data/lib/to_slug.rb
CHANGED
@@ -85,6 +85,18 @@ class String # This reopns the string class
|
|
85
85
|
regex = Regexp.new("[#{accent.join("|")}]")
|
86
86
|
string = string.gsub(regex, replacement)
|
87
87
|
end
|
88
|
+
|
89
|
+
# Strip any HTML decimal/hexadecimal entites
|
90
|
+
string = string.gsub(
|
91
|
+
/ # begin matching a string
|
92
|
+
& # an ampersand
|
93
|
+
[^ ] # Match any character except whitespace -- enables matching of hex or decimal
|
94
|
+
[0-9A-F] # a hex digit
|
95
|
+
{1,4} # 1 to 4 of them
|
96
|
+
; # a semicolon
|
97
|
+
/xi, # / = end matching; x = allow spaces/comments; i = ignore case; , = end argument
|
98
|
+
'' # replace matches with nothing (remove matches)
|
99
|
+
)
|
88
100
|
|
89
101
|
# Convert underscores and periods to dashs
|
90
102
|
string = string.gsub(/[_|.]/,"-")
|
data/lib/to_slug/version.rb
CHANGED
data/spec/to_slug_spec.rb
CHANGED
@@ -64,6 +64,11 @@ describe String, "to_slug" do
|
|
64
64
|
"I am a string class yo!".to_slug.should be_kind_of(String)
|
65
65
|
end
|
66
66
|
|
67
|
+
it "removes html entities" do
|
68
|
+
"I love my mom & dad; they made me cake".to_slug.should == "i-love-my-mom-dad-they-made-me-cake"
|
69
|
+
end
|
70
|
+
|
71
|
+
|
67
72
|
# Test all the accents
|
68
73
|
|
69
74
|
it "converts accents for the letter A" do
|
data/to_slug.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = "to_slug"
|
16
16
|
|
17
|
-
s.add_development_dependency "rspec"
|
17
|
+
s.add_development_dependency "rspec", "~> 2.4.0"
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 1.0.6
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.7
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Eric Boehs
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-10 00:00:00 -06:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -23,11 +19,9 @@ dependencies:
|
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
20
|
none: false
|
25
21
|
requirements:
|
26
|
-
- -
|
22
|
+
- - ~>
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
24
|
+
version: 2.4.0
|
31
25
|
type: :development
|
32
26
|
version_requirements: *id001
|
33
27
|
description: This gem makes URL friendly strings out of not so pretty strings.
|
@@ -41,6 +35,7 @@ extra_rdoc_files: []
|
|
41
35
|
|
42
36
|
files:
|
43
37
|
- .gitignore
|
38
|
+
- .rvmrc
|
44
39
|
- Gemfile
|
45
40
|
- Gemfile.lock
|
46
41
|
- Rakefile
|
@@ -62,21 +57,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
57
|
requirements:
|
63
58
|
- - ">="
|
64
59
|
- !ruby/object:Gem::Version
|
65
|
-
segments:
|
66
|
-
- 0
|
67
60
|
version: "0"
|
68
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
62
|
none: false
|
70
63
|
requirements:
|
71
64
|
- - ">="
|
72
65
|
- !ruby/object:Gem::Version
|
73
|
-
segments:
|
74
|
-
- 0
|
75
66
|
version: "0"
|
76
67
|
requirements: []
|
77
68
|
|
78
69
|
rubyforge_project: to_slug
|
79
|
-
rubygems_version: 1.
|
70
|
+
rubygems_version: 1.6.0
|
80
71
|
signing_key:
|
81
72
|
specification_version: 3
|
82
73
|
summary: Adds a to_slug method to ruby's String class
|