find_with_order 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a10df154f2815483b1f228f293ef94ea868c1cab
4
- data.tar.gz: 591a63c1697d04270b68dbe2cc9f4caf94eda9fa
3
+ metadata.gz: bb63ce7cc3c9a7a3f40cc9a3654dff8341b83693
4
+ data.tar.gz: 92bed035a6036c6c8b8ef35fa7ef59962ce3f42c
5
5
  SHA512:
6
- metadata.gz: 6fc7409020a264264b5b6cb180a3ebe4d1528fe7a295b9181b98a6e7a91745eadb160f564dda67f2dc05425db7c88e6a319c032985382b3f192deb8877f167ec
7
- data.tar.gz: d55cc03ec45d0c75a2c06bf660b4a00ac038394edb8904ed167ad22d1648faddf06a7cf6b7cd8a65131e7967d06f6873f0456d46ac32955f5fc9e3768cfc06da
6
+ metadata.gz: 6f812bb289265d92ee0ee6b3cf49265b2e8de116e20001f0bedf25169665361c466fdd938182cc0e8b4b1784d5ed2b3bfd5359e684a27c482eb2af543f7e8f79
7
+ data.tar.gz: fee919bde9d1e21ba3e6a4921b1e2d6e4e266b1ab29aabc5c8881a18317b99142cb7b7fbb2ac6e5013c33d8fe2ec9a8c74639bf38de0167d0c4a3f614730d5c5
data/README.md CHANGED
@@ -26,6 +26,11 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
+ ### Find records in the same order of input IDs
30
+ ```rb
31
+ User.find_with_order([3, 1, 5]).map(&:id)
32
+ # => [3, 1, 5]
33
+ ```
29
34
 
30
35
  ## Development
31
36
 
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["khiav reoy"]
10
10
  spec.email = ["mrtmrt15xn@yahoo.com.tw"]
11
11
 
12
- spec.summary = %q{find and preserve the order}
13
- spec.description = %q{find and preserve the order}
12
+ spec.summary = %q{Find records in the same order of input IDs.}
13
+ spec.description = %q{Find records in the same order of input IDs. Supports Rails 3+.}
14
14
  spec.homepage = "https://github.com/khiav223577/find_with_order"
15
15
  spec.license = "MIT"
16
16
 
@@ -29,9 +29,9 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.11"
31
31
  spec.add_development_dependency "rake", "~> 12.0"
32
- spec.add_development_dependency "mysql2", "~> 0.3.21"
33
32
  spec.add_development_dependency "minitest", "~> 5.0"
34
33
 
35
34
  spec.add_dependency "rails", ">= 3"
35
+ spec.add_dependency "mysql2", ">= 0.3"
36
36
 
37
37
  end
data/gemfiles/3.2.gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gem "activerecord", "~> 3.2"
6
6
 
7
7
  group :test do
8
+ gem 'mysql2' , '0.3.21'
8
9
  gem "simplecov"
9
10
  gem "codeclimate-test-reporter", "~> 1.0.0"
10
11
  end
data/gemfiles/4.2.gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gem "activerecord", "~> 4.2"
6
6
 
7
7
  group :test do
8
+ gem 'mysql2' , '0.3.21'
8
9
  gem "simplecov"
9
10
  gem "codeclimate-test-reporter", "~> 1.0.0"
10
11
  end
data/gemfiles/5.0.gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gem "activerecord", "~> 5.0"
6
6
 
7
7
  group :test do
8
+ gem 'mysql2' , '0.3.21'
8
9
  gem "simplecov"
9
10
  gem "codeclimate-test-reporter", "~> 1.0.0"
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module FindWithOrder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -8,3 +8,10 @@ class << ActiveRecord::Base
8
8
  where(id: ids).order("field(id, #{ids.join(',')})")
9
9
  end
10
10
  end
11
+ unless ActiveRecord::Base.respond_to?(:none) # extend only if not implement yet
12
+ class ActiveRecord::Base
13
+ def self.none #For Rails 3
14
+ where('1=0')
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: find_with_order
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
@@ -39,48 +39,48 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: mysql2
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.21
47
+ version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.21
54
+ version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
62
- type: :development
61
+ version: '3'
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '3'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rails
70
+ name: mysql2
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3'
75
+ version: '0.3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3'
83
- description: find and preserve the order
82
+ version: '0.3'
83
+ description: Find records in the same order of input IDs. Supports Rails 3+.
84
84
  email:
85
85
  - mrtmrt15xn@yahoo.com.tw
86
86
  executables: []
@@ -124,5 +124,5 @@ rubyforge_project:
124
124
  rubygems_version: 2.6.8
125
125
  signing_key:
126
126
  specification_version: 4
127
- summary: find and preserve the order
127
+ summary: Find records in the same order of input IDs.
128
128
  test_files: []