enumerable_mapper 0.5.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,63 @@
1
+ = enumerable_mapper
2
+
3
+ enumerable_mapper is a Ruby library that provides a shorthand for
4
+ simple .map/.collect calls on collections. Also supports grouping.
5
+
6
+ == Installation
7
+
8
+ Install from RubyForge:
9
+
10
+ sudo gem install enumerable_mapper
11
+
12
+ Install from GitHub:
13
+
14
+ gem sources -a http://gems.github.com
15
+ sudo gem install elektronaut-enumerable_mapper
16
+
17
+ == Usage
18
+
19
+ require 'enumerable_mapper'
20
+
21
+ # Collecting
22
+ people = Person.find(:all)
23
+ emails = people.collected.email # Equivalent of people.collect{|p| p.email}
24
+
25
+ # Grouping
26
+ people = Person.find(:all)
27
+ people_by_company = people.grouped_by(:company)
28
+ people_by_year = people.grouped_by{|p| p.born_on.year}
29
+
30
+ == API Documentation
31
+
32
+ Is available at http://enum-mapper.rubyforge.org
33
+
34
+ == Source code
35
+
36
+ Is available at http://github.com/elektronaut/enumerable_mapper
37
+
38
+ == Licence
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2007-2009 Inge Jørgensen
43
+
44
+ Permission is hereby granted, free of charge, to any person
45
+ obtaining a copy of this software and associated documentation
46
+ files (the "Software"), to deal in the Software without
47
+ restriction, including without limitation the rights to use,
48
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
49
+ copies of the Software, and to permit persons to whom the
50
+ Software is furnished to do so, subject to the following
51
+ conditions:
52
+
53
+ The above copyright notice and this permission notice shall be
54
+ included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
57
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
58
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
59
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
60
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
61
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
62
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
63
+ OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,4 +1,83 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
3
-
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "enumerable_mapper"
8
+ gem.summary = %Q{enumerable_mapper provides a shorthand for simple .map/.collect calls on collections}
9
+ gem.email = "inge@elektronaut.no"
10
+ gem.homepage = "http://github.com/elektronaut/enumerable_mapper"
11
+ gem.authors = ["Inge Jørgensen"]
12
+ gem.rubyforge_project = 'enum-mapper'
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ begin
41
+ require 'rake/contrib/sshpublisher'
42
+ namespace :rubyforge do
43
+
44
+ desc "Release gem and RDoc documentation to RubyForge"
45
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
46
+
47
+ namespace :release do
48
+ desc "Publish RDoc to RubyForge."
49
+ task :docs => [:rdoc] do
50
+ config = YAML.load(
51
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
52
+ )
53
+
54
+ host = "#{config['username']}@rubyforge.org"
55
+ remote_dir = "/var/www/gforge-projects/enum-mapper/"
56
+ local_dir = 'rdoc'
57
+
58
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
59
+ end
60
+ end
61
+ end
62
+ rescue LoadError
63
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
64
+ end
65
+
66
+ task :default => :test
67
+
68
+ require 'rake/rdoctask'
69
+ Rake::RDocTask.new do |rdoc|
70
+ if File.exist?('VERSION.yml')
71
+ config = YAML.load(File.read('VERSION.yml'))
72
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
73
+ else
74
+ version = ""
75
+ end
76
+
77
+ rdoc.rdoc_dir = 'rdoc'
78
+ rdoc.title = "vector2d #{version}"
79
+ rdoc.rdoc_files.include('README*')
80
+ rdoc.rdoc_files.include('lib/**/*.rb')
81
+ end
82
+
83
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -1,9 +1,5 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
- require 'enumerable_mapper/version'
4
-
5
- module EnumerableMapper; end
6
-
7
3
  module Enumerable
8
4
  # An Enumerable::Mapper object works as a proxy for a collection. Any method call
9
5
  # on the mapper will be routed to each of the members, and the results will be
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class EnumerableMapperTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
data/test/test_helper.rb CHANGED
@@ -1,2 +1,10 @@
1
+ require 'rubygems'
1
2
  require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/enumerable_mapper'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'vector2d'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata CHANGED
@@ -1,69 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: enumerable_mapper
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.5.5
7
- date: 2007-12-05 00:00:00 +01:00
8
- summary: This gem provides a shorthand for simple .map/.collect calls on collections.
9
- require_paths:
10
- - lib
11
- email: inge@elektronaut.no
12
- homepage: http://enum-mapper.rubyforge.org
13
- rubyforge_project: enum-mapper
14
- description: This gem provides a shorthand for simple .map/.collect calls on collections.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.0.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - "Inge J\xC3\xB8rgensen"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-20 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: inge@elektronaut.no
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
31
25
  files:
32
- - History.txt
33
- - License.txt
34
- - Manifest.txt
35
- - README.txt
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
36
30
  - Rakefile
