sort_it_out 1.0.0 → 1.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.
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm use ruby-1.8.7-p302@sort_it_out --create
2
+ rvm info
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sort_it_out.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2, :all_on_start => true, :all_after_pass => false, :cli => '--color --format doc' do
2
+ watch( %r{^spec/.+_spec\.rb$} )
3
+ watch( %r{^lib/(.+)\.rb$} ) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch( 'spec/spec_helper.rb' ) { "spec" }
5
+ end
data/Rakefile CHANGED
@@ -1,49 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "sort_it_out"
8
- gem.summary = %Q{Easily apply sorting to your Rails controller actions.}
9
- gem.description = %Q{Easily apply sorting to your Rails controller actions.}
10
- gem.email = "jason@lookforwardenterprises.com"
11
- gem.homepage = "http://github.com/midas/sort_it_out"
12
- gem.authors = ["Jason Harrelson"]
13
- gem.add_development_dependency "rspec"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- if File.exist?('VERSION')
40
- version = File.read('VERSION')
41
- else
42
- version = ""
43
- end
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "sort_it_out #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
1
+ require "bundler/gem_tasks"
data/lib/sort_it_out.rb CHANGED
@@ -1,10 +1,12 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
-
4
- require 'sort_it_out/sortable.rb'
1
+ require "sort_it_out/version"
2
+ require 'sort_it_out/railtie' if /3\.\d+\.\d+.*/.match( Rails.version )
5
3
 
6
4
  module SortItOut
7
- VERSION = '1.0.0'
5
+
6
+ autoload :Sortable, 'sort_it_out/sortable'
7
+
8
8
  end
9
9
 
10
- ActionController::Base.send( :include, SortItOut::Sortable ) if defined?( ActionController::Base )
10
+ if /2\.\d+\.\d+.*/.match( Rails.version )
11
+ ActionController::Base.send( :include, SortItOut::Sortable ) if defined?( ActionController::Base )
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+
3
+ module SortItOut
4
+
5
+ class Railtie < ::Rails::Railtie
6
+
7
+ initializer "sort_it_out.initialize" do
8
+ ActionController::Base.send :include, SortItOut::Sortable
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -1,4 +1,5 @@
1
1
  module SortItOut
2
+
2
3
  module Sortable
3
4
 
4
5
  def self.included( base )
@@ -6,18 +7,21 @@ module SortItOut
6
7
  end
7
8
 
8
9
  module ActMethods
10
+
9
11
  def sortable( options={} )
10
12
  unless included_modules.include? InstanceMethods
11
13
  include InstanceMethods
12
14
  before_filter :resolve_sort
13
- class_inheritable_accessor :options
15
+ class_attribute :options
14
16
  end
15
17
 
16
18
  self.options = options
17
19
  end
20
+
18
21
  end
19
22
 
20
23
  module InstanceMethods
24
+
21
25
  def resolve_sort
22
26
  order = params[:order]
23
27
  unless order
@@ -33,7 +37,7 @@ module SortItOut
33
37
  @order = order.nil? ? "" : resolve_order_clause( order, params[:direction] )
34
38
  end
35
39
 
36
- protected
40
+ protected
37
41
 
38
42
  def resolve_order_clause( order, dir="ASC" )
39
43
  translated = self.options[:map][order.to_sym] unless self.options[:map].nil?
@@ -46,7 +50,9 @@ module SortItOut
46
50
  return "#{order.to_s} #{dir}"
47
51
  end
48
52
  end
53
+
49
54
  end
50
55
 
51
56
  end
52
- end
57
+
58
+ end
@@ -0,0 +1,3 @@
1
+ module SortItOut
2
+ VERSION = "1.1.0"
3
+ end
data/sort_it_out.gemspec CHANGED
@@ -1,57 +1,35 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sort_it_out/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{sort_it_out}
8
- s.version = "1.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jason Harrelson"]
12
- s.date = %q{2010-09-30}
6
+ s.name = "sort_it_out"
7
+ s.version = SortItOut::VERSION
8
+ s.authors = ["C. Jason Harrelson"]
9
+ s.email = ["jason@lookforwardenterprises.com"]
10
+ s.homepage = "https://github.com/midas/sort_it_out"
11
+ s.summary = %q{Easily apply sorting to your Rails controller actions.}
13
12
  s.description = %q{Easily apply sorting to your Rails controller actions.}
