nutella 0.1 → 0.1.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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # Nutella [![Build Status](https://secure.travis-ci.org/gbchaosmaster/nutella.png)](http://travis-ci.org/gbchaosmaster/nutella)
1
+ # Nutella [![Build Status](https://secure.travis-ci.org/gbchaosmaster/nutella.png)](http://travis-ci.org/gbchaosmaster/nutella) [![Dependency Status](https://gemnasium.com/gbchaosmaster/nutella.png)](https://gemnasium.com/gbchaosmaster/nutella) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/gbchaosmaster/nutella)
2
2
 
3
3
  This library is my personal collection of Ruby utilities, mainly core
4
- extensions. It is similar to
5
- [Active Support](https://github.com/rails/rails/tree/master/activesupport),
6
- but lighter.
4
+ extensions.
5
+
6
+ * [RubyGems](https://rubygems.org/gems/nutella)
7
7
 
8
8
  ## Installation
9
9
 
@@ -15,39 +15,18 @@ gem install nutella
15
15
 
16
16
  ## Contributing
17
17
 
18
- This library is my own little collection of core extensions that I like to use,
19
- and I add things as they are useful to me. I cannot guarantee that you will
20
- find it useful as I do.
18
+ All contributions to Nutella are welcome. Feel free to send a pull request if
19
+ you feel that you have a feature that is useful, and definitely let me know if
20
+ you find any bugs.
21
21
 
22
- That being said, I welcome any contributions. Feel free to send a pull request
23
- if you feel that you have a feature that is useful, and definitely let me know
24
- if you find any bugs.
22
+ Be sure that all tests succeed before sending a pull request! Pull requests
23
+ with failing tests will not be accepted. Also, please test your code- if your
24
+ change affects the functionality of the library, write tests that fail
25
+ without your code, and pass with your code.
25
26
 
26
27
  ## License
27
28
 
28
- ```nutella``` is released under the MIT license.
29
-
30
- ```
31
- Copyright (C) 2012 Vinny Diehl
32
-
33
- Permission is hereby granted, free of charge, to any person obtaining a copy of
34
- this software and associated documentation files (the "Software"), to deal in
35
- the Software without restriction, including without limitation the rights to
36
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
37
- of the Software, and to permit persons to whom the Software is furnished to do
38
- so, subject to the following conditions:
39
-
40
- The above copyright notice and this permission notice shall be included in all
41
- copies or substantial portions of the Software.
42
-
43
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
- SOFTWARE.
50
- ```
51
-
52
- See [the official page on OSI](http://opensource.org/licenses/MIT) for more
29
+ Nutella is released under the MIT license. See the LICENSE file included with
30
+ this code or
31
+ [the official page on OSI](http://opensource.org/licenses/MIT) for more
53
32
  information.
data/Rakefile CHANGED
@@ -1,8 +1,17 @@
1
+ require "nutella/version"
2
+
1
3
  require "bundler"
2
4
  Bundler::GemHelper.install_tasks
3
5
 
4
6
  require "rspec/core/rake_task"
5
7
  RSpec::Core::RakeTask.new :spec
6
-
7
8
  task test: :spec
9
+
10
+ require "yard"
11
+ YARD::Rake::YardocTask.new do |doc|
12
+ doc.files << "lib/**/*.rb"
13
+ doc.options << ["--title", "Nutella #{Nutella::VERSION} Documentation"]
14
+ end
15
+ task doc: :yard
16
+
8
17
  task default: :spec
@@ -2,9 +2,11 @@ module Enumerable
2
2
  alias_method :contains?, :include?
3
3
  alias_method :includes?, :include?
4
4
 
5
- # The inverse of <tt>Enumerable#include?</tt>. Returns +true+ if the
6
- # collection does not contain +object+.
7
- def exclude? object
5
+ # The inverse of <tt>Enumerable#include?</tt>.
6
+ #
7
+ # @param [Object] object the object to test for exclusion
8
+ # @return [Boolean] whether or not the collection excludes +object+
9
+ def exclude?(object)
8
10
  !include? object
9
11
  end
10
12
  alias_method :excludes?, :exclude?
@@ -13,28 +15,43 @@ module Enumerable
13
15
  # at the end will be put into a smaller group if necessary, unless
14
16
  # +discard_excess+ is true, in which case they will be discarded.
15
17
  #
18
+ # @example Groups numbers 1..4 into groups of 2
16
19
  # (1..4).group(2) # => [[1, 2], [3, 4]]
20
+ # @example Groups numbers 1..8 into groups of 3
17
21
  # (1..8).group(3) # => [[1, 2, 3], [4, 5, 6], [7, 8]]
22
+ # @example Groups numbers 1..8 into groups of 3, discarding excess elements
18
23
  # (1..8).group(3, true) # => [[1, 2, 3], [4, 5, 6]]
24
+ #
25
+ # @param [Integer] size the size of the groups to create
26
+ # @param [Boolean] discard_excess whether or not to discard extra elements
27
+ # @return [Array] an array of the groups
19
28
  def group(size, discard_excess = false)
20
29
  groups = each_slice(size).to_a
21
- discard_excess && groups.last.size < size ? groups[0..-2] : groups
30
+ groups[0..(discard_excess && groups.last.size < size ? -2 : -1)]
22
31
  end
23
32
 
24
33
  # Modifies the collection in place as described for
25
34
  # <tt>Enumerable#group</tt>. Returns the modified collection, or nil if no
26
35
  # modifications were made.
36
+ #
37
+ # @see Enumerable#group
27
38
  def group!(size, discard_excess = false)
28
39
  return nil if empty?
29
40
  self.replace group(size, discard_excess)
30
41
  end
31
42
 
32
- # Returns the sum of all numeric elements in the collection
43
+ # Add together all numeric elements in the collection.
33
44
  #
45
+ # @example Sums up the elements of an array
34
46
  # [1, 2, 3].sum # => 6
47
+ # @example Sums up the elements of a 2-dimensional array
35
48
  # [[1, 2], [3, 4]].sum # => 10
49
+ # @example Sums up the numeric elements of a hash
36
50
  # { a: 4, b: 5 }.sum # => 9
51
+ # @example Ignores the non-numeric element in the array
37
52
  # [2, "string", 9].sum # => 11
53
+ #
54
+ # @return [Numeric] the sum of all numeric elements in the collection
38
55
  def sum
39
56
  flatten.select { |e| e.is_a? Numeric }.inject(:+) || 0
40
57
  end
@@ -4,15 +4,28 @@ class String
4
4
 
5
5
  alias_method :each, :each_char
6
6
 
7
- # The inverse of <tt>String#include?</tt>. Returns +true+ if the string does
8
- # not contain +str+.
7
+ # The inverse of <tt>String#include?</tt>.
8
+ #
9
+ # @param [String] str the string to test for exclusion
10
+ # @return [Boolean] whether or not the string excludes the substring +str+
9
11
  def exclude?(str)
10
12
  !include? str
11
13
  end
12
14
  alias_method :excludes?, :exclude?
13
15
 
14
- # Left-aligns a heredoc by finding the lest indented line in the string, and
15
- # removing that amount of leading whitespace.
16
+ # Left-aligns a heredoc by finding the least indented line in the string, and
17
+ # removing that amount of leading whitespace from each line.
18
+ #
19
+ # @example Prints the contents of the heredoc as described on each line
20
+ # puts <<-EOS.heredoc
21
+ # This line would be left-aligned.
22
+ # This line too.
23
+ # This line would be indented by four spaces.
24
+ # As well as this line.
25
+ # And back to left-aligned.
26
+ # EOS
27
+ #
28
+ # @return [String] the string with excess leading whitespace stripped
16
29
  def heredoc
17
30
  gsub /^[ \t]{#{scan(/^[ \t]*(?=\S)/).min.size}}/, ""
18
31
  end
@@ -1,3 +1,4 @@
1
1
  module Nutella
2
- VERSION = "0.1"
2
+ # The current version of Nutella.
3
+ VERSION = "0.1.1"
3
4
  end
data/nutella.gemspec CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |gem|
20
20
  ]
21
21
 
22
22
  gem.required_ruby_version = ">= 1.9.2"
23
- gem.add_development_dependency "rake"
24
- gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "rake", "~> 0.9"
24
+ gem.add_development_dependency "redcarpet", "~> 2.1"
25
+ gem.add_development_dependency "rdoc", "~> 3.0"
26
+ gem.add_development_dependency "rspec", "~> 2.11"
27
+ gem.add_development_dependency "yard", "~> 0.8"
25
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutella
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,33 +16,81 @@ dependencies:
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '0.9'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: '0.9'
30
+ - !ruby/object:Gem::Dependency
31
+ name: redcarpet
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.1'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.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: '3.0'
30
62
  - !ruby/object:Gem::Dependency
31
63
  name: rspec
32
64
  requirement: !ruby/object:Gem::Requirement
33
65
  none: false
34
66
  requirements:
35
- - - ! '>='
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.11'
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: '2.11'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
36
84
  - !ruby/object:Gem::Version
37
- version: '0'
85
+ version: '0.8'
38
86
  type: :development
39
87
  prerelease: false
40
88
  version_requirements: !ruby/object:Gem::Requirement
41
89
  none: false
42
90
  requirements:
43
- - - ! '>='
91
+ - - ~>
44
92
  - !ruby/object:Gem::Version
45
- version: '0'
93
+ version: '0.8'
46
94
  description: My collection of Ruby utilities, mainly core extensions.
47
95
  email: gbchaosmaster926@gmail.com
48
96
  executables: []
@@ -81,6 +129,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
129
  - - ! '>='
82
130
  - !ruby/object:Gem::Version
83
131
  version: '0'
132
+ segments:
133
+ - 0
134
+ hash: -2447363496143350435
84
135
  requirements: []
85
136
  rubyforge_project:
86
137
  rubygems_version: 1.8.24
@@ -91,3 +142,4 @@ test_files:
91
142
  - spec/nutella/core_ext/enumerable_spec.rb
92
143
  - spec/nutella/core_ext/string_spec.rb
93
144
  - spec/spec_helper.rb
145
+ has_rdoc: