rext 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,10 @@
1
1
 
2
+ 0.7.0 / 2010-01-11
3
+ ==================
4
+
5
+ * Added Array#{avg, average}
6
+ * Added Array#sum
7
+
2
8
  0.6.2 / 2009-11-30
3
9
  ==================
4
10
 
data/Manifest CHANGED
@@ -37,7 +37,6 @@ lib/rext/symbol/helpers.rb
37
37
  lib/rext/time.rb
38
38
  lib/rext/time/helpers.rb
39
39
  lib/rext/version.rb
40
- rext.gemspec
41
40
  spec/array_spec.rb
42
41
  spec/date_spec.rb
43
42
  spec/enumerable_spec.rb
@@ -97,6 +97,14 @@ Below are the methods currently provided by Rext.
97
97
  * Proc
98
98
  - yield_or_eval
99
99
 
100
+ * Array
101
+ - chunk / in_groups_of
102
+ - pad
103
+ - sum
104
+ - avg / average
105
+ - to
106
+ - from
107
+
100
108
  * Enumerable
101
109
  - group_by
102
110
  - includes_all?
@@ -3,6 +3,22 @@ require 'enumerator'
3
3
 
4
4
  class Array
5
5
 
6
+ ##
7
+ # Return the sum of numbers within the array.
8
+
9
+ def sum
10
+ inject(0) { |sum, n| sum += n }
11
+ end
12
+
13
+ ##
14
+ # Return the average of numbers within the array.
15
+
16
+ def avg
17
+ return 0 if empty?
18
+ sum.to_f / length
19
+ end
20
+ alias :average :avg
21
+
6
22
  ##
7
23
  # Return array of elements after _index_.
8
24
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rext
3
- VERSION = '0.6.2'
3
+ VERSION = '0.7.0'
4
4
  end
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rext}
5
- s.version = "0.6.2"
5
+ s.version = "0.7.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2009-11-30}
9
+ s.date = %q{2010-01-11}
10
10
  s.description = %q{Ruby extensions}
11
11
  s.email = %q{tj@vision-media.ca}
