cryx-g5k 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -0,0 +1,16 @@
1
+ # for versions of ruby < 1.8.7
2
+ module Enumerable
3
+ def index_by
4
+ inject({}) do |accum, elem|
5
+ accum[yield(elem)] = elem
6
+ accum
7
+ end
8
+ end
9
+
10
+ def group_by #:yield:
11
+ #h = k = e = nil
12
+ r = Hash.new
13
+ each{ |e| (r[yield(e)] ||= []) << e }
14
+ r
15
+ end
16
+ end
data/lib/g5k.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # Subdirs are not automatically loaded. Users must explicitly require them.
2
2
 
3
3
  module G5K
4
-
4
+ end
5
+
6
+ unless [].respond_to?(:group_by) || [].respond_to?(:index_by)
7
+ require File.dirname(__FILE__)+"/g5k/enumerable_extensions"
5
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryx-g5k
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Rohr
@@ -24,6 +24,7 @@ extra_rdoc_files: []
24
24
  files:
25
25
  - VERSION.yml
26
26
  - lib/g5k
27
+ - lib/g5k/enumerable_extensions.rb
27
28
  - lib/g5k/parsing
28
29
  - lib/g5k/parsing/parser.rb
29
30
  - lib/g5k/parsing.rb