powerpack 0.0.9 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d3df53a4979884a29c563336460368f50c8235b
4
- data.tar.gz: 0b4f51bcf7c5374cd5ebb4d48543c7450461796f
3
+ metadata.gz: 50f7e492da95de510a5b6fc4e65473ac3ddc1fb7
4
+ data.tar.gz: 427c3e18cd193ca1692e4c4f73e0cdaf9f4b5a73
5
5
  SHA512:
6
- metadata.gz: 2006ba07ffea976d3cbdc95dbf6cd88de0f69551ea8b95bf32e8ad196f3d29806284cd94aced250a71f72f4a7289410489f74dae2cad748f0c72298ea504db9a
7
- data.tar.gz: 8bf8a78aeb5967a9ecedc1a261f7d92cb73c08f81f9ff1c5985ad579d8b1199a6c1720608e56551b4b7067666ab3554dbb5c1e5375c8ce54b4c836028dd27369
6
+ metadata.gz: 97715c9d3bac5ddeb10c1f9be5a392a4a6ce93ac56e579eb8cdbc363ab736c1df0828dc65d8a1678633e159c45919d4e19d108f15de0933ebd95b96d533eee23
7
+ data.tar.gz: 1f96319f56cefb7c3a6d73d5465544fe74f07c73e7dec95c0dfb48a9ccc58959a5826998f87f83aabba9161b13222266e887ad6026fa1b9539da991a8b5a555e
@@ -2,6 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1
6
+ - 2.2
5
7
  - jruby-19mode
6
- - rbx-19mode
8
+ - rbx-2
7
9
  script: bundle exec rspec
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.1.0 (25/01/2015)
6
+
7
+ * Added `String#remove_prefix`
8
+ * Added `String#remove_prefix!`
9
+ * Added `String#remove_suffix`
10
+ * Added `String#remove_suffix!`
11
+
5
12
  ## 0.0.9 (22/10/2013)
6
13
 
7
14
  * Added `String#remove`
