relation_scope 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ 0.1.0
2
+ This plugin just for rails version 2.3.x with named scope module.
3
+ Include name scope methods: where, joins, includes, select, order, limit, offset, group, having
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.rdoc ADDED
@@ -0,0 +1,22 @@
1
+ == RelationScope
2
+
3
+ This plugin just for rails version 2.3.x with named scope module.
4
+ Include name scope methods: where, joins, includes, select, order, limit, offset, group, having
5
+
6
+
7
+ == Usage
8
+
9
+ User.order('created_at DESC').where(:name => 'test').limit(2) ...
10
+
11
+
12
+ == Install
13
+
14
+ git clone http://github.com/wenke/to_csv.git OR
15
+
16
+ ./script/plugin install git://github.com/wenke/relation_scope.git
17
+
18
+
19
+ == Note
20
+
21
+
22
+ Copyright (c) 2011 [liangwenke8@gmail.com], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the relation_scope plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the relation_scope plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'RelationScope'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README.rdoc')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'relation_scope'
@@ -0,0 +1,22 @@
1
+ # This plugin just for rails version 2.3.x with named scope module
2
+
3
+ module RelationScope
4
+ def self.included(base)
5
+ base.class_eval do
6
+ named_scope :where, lambda { |args|
7
+ conditions = args.is_a?(Hash) ? args.reject { |k, v| v.blank? } : args
8
+ { :conditions => conditions }
9
+ }
10
+ named_scope :joins, lambda { |joins| { :joins => joins } }
11
+ named_scope :includes, lambda { |includes| { :include => includes } }
12
+ named_scope :select, lambda { |select| { :select => select } }
13
+ named_scope :order, lambda { |order| { :order => order } }
14
+ named_scope :limit, lambda { |limit| { :limit => limit } }
15
+ named_scope :offset, lambda { |offset| { :offset => offset } }
16
+ named_scope :group, lambda { |group| { :group => group } }
17
+ named_scope :having, lambda { |having| { :having => having } }
18
+ end
19
+ end
20
+ end
21
+
22
+ ActiveRecord::Base.send(:include, RelationScope)
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :relation_scope do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relation_scope
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - LiangWenKe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-23 00:00:00 +08:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: This gem suppords some very nice named scope methods as rails 3 activerecord relation.
18
+ email: liangwenke8@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/relation_scope.rb
27
+ - lib/tasks/relation_scope_tasks.rake
28
+ - CHANGELOG
29
+ - MIT-LICENSE
30
+ - Rakefile
31
+ - README.rdoc
32
+ - VERSION
33
+ - init.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/wenke/relation_scope
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.4
55
+ requirements: []
56
+
57
+ rubyforge_project: relation_scope
58
+ rubygems_version: 1.6.2
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Suppords very nice named scope methods for rails 2.2.x, 2.3.x
62
+ test_files: []
63
+