pluck_all 2.0.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +101 -0
- data/.gitignore +10 -10
- data/.rubocop.yml +1227 -0
- data/CHANGELOG.md +73 -46
- data/CODE_OF_CONDUCT.md +48 -48
- data/LICENSE.txt +21 -21
- data/README.md +187 -130
- data/Rakefile +9 -9
- data/bin/console +3 -3
- data/bin/setup +8 -8
- data/gemfiles/active_record_32.gemfile +14 -14
- data/gemfiles/active_record_42.gemfile +16 -14
- data/gemfiles/active_record_50.gemfile +16 -14
- data/gemfiles/active_record_51.gemfile +16 -14
- data/gemfiles/active_record_52.gemfile +16 -14
- data/gemfiles/active_record_60.gemfile +16 -0
- data/gemfiles/active_record_61.gemfile +16 -0
- data/gemfiles/mongoid_54.gemfile +11 -12
- data/gemfiles/mongoid_64.gemfile +11 -12
- data/gemfiles/mongoid_70.gemfile +11 -12
- data/lib/pluck_all.rb +2 -3
- data/lib/pluck_all/hooks.rb +10 -10
- data/lib/pluck_all/models/active_record_extension.rb +139 -125
- data/lib/pluck_all/models/mongoid_extension.rb +2 -1
- data/lib/pluck_all/models/patches/deserialize.rb +13 -0
- data/lib/pluck_all/version.rb +4 -4
- data/pluck_all.gemspec +26 -18
- metadata +38 -10
- data/.travis.yml +0 -52
@@ -47,7 +47,7 @@ module Mongoid
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def plucked_value_mapper(type, doc)
|
50
|
-
|
50
|
+
proc do |n|
|
51
51
|
values = [n, n =~ /\./ ? doc[n.partition('.')[0]] : doc[n]]
|
52
52
|
case type
|
53
53
|
when :array then values[1]
|
@@ -55,6 +55,7 @@ module Mongoid
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
58
59
|
def get_query_data(normalized_select)
|
59
60
|
return (@view ? @view.projection(normalized_select) : query.dup.select(normalized_select))
|
60
61
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
[
|
3
|
+
*([Type::Value, Type::Integer, Type::Serialized] if defined?(Type::Value)),
|
4
|
+
*([Enum::EnumType] if defined?(Enum::EnumType)),
|
5
|
+
].each do |s|
|
6
|
+
s.class_eval do
|
7
|
+
if !method_defined?(:deserialize) && method_defined?(:type_cast_from_database)
|
8
|
+
# deserialize was changed to type_cast_from_database in Rails 5
|
9
|
+
alias_method :deserialize, :type_cast_from_database
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/pluck_all/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module PluckAll
|
3
|
-
VERSION = '2.0
|
4
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PluckAll
|
3
|
+
VERSION = '2.3.0'
|
4
|
+
end
|
data/pluck_all.gemspec
CHANGED
@@ -4,32 +4,40 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'pluck_all/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'pluck_all'
|
8
8
|
spec.version = PluckAll::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['khiav reoy']
|
10
|
+
spec.email = ['mrtmrt15xn@yahoo.com.tw']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = 'Pluck multiple columns/attributes and return array of hashes. Support Rails 3, 4, 5.'
|
13
|
+
spec.description = 'Pluck multiple columns/attributes and return array of hashes. Support Rails 3, 4, 5. If you have a Rails 3 project, and want to pluck not only one column, feel free to use this gem and no need to worry about upgrading to Rails 4, 5 in the future will break this.'
|
14
|
+
spec.homepage = 'https://github.com/khiav223577/pluck_all'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
18
|
# delete this section to allow pushing this gem to any host.
|
19
|
-
#if spec.respond_to?(:metadata)
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
20
|
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
#else
|
21
|
+
# else
|
22
22
|
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
#end
|
23
|
+
# end
|
24
24
|
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
26
|
-
spec.bindir =
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/})
|
28
|
-
spec.require_paths = [
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject{|f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}){|f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
spec.metadata = {
|
30
|
+
'homepage_uri' => 'https://github.com/khiav223577/pluck_all',
|
31
|
+
'changelog_uri' => 'https://github.com/khiav223577/pluck_all/blob/master/CHANGELOG.md',
|
32
|
+
'source_code_uri' => 'https://github.com/khiav223577/pluck_all',
|
33
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/pluck_all',
|
34
|
+
'bug_tracker_uri' => 'https://github.com/khiav223577/pluck_all/issues',
|
35
|
+
}
|
29
36
|
|
30
|
-
spec.add_dependency
|
37
|
+
spec.add_dependency 'activesupport', '>= 3.0.0'
|
38
|
+
spec.add_dependency 'rails_compatibility', '>= 0.0.2'
|
31
39
|
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
40
|
+
spec.add_development_dependency 'bundler', '>= 1.17', '< 3.x'
|
41
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
42
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
35
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluck_all
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,20 +24,40 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails_compatibility
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
47
|
+
version: '1.17'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.x
|
34
51
|
type: :development
|
35
52
|
prerelease: false
|
36
53
|
version_requirements: !ruby/object:Gem::Requirement
|
37
54
|
requirements:
|
38
|
-
- - "
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.17'
|
58
|
+
- - "<"
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
60
|
+
version: 3.x
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: rake
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,8 +96,9 @@ executables: []
|
|
76
96
|
extensions: []
|
77
97
|
extra_rdoc_files: []
|
78
98
|
files:
|
99
|
+
- ".github/workflows/ruby.yml"
|
79
100
|
- ".gitignore"
|
80
|
-
- ".
|
101
|
+
- ".rubocop.yml"
|
81
102
|
- CHANGELOG.md
|
82
103
|
- CODE_OF_CONDUCT.md
|
83
104
|
- LICENSE.txt
|
@@ -90,6 +111,8 @@ files:
|
|
90
111
|
- gemfiles/active_record_50.gemfile
|
91
112
|
- gemfiles/active_record_51.gemfile
|
92
113
|
- gemfiles/active_record_52.gemfile
|
114
|
+
- gemfiles/active_record_60.gemfile
|
115
|
+
- gemfiles/active_record_61.gemfile
|
93
116
|
- gemfiles/mongoid_54.gemfile
|
94
117
|
- gemfiles/mongoid_64.gemfile
|
95
118
|
- gemfiles/mongoid_70.gemfile
|
@@ -97,12 +120,18 @@ files:
|
|
97
120
|
- lib/pluck_all/hooks.rb
|
98
121
|
- lib/pluck_all/models/active_record_extension.rb
|
99
122
|
- lib/pluck_all/models/mongoid_extension.rb
|
123
|
+
- lib/pluck_all/models/patches/deserialize.rb
|
100
124
|
- lib/pluck_all/version.rb
|
101
125
|
- pluck_all.gemspec
|
102
126
|
homepage: https://github.com/khiav223577/pluck_all
|
103
127
|
licenses:
|
104
128
|
- MIT
|
105
|
-
metadata:
|
129
|
+
metadata:
|
130
|
+
homepage_uri: https://github.com/khiav223577/pluck_all
|
131
|
+
changelog_uri: https://github.com/khiav223577/pluck_all/blob/master/CHANGELOG.md
|
132
|
+
source_code_uri: https://github.com/khiav223577/pluck_all
|
133
|
+
documentation_uri: https://www.rubydoc.info/gems/pluck_all
|
134
|
+
bug_tracker_uri: https://github.com/khiav223577/pluck_all/issues
|
106
135
|
post_install_message:
|
107
136
|
rdoc_options: []
|
108
137
|
require_paths:
|
@@ -118,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
147
|
- !ruby/object:Gem::Version
|
119
148
|
version: '0'
|
120
149
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.6.13
|
150
|
+
rubygems_version: 3.2.14
|
123
151
|
signing_key:
|
124
152
|
specification_version: 4
|
125
153
|
summary: Pluck multiple columns/attributes and return array of hashes. Support Rails
|
data/.travis.yml
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
env:
|
3
|
-
global:
|
4
|
-
- CC_TEST_REPORTER_ID=db72eba1ff8fb1329dae5fb9b9dcd234243899d7a464ceb374e14a05ead27b7c
|
5
|
-
language: ruby
|
6
|
-
rvm:
|
7
|
-
- 2.2
|
8
|
-
- 2.3
|
9
|
-
services:
|
10
|
-
- mongodb
|
11
|
-
env:
|
12
|
-
- ORM_TYPE=ACTIVE_RECORD
|
13
|
-
- ORM_TYPE=MONGOID
|
14
|
-
gemfile:
|
15
|
-
- gemfiles/active_record_32.gemfile
|
16
|
-
- gemfiles/active_record_42.gemfile
|
17
|
-
- gemfiles/active_record_50.gemfile
|
18
|
-
- gemfiles/active_record_51.gemfile
|
19
|
-
- gemfiles/active_record_52.gemfile
|
20
|
-
- gemfiles/mongoid_54.gemfile
|
21
|
-
- gemfiles/mongoid_64.gemfile
|
22
|
-
- gemfiles/mongoid_70.gemfile
|
23
|
-
matrix:
|
24
|
-
exclude:
|
25
|
-
- gemfile: gemfiles/active_record_32.gemfile
|
26
|
-
env: ORM_TYPE=MONGOID
|
27
|
-
- gemfile: gemfiles/active_record_42.gemfile
|
28
|
-
env: ORM_TYPE=MONGOID
|
29
|
-
- gemfile: gemfiles/active_record_50.gemfile
|
30
|
-
env: ORM_TYPE=MONGOID
|
31
|
-
- gemfile: gemfiles/active_record_51.gemfile
|
32
|
-
env: ORM_TYPE=MONGOID
|
33
|
-
- gemfile: gemfiles/active_record_52.gemfile
|
34
|
-
env: ORM_TYPE=MONGOID
|
35
|
-
- gemfile: gemfiles/mongoid_54.gemfile
|
36
|
-
env: ORM_TYPE=ACTIVE_RECORD
|
37
|
-
- gemfile: gemfiles/mongoid_64.gemfile
|
38
|
-
env: ORM_TYPE=ACTIVE_RECORD
|
39
|
-
- gemfile: gemfiles/mongoid_70.gemfile
|
40
|
-
env: ORM_TYPE=ACTIVE_RECORD
|
41
|
-
before_install:
|
42
|
-
- gem install bundler
|
43
|
-
- gem update --system
|
44
|
-
- gem --version
|
45
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
46
|
-
- chmod +x ./cc-test-reporter
|
47
|
-
- ./cc-test-reporter before-build
|
48
|
-
script:
|
49
|
-
- if [ "$ORM_TYPE" = "ACTIVE_RECORD" ]; then bundle exec rake test_active_record; fi
|
50
|
-
- if [ "$ORM_TYPE" = "MONGOID" ]; then bundle exec rake test_mongoid; fi
|
51
|
-
after_script:
|
52
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|