data/README.md CHANGED
@@ -52,6 +52,10 @@ Or install it yourself as:
52
52
  * [#format](http://rdoc.info/github/bbatsov/powerpack/String#format-instance_method)
53
53
  * [#remove](http://rdoc.info/github/bbatsov/powerpack/String#remove-instance_method)
54
54
  * [#remove!](http://rdoc.info/github/bbatsov/powerpack/String#remove!-instance_method)
55
+ * [#remove_prefix](http://rdoc.info/github/bbatsov/powerpack/String#remove_prefix-instance_method)
56
+ * [#remove_prefix!](http://rdoc.info/github/bbatsov/powerpack/String#remove_prefix!-instance_method)
57
+ * [#remove_suffix](http://rdoc.info/github/bbatsov/powerpack/String#remove_suffix-instance_method)
58
+ * [#remove_suffix!](http://rdoc.info/github/bbatsov/powerpack/String#remove_suffix!-instance_method)
55
59
  * [#strip_indent](http://rdoc.info/github/bbatsov/powerpack/String#strip_indent-instance_method)
56
60
  * [#strip_margin](http://rdoc.info/github/bbatsov/powerpack/String#strip_margin-instance_method)
57
61
  * [#squish](http://rdoc.info/github/bbatsov/powerpack/String#squish-instance_method)
@@ -2,6 +2,8 @@ require_relative 'string/ascii_only'
2
2
  require_relative 'string/blank'
3
3
  require_relative 'string/format'
4
4
  require_relative 'string/remove'
5
+ require_relative 'string/remove_prefix'
6
+ require_relative 'string/remove_suffix'
5
7
  require_relative 'string/strip_indent'
6
8
  require_relative 'string/strip_margin'
7
9
  require_relative 'string/squish'
@@ -0,0 +1,23 @@
1
+ unless String.method_defined? :remove_prefix
2
+ class String
3
+ # Removes a prefix in a string.
4
+ #
5
+ # @return [String] a new string without the prefix.
6
+ #
7
+ # @example
8
+ # 'Ladies Night'.remove_prefix('Ladies ') #=> 'Night'
9
+ def remove_prefix(pattern)
10
+ dup.remove_prefix!(pattern)
11
+ end
12
+
13
+ # Removes a prefix in a string.
14
+ #
15
+ # @return [String] the string without the prefix.
16
+ #
17
+ # @example
18
+ # 'Ladies Night'.remove_prefix!('Ladies ') #=> 'Night'
19
+ def remove_prefix!(pattern)
20
+ gsub!(/\A#{pattern}/, '')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ unless String.method_defined? :remove_suffix
2
+ class String
3
+ # Removes a suffix in a string.
4
+ #
5
+ # @return [String] a new string without the suffix.
6
+ #
7
+ # @example
8
+ # 'Ladies Night'.remove_suffix(' Night') #=> 'Ladies'
9
+ def remove_suffix(pattern)
10
+ dup.remove_suffix!(pattern)
11
+ end
12
+
13
+ # Removes a suffix in a string.
14
+ #
15
+ # @return [String] the string without the suffix.
16
+ #
17
+ # @example
18
+ # 'Ladies Night'.remove_suffix!(' Night') #=> 'Ladies'
19
+ def remove_suffix!(pattern)
20
+ gsub!(/#{pattern}\z/, '')
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Powerpack
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'String#remove_prefix' do
4
+ it 'removes a prefix in a string' do
5
+ expect('Ladies Night'.remove_prefix('Ladies ')).to eq('Night')
6
+ end
7
+ end
8
+
9
+ describe 'String#remove_prefix!' do
10
+ it 'removes a prefix in a string' do
11
+ expect('Ladies Night'.remove_prefix!('Ladies ')).to eq('Night')
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'String#remove_suffix' do
4
+ it 'removes a suffix in a string' do
5
+ expect('Ladies Night'.remove_suffix(' Night')).to eq('Ladies')
6
+ end
7
+ end
8
+
9
+ describe 'String#remove_suffix!' do
10
+ it 'removes a suffix in a string' do
11
+ expect('Ladies Night'.remove_suffix!(' Night')).to eq('Ladies')
12
+ end
13
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: powerpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.13'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.8'
69
69
  description: A few useful extensions to core Ruby classes.
@@ -73,9 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
79
  - CHANGELOG.md
80
80
  - Gemfile
81
81
  - LICENSE.txt
@@ -106,6 +106,8 @@ files:
106
106
  - lib/powerpack/string/blank.rb
107
107
  - lib/powerpack/string/format.rb
108
108
  - lib/powerpack/string/remove.rb
109
+ - lib/powerpack/string/remove_prefix.rb
110
+ - lib/powerpack/string/remove_suffix.rb
109
111
  - lib/powerpack/string/squish.rb
110
112
  - lib/powerpack/string/strip_indent.rb
111
113
  - lib/powerpack/string/strip_margin.rb
@@ -129,7 +131,9 @@ files:
129
131
  - spec/powerpack/string/ascii_only_spec.rb
130
132
  - spec/powerpack/string/blank_spec.rb
131
133
  - spec/powerpack/string/format_spec.rb
134
+ - spec/powerpack/string/remove_prefix_spec.rb
132
135
  - spec/powerpack/string/remove_spec.rb
136
+ - spec/powerpack/string/remove_suffix_spec.rb
133
137
  - spec/powerpack/string/squish_spec.rb
134
138
  - spec/powerpack/string/strip_indent_spec.rb
135
139
  - spec/powerpack/string/strip_margin_spec.rb
@@ -144,17 +148,17 @@ require_paths:
144
148
  - lib
145
149
  required_ruby_version: !ruby/object:Gem::Requirement
146
150
  requirements:
147
- - - '>='
151
+ - - ">="
148
152
  - !ruby/object:Gem::Version
149
153
  version: '0'
150
154
  required_rubygems_version: !ruby/object:Gem::Requirement
151
155
  requirements:
152
- - - '>='
156
+ - - ">="
153
157
  - !ruby/object:Gem::Version
154
158
  version: '0'
155
159
  requirements: []
156
160
  rubyforge_project:
157
- rubygems_version: 2.0.3
161
+ rubygems_version: 2.2.2
158
162
  signing_key:
159
163
  specification_version: 4
160
164
  summary: A few useful extensions to core Ruby classes.
@@ -177,7 +181,9 @@ test_files:
177
181
  - spec/powerpack/string/ascii_only_spec.rb
178
182
  - spec/powerpack/string/blank_spec.rb
179
183
  - spec/powerpack/string/format_spec.rb
184
+ - spec/powerpack/string/remove_prefix_spec.rb
180
185
  - spec/powerpack/string/remove_spec.rb
186
+ - spec/powerpack/string/remove_suffix_spec.rb
181
187
  - spec/powerpack/string/squish_spec.rb
182
188
  - spec/powerpack/string/strip_indent_spec.rb
183
189
  - spec/powerpack/string/strip_margin_spec.rb