37
- - config/hoe.rb
38
- - config/requirements.rb
31
+ - VERSION
39
32
  - lib/enumerable_mapper.rb
40
- - lib/enumerable_mapper/version.rb
41
- - log/debug.log
42
- - script/destroy
43
- - script/generate
44
- - setup.rb
45
- - tasks/deployment.rake
46
- - tasks/environment.rake
47
- - tasks/website.rake
48
- - test/test_enumerable_mapper.rb
49
- - test/test_helper.rb
50
- test_files:
51
- - test/test_enumerable_mapper.rb
52
- - test/test_grouped_by.rb
33
+ - test/enumerable_mapper_test.rb
53
34
  - test/test_helper.rb
35
+ has_rdoc: true
36
+ homepage: http://github.com/elektronaut/enumerable_mapper
37
+ post_install_message:
54
38
  rdoc_options:
55
- - --main
56
- - README.txt
57
- extra_rdoc_files:
58
- - History.txt
59
- - License.txt
60
- - Manifest.txt
61
- - README.txt
62
- executables: []
63
-
64
- extensions: []
65
-
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
66
54
  requirements: []
67
55
 
68
- dependencies: []
69
-
56
+ rubyforge_project: enum-mapper
57
+ rubygems_version: 1.3.1
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: enumerable_mapper provides a shorthand for simple .map/.collect calls on collections
61
+ test_files:
62
+ - test/enumerable_mapper_test.rb
63
+ - test/test_helper.rb
data/History.txt DELETED
@@ -1,3 +0,0 @@
1
- == 0.5.0 2007-08-29
2
-
3
- * First release!
data/Manifest.txt DELETED
@@ -1,18 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
- lib/enumerable_mapper.rb
9
- lib/enumerable_mapper/version.rb
10
- log/debug.log
11
- script/destroy
12
- script/generate
13
- setup.rb
14
- tasks/deployment.rake
15
- tasks/environment.rake
16
- tasks/website.rake
17
- test/test_enumerable_mapper.rb
18
- test/test_helper.rb
data/README.txt DELETED
@@ -1,28 +0,0 @@
1
- = enumerable_mapper
2
-
3
- This gem provides a shorthand for simple .map/.collect calls on collections.
4
-
5
- Example:
6
-
7
- Person.find(:all).collect{ |p| p.email }
8
-
9
- Could be written as:
10
-
11
- Person.find(:all).collected.email
12
-
13
- Of course, this works with arguments too:
14
-
15
- ["wow", "this", "is", "easy"].mapped.gsub('s','sh') # => ["wow", "thish", "ish", "eashy"]
16
-
17
- my_array.collected returns a Mapper object, which means you can do:
18
-
19
- collect = Person.find(:all).collected
20
- emails = collect.email
21
- names = collect.name
22
-
23
-
24
- = License
25
-
26
- enumerable_mapper is licensed under the MIT license.
27
-
28
- Copyright (c) 2007 Inge J�rgensen <inge@elektronaut.no>
data/config/hoe.rb DELETED
@@ -1,70 +0,0 @@
1
- require 'enumerable_mapper/version'
2
-
3
- AUTHOR = 'Inge Jørgensen' # can also be an array of Authors
4
- EMAIL = "inge@elektronaut.no"
5
- DESCRIPTION = "This gem provides a shorthand for simple .map/.collect calls on collections."
6
- GEM_NAME = 'enumerable_mapper' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'enum-mapper' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- RUBYFORGE_USERNAME = "elektronaut"
14
- def rubyforge_username
15
- unless @config
16
- begin
17
- @config = YAML.load(File.read(File.expand_path(@config_file)))
18
- rescue
19
- puts <<-EOS
20
- ERROR: No rubyforge config file found: #{@config_file}"
21
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
- - See http://newgem.rubyforge.org/rubyforge.html for more details
23
- EOS
24
- exit
25
- end
26
- end
27
- RUBYFORGE_USERNAME.replace @config["username"]
28
- end
29
-
30
-
31
- REV = nil
32
- # UNCOMMENT IF REQUIRED:
33
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
- VERS = EnumerableMapper::VERSION::STRING + (REV ? ".#{REV}" : "")
35
- RDOC_OPTS = ['--quiet', '--title', 'enumerable_mapper documentation',
36
- "--opname", "index.html",
37
- "--line-numbers",
38
- "--main", "README",
39
- "--inline-source"]
40
-
41
- class Hoe
42
- def extra_deps
43
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
- @extra_deps
45
- end
46
- end
47
-
48
- # Generate all the Rake tasks
49
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
- p.author = AUTHOR
52
- p.description = DESCRIPTION
53
- p.email = EMAIL
54
- p.summary = DESCRIPTION
55
- p.url = HOMEPATH
56
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
- p.test_globs = ["test/**/test_*.rb"]
58
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
-
60
- # == Optional
61
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
62
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
-
64
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
-
66
- end
67
-
68
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
69
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')