12
12
  s.extra_rdoc_files = ["README.rdoc", "lib/rext.rb", "lib/rext/all.rb", "lib/rext/array.rb", "lib/rext/array/helpers.rb", "lib/rext/date.rb", "lib/rext/date/helpers.rb", "lib/rext/enumerable.rb", "lib/rext/enumerable/helpers.rb", "lib/rext/hash.rb", "lib/rext/hash/helpers.rb", "lib/rext/integer.rb", "lib/rext/integer/helpers.rb", "lib/rext/module.rb", "lib/rext/module/helpers.rb", "lib/rext/numeric.rb", "lib/rext/numeric/bytes.rb", "lib/rext/numeric/helpers.rb", "lib/rext/numeric/time.rb", "lib/rext/object.rb", "lib/rext/object/helpers.rb", "lib/rext/object/metaclass.rb", "lib/rext/proc.rb", "lib/rext/proc/helpers.rb", "lib/rext/process.rb", "lib/rext/process/helpers.rb", "lib/rext/string.rb", "lib/rext/string/encode.rb", "lib/rext/string/helpers.rb", "lib/rext/symbol.rb", "lib/rext/symbol/helpers.rb", "lib/rext/time.rb", "lib/rext/time/helpers.rb", "lib/rext/version.rb", "tasks/benchmark.rake", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
- s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "benchmarks/enumerable.rb", "benchmarks/proc.rb", "lib/rext.rb", "lib/rext/all.rb", "lib/rext/array.rb", "lib/rext/array/helpers.rb", "lib/rext/date.rb", "lib/rext/date/helpers.rb", "lib/rext/enumerable.rb", "lib/rext/enumerable/helpers.rb", "lib/rext/hash.rb", "lib/rext/hash/helpers.rb", "lib/rext/integer.rb", "lib/rext/integer/helpers.rb", "lib/rext/module.rb", "lib/rext/module/helpers.rb", "lib/rext/numeric.rb", "lib/rext/numeric/bytes.rb", "lib/rext/numeric/helpers.rb", "lib/rext/numeric/time.rb", "lib/rext/object.rb", "lib/rext/object/helpers.rb", "lib/rext/object/metaclass.rb", "lib/rext/proc.rb", "lib/rext/proc/helpers.rb", "lib/rext/process.rb", "lib/rext/process/helpers.rb", "lib/rext/string.rb", "lib/rext/string/encode.rb", "lib/rext/string/helpers.rb", "lib/rext/symbol.rb", "lib/rext/symbol/helpers.rb", "lib/rext/time.rb", "lib/rext/time/helpers.rb", "lib/rext/version.rb", "rext.gemspec", "spec/array_spec.rb", "spec/date_spec.rb", "spec/enumerable_spec.rb", "spec/hash_spec.rb", "spec/integer_spec.rb", "spec/module_spec.rb", "spec/numeric_spec.rb", "spec/object_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/string_spec.rb", "spec/symbol_spec.rb", "spec/time_spec.rb", "tasks/benchmark.rake", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
+ s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "benchmarks/enumerable.rb", "benchmarks/proc.rb", "lib/rext.rb", "lib/rext/all.rb", "lib/rext/array.rb", "lib/rext/array/helpers.rb", "lib/rext/date.rb", "lib/rext/date/helpers.rb", "lib/rext/enumerable.rb", "lib/rext/enumerable/helpers.rb", "lib/rext/hash.rb", "lib/rext/hash/helpers.rb", "lib/rext/integer.rb", "lib/rext/integer/helpers.rb", "lib/rext/module.rb", "lib/rext/module/helpers.rb", "lib/rext/numeric.rb", "lib/rext/numeric/bytes.rb", "lib/rext/numeric/helpers.rb", "lib/rext/numeric/time.rb", "lib/rext/object.rb", "lib/rext/object/helpers.rb", "lib/rext/object/metaclass.rb", "lib/rext/proc.rb", "lib/rext/proc/helpers.rb", "lib/rext/process.rb", "lib/rext/process/helpers.rb", "lib/rext/string.rb", "lib/rext/string/encode.rb", "lib/rext/string/helpers.rb", "lib/rext/symbol.rb", "lib/rext/symbol/helpers.rb", "lib/rext/time.rb", "lib/rext/time/helpers.rb", "lib/rext/version.rb", "spec/array_spec.rb", "spec/date_spec.rb", "spec/enumerable_spec.rb", "spec/hash_spec.rb", "spec/integer_spec.rb", "spec/module_spec.rb", "spec/numeric_spec.rb", "spec/object_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/string_spec.rb", "spec/symbol_spec.rb", "spec/time_spec.rb", "tasks/benchmark.rake", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "rext.gemspec"]
14
14
  s.homepage = %q{http://github.com/visionmedia/rext}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rext", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
@@ -9,6 +9,26 @@ describe Array do
9
9
  @items = %w( some foo bar )
10
10
  end
11
11
 
12
+ describe "#sum" do
13
+ it "should return the sum of the numbers in an array" do
14
+ [1,2,3].sum.should == 6
15
+ end
16
+
17
+ it "should return 0 when empty" do
18
+ [].sum.should == 0
19
+ end
20
+ end
21
+
22
+ describe "#avg" do
23
+ it "should return the average of numbers in the array" do
24
+ [3,3,6,6].avg.should == 4.5
25
+ end
26
+
27
+ it "should return 0 when empty" do
28
+ [].avg.should == 0
29
+ end
30
+ end
31
+
12
32
  describe "#from" do
13
33
  it "should return elements after the position specified" do
14
34
  @items.from(1).should == %w( foo bar )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-30 00:00:00 -08:00
12
+ date: 2010-01-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -98,7 +98,6 @@ files:
98
98
  - lib/rext/time.rb
99
99
  - lib/rext/time/helpers.rb
100
100
  - lib/rext/version.rb
101
- - rext.gemspec
102
101
  - spec/array_spec.rb
103
102
  - spec/date_spec.rb
104
103
  - spec/enumerable_spec.rb
@@ -116,6 +115,7 @@ files:
116
115
  - tasks/docs.rake
117
116
  - tasks/gemspec.rake
118
117
  - tasks/spec.rake
118
+ - rext.gemspec
119
119
  has_rdoc: true
120
120
  homepage: http://github.com/visionmedia/rext
121
121
  licenses: []