comprende 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.
@@ -0,0 +1,8 @@
1
+ Manifest
2
+ README.rdoc
3
+ Rakefile
4
+ comprende.gemspec
5
+ lib/comprende.rb
6
+ lib/comprende/array.rb
7
+ lib/comprende/proc.rb
8
+ lib/comprende/symbol.rb
@@ -0,0 +1,11 @@
1
+ = Comprende
2
+
3
+ Ruby gem for performing list comprehensions on collections of data.
4
+
5
+ == Install
6
+
7
+ gem install comprende
8
+
9
+ == Usage
10
+
11
+ Coming soon!
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ require "rake"
3
+ require "echoe"
4
+
5
+ Echoe.new("comprende", "0.1.0") do |config|
6
+ config.description = "List comprehension support for Ruby"
7
+ config.url = "http://github.com/evansenter/comprende"
8
+ config.author = "Evan Senter"
9
+ config.email = "evansenter@gmail.com"
10
+ config.ignore_pattern = ["tmp/*", "script/*"]
11
+ config.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |task| load task }
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{comprende}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Evan Senter"]
9
+ s.date = %q{2010-07-20}
10
+ s.description = %q{List comprehension support for Ruby}
11
+ s.email = %q{evansenter@gmail.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/comprende.rb", "lib/comprende/array.rb", "lib/comprende/proc.rb", "lib/comprende/symbol.rb"]
13
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "comprende.gemspec", "lib/comprende.rb", "lib/comprende/array.rb", "lib/comprende/proc.rb", "lib/comprende/symbol.rb"]
14
+ s.homepage = %q{http://github.com/evansenter/comprende}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Comprende", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{comprende}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{List comprehension support for Ruby}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), "comprende", "array")
2
+ require File.join(File.dirname(__FILE__), "comprende", "proc")
3
+ require File.join(File.dirname(__FILE__), "comprende", "symbol")
@@ -0,0 +1,17 @@
1
+ class Array
2
+ def combinations
3
+ self.class.combinate(self, [], [])
4
+ end
5
+
6
+ def self.combinate(collection, list, results)
7
+ results.tap do
8
+ unless collection.empty?
9
+ collection.first.each do |value|
10
+ combinate(collection[1..-1], list + [value], results)
11
+ end
12
+ else
13
+ results << list
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ class Proc
2
+ def filter(*collections, &action)
3
+ collections.combinations.select { |list| self[*list] }.map do |list|
4
+ action ? action[*list] : collections.size == 1 ? list.first : list
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class Symbol
2
+ def filter(*collections, &action)
3
+ to_proc.filter(*collections, &action)
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: comprende
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Evan Senter
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-20 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: List comprehension support for Ruby
23
+ email: evansenter@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ - lib/comprende.rb
31
+ - lib/comprende/array.rb
32
+ - lib/comprende/proc.rb
33
+ - lib/comprende/symbol.rb
34
+ files:
35
+ - Manifest
36
+ - README.rdoc
37
+ - Rakefile
38
+ - comprende.gemspec
39
+ - lib/comprende.rb
40
+ - lib/comprende/array.rb
41
+ - lib/comprende/proc.rb
42
+ - lib/comprende/symbol.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/evansenter/comprende
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --line-numbers
50
+ - --inline-source
51
+ - --title
52
+ - Comprende
53
+ - --main
54
+ - README.rdoc
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 11
72
+ segments:
73
+ - 1
74
+ - 2
75
+ version: "1.2"
76
+ requirements: []
77
+
78
+ rubyforge_project: comprende
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: List comprehension support for Ruby
83
+ test_files: []
84
+