attributes_sort 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -15
  2. data/VERSION +1 -1
  3. data/lib/attributes_sort.rb +5 -5
  4. metadata +17 -4
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ begin
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
15
  end
16
+ Jeweler::GemcutterTasks.new
16
17
  rescue LoadError
17
18
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
19
  end
@@ -43,18 +44,3 @@ Rake::RDocTask.new do |rdoc|
43
44
  rdoc.rdoc_files.include('lib/**/*.rb')
44
45
  end
45
46
 
46
- begin
47
- require 'jeweler'
48
- Jeweler::Tasks.new do |gem|
49
- gem.name = "attributes_sort"
50
- gem.summary = "A slick way to sort a collection objects."
51
- gem.description = "Sort a collection of objects using one or more of the attributes of your object."
52
- gem.email = "karmenblake@gmail.com"
53
- gem.homepage = "http://github.com/kblake/attributes_sort"
54
- gem.authors = ["Karmen Blake"]
55
- end
56
- Jeweler::GemcutterTasks.new
57
- rescue LoadError
58
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
59
- end
60
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -2,11 +2,11 @@ module AttributesSort
2
2
  def self.included(receiver)
3
3
  receiver.instance_eval do
4
4
  def build_attributes(attributes)
5
- "[" + attributes.map!{|a| "object.#{a}"}.join(",") + "]"
5
+ "[" + attributes.map!{|attribute| "object.#{attribute}"}.join(",") + "]"
6
6
  end
7
7
 
8
- def do_attributes_sort(collection, options={})
9
- attributes = build_attributes(options[:sort_by])
8
+ def do_attributes_sort(collection, attributes)
9
+ attributes = build_attributes(attributes)
10
10
  collection.sort_by{|object| eval(attributes)}
11
11
  end
12
12
  end
@@ -19,9 +19,9 @@ module AttributesSort
19
19
  end
20
20
 
21
21
  def attr_sort(options = {})
22
- raise "You must pass in sort_by criteria" unless options[:sort_by]
22
+ raise "You must pass in sort_by criteria" unless attributes = options[:sort_by]
23
23
  begin
24
- class_type.do_attributes_sort(self, options)
24
+ class_type.do_attributes_sort(self, attributes)
25
25
  rescue NoMethodError
26
26
  raise "You must sort by an attribute that exists in the object that you are sorting"
27
27
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Karmen Blake
@@ -16,8 +16,21 @@ cert_chain: []
16
16
 
17
17
  date: 2010-03-23 00:00:00 -07:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
21
34
  description: Sort a collection of objects using one or more of the attributes of your object.
22
35
  email: karmenblake@gmail.com
23
36
  executables: []