14
- s.email = %q{jason@lookforwardenterprises.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "Histroy.txt",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/sort_it_out.rb",
28
- "lib/sort_it_out/sortable.rb",
29
- "script/console",
30
- "sort_it_out.gemspec",
31
- "spec/sort_it_out_spec.rb",
32
- "spec/spec_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/midas/sort_it_out}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{Easily apply sorting to your Rails controller actions.}
39
- s.test_files = [
40
- "spec/sort_it_out_spec.rb",
41
- "spec/spec_helper.rb"
42
- ]
43
13
 
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
14
+ s.rubyforge_project = "sort_it_out"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
47
20
 
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rspec>, [">= 0"])
50
- else
51
- s.add_dependency(%q<rspec>, [">= 0"])
52
- end
53
- else
54
- s.add_dependency(%q<rspec>, [">= 0"])
21
+ %w(
22
+ gem-dandy
23
+ rspec
24
+ ruby-debug
25
+ guard
26
+ rb-fsevent
27
+ growl
28
+ guard-rspec
29
+ rake
30
+ ).each do |development_dependency|
31
+ s.add_development_dependency development_dependency
55
32
  end
56
- end
57
33
 
34
+ # s.add_runtime_dependency "rest-client"
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,23 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require 'bundler/setup'
2
+
3
3
  require 'sort_it_out'
4
- require 'spec'
5
- require 'spec/autorun'
6
4
 
7
- Spec::Runner.configure do |config|
8
-
5
+ RSpec.configure do |config|
6
+
7
+ config.mock_with :rspec
8
+
9
+ end
10
+
11
+ class Hash
12
+
13
+ # for excluding keys
14
+ def except(*exclusions)
15
+ self.reject { |key, value| exclusions.include? key.to_sym }
16
+ end
17
+
18
+ # for overriding keys
19
+ def with(overrides = {})
20
+ self.merge overrides
21
+ end
22
+
9
23
  end
metadata CHANGED
@@ -1,25 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sort_it_out
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
- - Jason Harrelson
13
+ - C. Jason Harrelson
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-30 00:00:00 -05:00
18
+ date: 2012-01-05 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: gem-dandy
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -32,36 +32,135 @@ dependencies:
32
32
  version: "0"
33
33
  type: :development
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: ruby-debug
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: guard
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rb-fsevent
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :development
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: growl
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :development
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: guard-rspec
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ type: :development
118
+ version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
120
+ name: rake
121
+ prerelease: false
122
+ requirement: &id008 !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ type: :development
132
+ version_requirements: *id008
35
133
  description: Easily apply sorting to your Rails controller actions.
36
- email: jason@lookforwardenterprises.com
134
+ email:
135
+ - jason@lookforwardenterprises.com
37
136
  executables: []
38
137
 
39
138
  extensions: []
40
139
 
41
- extra_rdoc_files:
42
- - LICENSE
43
- - README.rdoc
140
+ extra_rdoc_files: []
141
+
44
142
  files:
45
143
  - .document
46
144
  - .gitignore
47
- - Histroy.txt
145
+ - .rvmrc
146
+ - Gemfile
147
+ - Guardfile
48
148
  - LICENSE
49
149
  - README.rdoc
50
150
  - Rakefile
51
- - VERSION
52
151
  - lib/sort_it_out.rb
152
+ - lib/sort_it_out/railtie.rb
53
153
  - lib/sort_it_out/sortable.rb
54
- - script/console
154
+ - lib/sort_it_out/version.rb
55
155
  - sort_it_out.gemspec
56
- - spec/sort_it_out_spec.rb
57
156
  - spec/spec_helper.rb
58
157
  has_rdoc: true
59
- homepage: http://github.com/midas/sort_it_out
158
+ homepage: https://github.com/midas/sort_it_out
60
159
  licenses: []
61
160
 
62
161
  post_install_message:
63
- rdoc_options:
64
- - --charset=UTF-8
162
+ rdoc_options: []
163
+
65
164
  require_paths:
66
165
  - lib
67
166
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -84,11 +183,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
183
  version: "0"
85
184
  requirements: []
86
185
 
87
- rubyforge_project:
88
- rubygems_version: 1.3.7
186
+ rubyforge_project: sort_it_out
187
+ rubygems_version: 1.6.0
89
188
  signing_key:
90
189
  specification_version: 3
91
190
  summary: Easily apply sorting to your Rails controller actions.
92
191
  test_files:
93
- - spec/sort_it_out_spec.rb
94
192
  - spec/spec_helper.rb
data/Histroy.txt DELETED
@@ -1,19 +0,0 @@
1
- = 1.0.0 2010-09-30
2
-
3
- * Add default sort direction specification.
4
-
5
-
6
- = 0.9.2 2009-11-15
7
-
8
- * Added ability yo specify default sort as a string that is a SQL fragment.
9
-
10
-
11
- = 0.9.1 2009-11-15
12
-
13
- * Fixed bug when there is no mapping specified for sortable.
14
-
15
-
16
- = 0.9.0 2009-11-15
17
-
18
- * Ported from a lib in a project to this Gem.
19
- * No tests yet.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.0
data/script/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/sort_it_out.rb'}"
9
- puts "Loading sort_it_out gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "SortItOut" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end