finishing_moves 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +9 -5
- data/Vagrantfile +4 -0
- data/finishing_moves.gemspec +1 -0
- data/lib/finishing_moves/object.rb +4 -0
- data/lib/finishing_moves/string.rb +17 -0
- data/lib/finishing_moves/version.rb +1 -1
- data/provision.sh +7 -16
- data/spec/spec_helper.rb +4 -0
- data/spec/string_spec.rb +26 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d56bf8257e6c87e6b608472cb3aa7aaafe5aa921
|
4
|
+
data.tar.gz: e0f8790fb33d1b2b613429a133cb77725a90d011
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f406d28dbe0a08825c828aa3c856a7e7fd3910fc20cbda106babb058e4fff488feec211d0dceb06044f7e72978203034219c8b13a64db583d7122536ddae8aae
|
7
|
+
data.tar.gz: eb8715f761ddb6a4b7871591ab8e5118901736f1b6371305bfaccca7be01f972b892cf4610444c8097ca4e282b8bb9ba047a81fd073eb7df9efbc9c534bfd3e5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Finishing Moves
|
2
|
-
[](
|
3
|
-
[](https://travis-ci.org/forgecrafted/finishing_moves
|
2
|
+
[](https://rubygems.org/gems/finishing_moves)
|
3
|
+
[](https://travis-ci.org/forgecrafted/finishing_moves)
|
4
|
+
[](https://coveralls.io/r/forgecrafted/finishing_moves?branch=master)
|
4
5
|
[](http://www.forgecrafted.com)
|
5
6
|
|
6
7
|
Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself in a situation where an **elaborate-yet-precise** coding maneuver wins the day. Finishing Moves is a collection of methods designed to assist in those just-typical-enough-to-be-annoying scenarios.
|
@@ -25,6 +26,7 @@ gem install 'finishing_moves'
|
|
25
26
|
Tested against **`2.0.0` and above**. Probably works in `1.9.3`.
|
26
27
|
|
27
28
|
## List of Methods
|
29
|
+
###### Complete documentation in the [GitHub wiki](https://github.com/forgecrafted/finishing_moves/wiki)
|
28
30
|
|
29
31
|
**Not sure if this gem is for you?** Check out the methods marked with a :boom: first.
|
30
32
|
|
@@ -37,7 +39,7 @@ Tested against **`2.0.0` and above**. Probably works in `1.9.3`.
|
|
37
39
|
- [`Hash#delete_each`](https://github.com/forgecrafted/finishing_moves/wiki/Hash#hashdelete_each)
|
38
40
|
- [`Hash#delete_each!`](https://github.com/forgecrafted/finishing_moves/wiki/Hash#hashdelete_each-1)
|
39
41
|
- [`Integer#length`](https://github.com/forgecrafted/finishing_moves/wiki/Numeric#integerlength)
|
40
|
-
- [`Kernel#nil_chain`](https://github.com/forgecrafted/finishing_moves/wiki/Kernel#kernelnil_chain) :boom:
|
42
|
+
- [`Kernel#nil_chain`](https://github.com/forgecrafted/finishing_moves/wiki/Kernel#kernelnil_chain) :boom::boom:
|
41
43
|
- [`Kernel#cascade`](https://github.com/forgecrafted/finishing_moves/wiki/Kernel#kernelcascade)
|
42
44
|
- [`Kernel#class_exists?`](https://github.com/forgecrafted/finishing_moves/wiki/Kernel#kernelclass_exists)
|
43
45
|
- [`Numeric#add_percent`](https://github.com/forgecrafted/finishing_moves/wiki/Numeric#numericadd_percent)
|
@@ -51,9 +53,11 @@ Tested against **`2.0.0` and above**. Probably works in `1.9.3`.
|
|
51
53
|
- [`String#nl2br`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnl2br)
|
52
54
|
- [`String#remove_whitespace`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringremove_whitespace)
|
53
55
|
- [`String#strip_all`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringstrip_all) :boom:
|
54
|
-
- [Boolean Typecasting](https://github.com/forgecrafted/finishing_moves/wiki/Boolean-Typecasting)
|
55
56
|
|
56
|
-
|
57
|
+
*Multi-class logic enhancements*
|
58
|
+
|
59
|
+
- [Fiscal Calendar Calculations](https://github.com/forgecrafted/finishing_moves/wiki/Fiscal-Calendar-Calculations) :boom:
|
60
|
+
- [Boolean Typecasting](https://github.com/forgecrafted/finishing_moves/wiki/Boolean-Typecasting)
|
57
61
|
|
58
62
|
## Development approach
|
59
63
|
|
data/Vagrantfile
CHANGED
@@ -9,6 +9,10 @@ Vagrant.configure("2") do |config|
|
|
9
9
|
config.vm.box = "trusty32"
|
10
10
|
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box"
|
11
11
|
|
12
|
+
# Use the normal insecure key
|
13
|
+
# https://github.com/mitchellh/vagrant/issues/2608
|
14
|
+
config.ssh.insert_key = false
|
15
|
+
|
12
16
|
config.vm.provider :virtualbox do |vb|
|
13
17
|
vb.customize ["modifyvm", :id,
|
14
18
|
# Basics.
|
data/finishing_moves.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency 'priscilla', '>= 0'
|
25
25
|
s.add_development_dependency 'pry-byebug', '>= 0'
|
26
26
|
s.add_development_dependency 'fuubar', '>= 0'
|
27
|
+
s.add_development_dependency 'coveralls', '>= 0.8.0'
|
27
28
|
|
28
29
|
s.required_ruby_version = '>= 2.0.0'
|
29
30
|
|
@@ -39,6 +39,14 @@ class String
|
|
39
39
|
result
|
40
40
|
end
|
41
41
|
|
42
|
+
def slugify
|
43
|
+
_slugify_gsub(self.keyify)
|
44
|
+
end
|
45
|
+
|
46
|
+
def slugify!
|
47
|
+
_slugify_gsub(self.keyify!)
|
48
|
+
end
|
49
|
+
|
42
50
|
def strip_all(chars = nil)
|
43
51
|
expr = _strip_all_prep(chars)
|
44
52
|
gsub Regexp.union(_lstrip_all_regex(expr), _rstrip_all_regex(expr)), ''
|
@@ -114,6 +122,11 @@ class String
|
|
114
122
|
expr << ' '
|
115
123
|
end
|
116
124
|
|
125
|
+
def _slugify_gsub(str)
|
126
|
+
return nil if str.nil?
|
127
|
+
str.to_s.gsub('_', '-')
|
128
|
+
end
|
129
|
+
|
117
130
|
end
|
118
131
|
|
119
132
|
# We aren't reopening Symbol class for anything else yet, so we'll just define
|
@@ -124,4 +137,8 @@ class Symbol
|
|
124
137
|
to_s.keyify
|
125
138
|
end
|
126
139
|
|
140
|
+
def slugify
|
141
|
+
to_s.slugify
|
142
|
+
end
|
143
|
+
|
127
144
|
end
|
data/provision.sh
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Shell user settings.
|
4
4
|
USER_NAME=vagrant
|
5
5
|
USER_HOME=/home/$USER_NAME
|
6
|
-
DEFAULT_RUBY='2.2.
|
6
|
+
DEFAULT_RUBY='2.2.2'
|
7
7
|
|
8
8
|
###############################################################################
|
9
9
|
# Functions
|
@@ -14,12 +14,6 @@ as_user() {
|
|
14
14
|
su -l $USER_NAME -c "$*"
|
15
15
|
}
|
16
16
|
|
17
|
-
# Install the requested version of Ruby, with Bundler.
|
18
|
-
install_ruby() {
|
19
|
-
as_user "rbenv install -s $1"
|
20
|
-
as_user "RBENV_VERSION=$1 gem install bundler"
|
21
|
-
}
|
22
|
-
|
23
17
|
###############################################################################
|
24
18
|
# Base System
|
25
19
|
###############################################################################
|
@@ -57,14 +51,11 @@ truncate -s 0 $USER_HOME/.bashrc
|
|
57
51
|
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $USER_HOME/.bashrc
|
58
52
|
echo 'eval "$(rbenv init -)"' >> $USER_HOME/.bashrc
|
59
53
|
echo 'cd /vagrant' >> $USER_HOME/.bashrc
|
60
|
-
echo 'gem: --no-document' >> $USER_HOME/.gemrc
|
61
54
|
|
62
|
-
|
63
|
-
install_ruby $DEFAULT_RUBY
|
64
|
-
/home/$USER_NAME/.rbenv/bin/rbenv global $DEFAULT_RUBY
|
55
|
+
echo 'gem: --no-document' > $USER_HOME/.gemrc
|
65
56
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
# Install the requested version of Ruby, with Bundler.
|
58
|
+
as_user "rbenv install -s $DEFAULT_RUBY"
|
59
|
+
as_user "rbenv global $DEFAULT_RUBY"
|
60
|
+
as_user "RBENV_VERSION=$DEFAULT_RUBY gem install bundler"
|
61
|
+
as_user "cd /vagrant && bundle"
|
data/spec/spec_helper.rb
CHANGED
data/spec/string_spec.rb
CHANGED
@@ -155,4 +155,30 @@ describe String do
|
|
155
155
|
expect('1 2 3 4 5'.dedupe(' ').remove_whitespace('+')).to eq '1+2+3+4+5'
|
156
156
|
end
|
157
157
|
|
158
|
+
it '#slugify' do
|
159
|
+
expect(Integer.slugify).to eq 'integer'
|
160
|
+
expect(Math::DomainError.slugify).to eq 'math-domain-error'
|
161
|
+
expect('FooBarBaz'.slugify).to eq 'foo-bar-baz'
|
162
|
+
expect(:FooBarBaz.slugify).to eq 'foo-bar-baz'
|
163
|
+
expect("Foo-Bar'Baz".slugify).to eq 'foo-bar-baz'
|
164
|
+
expect('(Foo*&Bar!Baz?'.slugify).to eq 'foo-bar-baz'
|
165
|
+
expect('1234FooBAR'.slugify).to eq 'foo-bar'
|
166
|
+
expect('!@#$Foo0987'.slugify).to eq 'foo0987'
|
167
|
+
expect('!@#$%^'.slugify).to eq nil
|
168
|
+
expect('12345678'.slugify).to eq nil
|
169
|
+
expect("Bill O'Shea".slugify).to eq 'bill-o-shea'
|
170
|
+
expect("Bill O Shea".slugify).to eq 'bill-o-shea'
|
171
|
+
expect("Bill O Shea".slugify).to eq 'bill-o-shea'
|
172
|
+
|
173
|
+
# make sure we're not performing in place
|
174
|
+
str = 'FooBarBaz'
|
175
|
+
expect(str.slugify).to eq 'foo-bar-baz'
|
176
|
+
expect(str).to eq 'FooBarBaz'
|
177
|
+
end
|
178
|
+
|
179
|
+
it '#slugify!' do
|
180
|
+
expect{ '!@#$%^'.slugify! }.to raise_error(ArgumentError)
|
181
|
+
expect{ '12345678'.slugify! }.to raise_error(ArgumentError)
|
182
|
+
end
|
183
|
+
|
158
184
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finishing_moves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Koehl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-readline
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: coveralls
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.8.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.8.0
|
84
98
|
description: |2
|
85
99
|
Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself in a situation where an elaborate-yet-precise coding maneuver wins the day. Finishing Moves is a collection of methods designed to assist in those just-typical-enough-to-be-annoying scenarios.
|
86
100
|
email:
|