powerpack 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a3a66b83a0099f21936fdf18fdd2465ee803a0b
4
- data.tar.gz: 850e52d270c66647b71ff8a98a44bcfca39c9e14
3
+ metadata.gz: b2e81863714b8ba985b6b8df75e8c80fe0067622
4
+ data.tar.gz: 8db7578f7f0e9d011bbed495fbd86baec322906e
5
5
  SHA512:
6
- metadata.gz: 076f54612a3f4c83715654f2c5ecd82792b492b4a52308b52f43f6a4d718334eed4f24f4f578c7ca4f9d04cfa11c1e141075bbafd2fe465b5a63123ae9287dac
7
- data.tar.gz: 06746d79155d9a90500fbf93843e2b69aec72aca92b55389267b3f474dcc6127fd659a0bf108d0870d554c824948fb4785fe77f7074ad2a2ee8735d52b7e3606
6
+ metadata.gz: 0be201c62b1285df95790d9e48f121b6ef78a1cd2f58858b2b12098c03ae8cd8db9bae0ad9cde53a55f5d51c327d5887ca8bd1ec0b66fc7293f9bd16e0e67222
7
+ data.tar.gz: da8f272a0c79d5d83c04aa87775c4e52f9eea3f235a2074374447b5cab61bfe493aa059ad7427bf78ce7ff8e8809e425ae1776d6636ff34d4b14087712662e74
@@ -1,9 +1,13 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1
6
- - 2.2
7
- - jruby-19mode
8
- - rbx-2
4
+ - jruby-9.1.13.0
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - ruby-head
9
+ - rbx-3
9
10
  script: bundle exec rspec
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: rbx-3
@@ -2,25 +2,32 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 0.1.1 (04/05/2015)
5
+ ## 0.1.2 (2018-06-10)
6
+
7
+ * Changed `String#remove_prefix` to return the original string if the parameter is not a prefix.
8
+ +* Changed `String#remove_prefix!`to return the original string if the parameter is not a prefix.
9
+ +* Changed `String#remove_suffix` to return the original string if the parameter is not a suffix.
10
+ +* Changed `String#remove_suffix!` to return the original string if the parameter is not a suffix.
11
+
12
+ ## 0.1.1 (2015-05-04)
6
13
 
7
14
  No user-visible changes.
8
15
 
9
- ## 0.1.0 (25/01/2015)
16
+ ## 0.1.0 (2015-01-25)
10
17
 
11
18
  * Added `String#remove_prefix`
12
19
  * Added `String#remove_prefix!`
13
20
  * Added `String#remove_suffix`
14
21
  * Added `String#remove_suffix!`
15
22
 
16
- ## 0.0.9 (22/10/2013)
23
+ ## 0.0.9 (2013-10-22)
17
24
 
18
25
  * Added `String#remove`
19
26
  * Added `String#remove!`
20
27
  * Added `String#ascii_only`
21
28
  * Added `String#ascii_only!`
22
29
 
23
- ## 0.0.8 (13/09/2013)
30
+ ## 0.0.8 (2013-09-13)
24
31
 
25
32
  ### New features
26
33
 
@@ -0,0 +1,62 @@
1
+ # Contributing
2
+
3
+ If you discover issues, have ideas for improvements or new features,
4
+ please report them to the [issue tracker][1] of the repository or
5
+ submit a pull request. Please, try to follow these guidelines when you
6
+ do so.
7
+
8
+ ## Issue reporting
9
+
10
+ * Check that the issue has not already been reported.
11
+ * Check that the issue has not already been fixed in the latest code
12
+ (a.k.a. `master`).
13
+ * Be clear, concise and precise in your description of the problem.
14
+ * Open an issue with a descriptive title and a summary in grammatically correct,
15
+ complete sentences.
16
+ * Include Powerpack's version number.
17
+ * Include any relevant code to the issue summary.
18
+
19
+ ## Pull requests
20
+
21
+ * Read [how to properly contribute to open source projects on Github][2].
22
+ * Fork the project.
23
+ * Use a topic/feature branch to easily amend a pull request later, if necessary.
24
+ * Write [good commit messages][3].
25
+ * Use the same coding conventions as the rest of the project.
26
+ * Commit and push until you are happy with your contribution.
27
+ * Make sure to add tests for it. This is important so I don't break it
28
+ in a future version unintentionally.
29
+ * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
30
+ * Please try not to mess with the Rakefile, version, or history. If
31
+ you want to have your own version, or is otherwise necessary, that
32
+ is fine, but please isolate to its own commit so I can cherry-pick
33
+ around it.
34
+ * Make sure the test suite is passing ([including rbx and jruby][7]) and the code you wrote doesn't produce
35
+ RuboCop offenses.
36
+ * [Squash related commits together][5].
37
+ * Open a [pull request][4] that relates to *only* one subject with a clear title
38
+ and description in grammatically correct, complete sentences.
39
+
40
+ ### Changelog entry format
41
+
42
+ Here are a few examples:
43
+
44
+ ```
45
+ * [#123](https://github.com/bbatsov/powerpack/issues/123): Fixed a bug in `Something#something`. ([@bbatsov][])
46
+ * Added new method `Something#something`. ([@bbatsov][])
47
+ ```
48
+
49
+ * Mark it up in [Markdown syntax][6].
50
+ * The entry line should start with `* ` (an asterisk and a space).
51
+ * If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/bbatsov/powerpack/issues/123): `.
52
+ * Describe the brief of the change. The sentence should end with a punctuation.
53
+ * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
54
+ * If this is your first contribution to Powerpack project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
55
+
56
+ [1]: https://github.com/bbatsov/powerpack/issues
57
+ [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
58
+ [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
59
+ [4]: https://help.github.com/articles/using-pull-requests
60
+ [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
61
+ [6]: http://daringfireball.net/projects/markdown/syntax
62
+ [7]: http://blog.stwrt.ca/2013/09/06/installing-rubinius-with-rbenv
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Gem Version](https://badge.fury.io/rb/powerpack.png)](http://badge.fury.io/rb/powerpack)
2
- [![Build Status](https://travis-ci.org/bbatsov/powerpack.png?branch=master)](https://travis-ci.org/bbatsov/powerpack)
1
+ [![Gem Version](https://badge.fury.io/rb/powerpack.svg)](http://badge.fury.io/rb/powerpack)
2
+ [![Build Status](https://travis-ci.org/bbatsov/powerpack.svg?branch=master)](https://travis-ci.org/bbatsov/powerpack)
3
3
 
4
4
  # Powerpack
5
5
 
@@ -3,19 +3,23 @@ unless Enumerable.method_defined? :sum
3
3
  # Sums up elements of a collection by invoking their `+` method.
4
4
  # Most useful for summing up numbers.
5
5
  #
6
- # @param default [Object] an optional default return value if there are no elements.
7
- # It's nil by default.
8
- # @return The sum of the elements or the default value if there are no
9
- # elements.
6
+ # @param initial [Object] an optional initial value.
7
+ # It defaults to 0 for an empty collection.
8
+ # @return The sum of the elements, or the initial value if there
9
+ # are no elements.
10
10
  #
11
11
  # @example
12
12
  # [1, 2, 3].sum #=> 6
13
- # ["a", "b", "c"].sum #=> "abc"
14
13
  # [[1], [2], [3]].sum #=> [1, 2, 3]
15
- # [].sum #=> nil
16
- # [].sum(0) #=> 0
17
- def sum(default = nil)
18
- reduce(&:+) || default
14
+ # [].sum #=> 0
15
+ # ["a"].sum #=> "a"
16
+ # ["b", "c"].sum("a") #=> "abc"
17
+ def sum(initial = nil)
18
+ if initial
19
+ reduce(initial, &:+)
20
+ else
21
+ reduce(&:+) || 0
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -18,6 +18,7 @@ unless String.method_defined? :remove_prefix
18
18
  # 'Ladies Night'.remove_prefix!('Ladies ') #=> 'Night'
19
19
  def remove_prefix!(pattern)
20
20
  gsub!(/\A#{pattern}/, '')
21
+ self
21
22
  end
22
23
  end
23
24
  end
@@ -18,6 +18,7 @@ unless String.method_defined? :remove_suffix
18
18
  # 'Ladies Night'.remove_suffix!(' Night') #=> 'Ladies'
19
19
  def remove_suffix!(pattern)
20
20
  gsub!(/#{pattern}\z/, '')
21
+ self
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Powerpack
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency 'bundler', '~> 1.3'
21
21
  spec.add_development_dependency 'rake'
22
22
  spec.add_development_dependency('rspec')
23
- spec.add_development_dependency('yard', '~> 0.8')
23
+ spec.add_development_dependency('yard', '~> 0.9')
24
24
  end
@@ -1,15 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Enumerable#sum' do
4
- it 'sums up the numbers of an enum' do
5
- expect((1..3).sum).to eq(6)
6
- end
3
+ unless Enumerable.method_defined? :sum
4
+ describe 'Enumerable#sum' do
5
+ it 'sums up the numbers of an enum' do
6
+ expect((1..3).sum).to eq(6)
7
+ end
7
8
 
8
- it 'returns nil when invoked on an empty collection' do
9
- expect([].sum).to be_nil
10
- end
9
+ it 'returns zero when invoked on an empty collection' do
10
+ expect([].sum).to be_zero
11
+ end
12
+
13
+ it 'returns the initial value when invoked on an empty collection' do
14
+ expect([].sum('')).to be_empty
15
+ end
16
+
17
+ it 'prepends the initial value to the sum' do
18
+ expect(['b', 'c'].sum('a')).to eq('abc')
19
+ end
20
+
21
+ it 'concatenates strings' do
22
+ expect(['a', 'b', 'c'].sum).to eq('abc')
23
+ end
11
24
 
12
- it 'returns default value when invoked on an empty collection' do
13
- expect([].sum(0)).to be_zero
25
+ it 'concatenates arrays' do
26
+ expect([[1], [2], [3]].sum).to eq([1, 2, 3])
27
+ end
14
28
  end
15
29
  end
@@ -4,10 +4,18 @@ describe 'String#remove_prefix' do
4
4
  it 'removes a prefix in a string' do
5
5
  expect('Ladies Night'.remove_prefix('Ladies ')).to eq('Night')
6
6
  end
7
+
8
+ it 'returns the original string if the parameter is not a prefix' do
9
+ expect('Ladies Night'.remove_prefix('Night')).to eq('Ladies Night')
10
+ end
7
11
  end
8
12
 
9
13
  describe 'String#remove_prefix!' do
10
14
  it 'removes a prefix in a string' do
11
15
  expect('Ladies Night'.remove_prefix!('Ladies ')).to eq('Night')
12
16
  end
17
+
18
+ it 'returns the original string if the parameter is not a prefix' do
19
+ expect('Ladies Night'.remove_prefix!('Night')).to eq('Ladies Night')
20
+ end
13
21
  end
@@ -4,10 +4,18 @@ describe 'String#remove_suffix' do
4
4
  it 'removes a suffix in a string' do
5
5
  expect('Ladies Night'.remove_suffix(' Night')).to eq('Ladies')
6
6
  end
7
+
8
+ it 'returns the original string if the parameter is not a suffix' do
9
+ expect('Ladies Night'.remove_suffix('Ladies')).to eq('Ladies Night')
10
+ end
7
11
  end
8
12
 
9
13
  describe 'String#remove_suffix!' do
10
14
  it 'removes a suffix in a string' do
11
15
  expect('Ladies Night'.remove_suffix!(' Night')).to eq('Ladies')
12
16
  end
17
+
18
+ it 'returns the original string if the parameter is not a suffix' do
19
+ expect('Ladies Night'.remove_suffix!('Ladies')).to eq('Ladies Night')
20
+ end
13
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: powerpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2018-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.8'
61
+ version: '0.9'
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
- version: '0.8'
68
+ version: '0.9'
69
69
  description: A few useful extensions to core Ruby classes.
70
70
  email:
71
71
  - bozhidar@batsov.com
@@ -77,6 +77,7 @@ files:
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
79
  - CHANGELOG.md
80
+ - CONTRIBUTING.md
80
81
  - Gemfile
81
82
  - LICENSE.txt
82
83
  - README.md
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  version: '0'
159
160
  requirements: []
160
161
  rubyforge_project:
161
- rubygems_version: 2.2.2
162
+ rubygems_version: 2.6.11
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: A few useful extensions to core Ruby classes.
@@ -188,4 +189,3 @@ test_files:
188
189
  - spec/powerpack/string/strip_indent_spec.rb
189
190
  - spec/powerpack/string/strip_margin_spec.rb
190
191
  - spec/spec_helper.rb
191
- has_rdoc: