pluck_all 2.3.0 → 2.3.1

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
  SHA256:
3
- metadata.gz: 8110917f9cdbc5689553a582ca517652c40f6ab9ad2e2c7b69ceeab11b99e35c
4
- data.tar.gz: cb8419df5c2b6461aff433c8feac9c75a4467aac54ac219150021effafe75d19
3
+ metadata.gz: 9205cb355255151e1f3140349018afe9e7b75384b9677541fba84fcc1d5d009e
4
+ data.tar.gz: 10a8c03b49c5791d8ee56ce05399bebc1b2105bff7a084a7ed7975a4b6b5170b
5
5
  SHA512:
6
- metadata.gz: 768898ce2eb79faea5f71222bb6264d0c5f84626f1aa2176d866cd6c79ad51593b13d91ff72a18023504fbba5889a24b800025c6362f69b1b311ca54a2bd3c76
7
- data.tar.gz: 352339db50465bab76df7aab4e558f5e112b4f5baf57988a4df78d59ed33b80492cbb8bb9ab6968e54373d9d2a742f6f8a6df6f1461af330026863cd9a0f22a2
6
+ metadata.gz: 94f7f7e97bb0ed041a5ebc507799b1343f57d8bce81906385a561c6d1ff8cbdf600d18a0d76a1e22931ec172d283cc1ee7fcd66e76c7b630178332ff396c41cf
7
+ data.tar.gz: a642c2d5f31471f4ee0180d478f34ed0413e02472e10f36ff65bbbfa6fd2dd77c3ef0b00172c3185c3c278e10b15273ca7fc07e6eb95ba41506299430ec4079c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v2.3.0](https://github.com/khiav223577/pluck_all/compare/v2.2.1...v2.3.0) 2021/06/10
4
+ - [#52](https://github.com/khiav223577/pluck_all/pull/52) Support `globalize` gem (@khiav223577)
5
+ - [#51](https://github.com/khiav223577/pluck_all/pull/51) Fix: broken test cases caused by `mimemagic` (@khiav223577)
6
+ - [#50](https://github.com/khiav223577/pluck_all/pull/50) Migrating from Travis CI to GitHub Actions (@khiav223577)
7
+ - [#49](https://github.com/khiav223577/pluck_all/pull/49) Fix: test files should not be included in coverage (@khiav223577)
8
+
3
9
  ### [v2.2.1](https://github.com/khiav223577/pluck_all/compare/v2.1.0...v2.2.1) 2020/12/29
4
10
  - [#48](https://github.com/khiav223577/pluck_all/pull/48) fix Rails 6.1 `map!` deprecation warning (@klausbadelt)
5
11
 
data/Rakefile CHANGED
@@ -1,22 +1,22 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- Rake::TestTask.new(:test_active_record) do |t|
11
- t.libs << 'test'
12
- t.libs << 'lib'
13
- t.test_files = FileList['test/active_record/**/*_test.rb']
14
- end
15
-
16
- Rake::TestTask.new(:test_mongoid) do |t|
17
- t.libs << 'test'
18
- t.libs << 'lib'
19
- t.test_files = FileList['test/mongoid/**/*_test.rb']
20
- end
21
-
22
- task default: :test
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ Rake::TestTask.new(:test_active_record) do |t|
11
+ t.libs << 'test'
12
+ t.libs << 'lib'
13
+ t.test_files = FileList['test/active_record/**/*_test.rb']
14
+ end
15
+
16
+ Rake::TestTask.new(:test_mongoid) do |t|
17
+ t.libs << 'test'
18
+ t.libs << 'lib'
19
+ t.test_files = FileList['test/mongoid/**/*_test.rb']
20
+ end
21
+
22
+ task default: :test
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'pluck_all'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pluck_all'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.0'
6
6
  gem 'activerecord', '~> 3.2.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.0'
6
6
  gem 'activerecord', '~> 4.2.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.0'
6
6
  gem 'activerecord', '~> 5.0.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.0'
6
6
  gem 'activerecord', '~> 5.1.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.3.0'
6
6
  gem 'activerecord', '~> 5.2.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.4.1'
6
6
  gem 'activerecord', '~> 6.0.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'sqlite3', '~> 1.4.1'
6
6
  gem 'activerecord', '~> 6.1.0'
7
+ gem 'rails_compatibility', '~> 0.0.7'
8
+
7
9
  gem 'carrierwave', '~> 0.11.0'
8
10
  gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
9
11
 
data/lib/pluck_all.rb CHANGED
@@ -1,3 +1,3 @@
1
- # frozen_string_literal: true
2
- require 'pluck_all/version'
3
- require 'pluck_all/hooks'
1
+ # frozen_string_literal: true
2
+ require 'pluck_all/version'
3
+ require 'pluck_all/hooks'
@@ -1,21 +1,21 @@
1
- module PluckAll
2
- class Hooks
3
- class << self
4
- def init
5
- require 'pluck_all/models/active_record_extension' if require_if_exists('active_record')
6
- require 'pluck_all/models/mongoid_extension' if require_if_exists('mongoid')
7
- end
8
-
9
- private
10
-
11
- def require_if_exists(path)
12
- require path
13
- return true
14
- rescue LoadError, Gem::LoadError
15
- return false
16
- end
17
- end
18
- end
19
- end
20
-
21
- PluckAll::Hooks.init
1
+ module PluckAll
2
+ class Hooks
3
+ class << self
4
+ def init
5
+ require 'pluck_all/models/active_record_extension' if require_if_exists('active_record')
6
+ require 'pluck_all/models/mongoid_extension' if require_if_exists('mongoid')
7
+ end
8
+
9
+ private
10
+
11
+ def require_if_exists(path)
12
+ require path
13
+ return true
14
+ rescue LoadError, Gem::LoadError
15
+ return false
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ PluckAll::Hooks.init
@@ -1,4 +1,6 @@
1
1
  require 'rails_compatibility/attribute_types'
2
+ require 'rails_compatibility/has_include'
3
+ require 'rails_compatibility/apply_join_dependency'
2
4
  require_relative 'patches/deserialize'
3
5
 
4
6
  class ActiveRecord::Relation
@@ -51,11 +53,8 @@ class ActiveRecord::Relation
51
53
  end
52
54
  else
53
55
  def pluck_all(*column_names, cast_uploader_url: true)
54
- if has_include?(column_names.first)
55
- # The `construct_relation_for_association_calculations` method was removed at Rails 5.2.
56
- relation = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.2.0') ? apply_join_dependency : construct_relation_for_association_calculations
57
- return relation.pluck_all(*column_names)
58
- end
56
+ has_include = RailsCompatibility.has_include?(self, column_names.first)
57
+ return RailsCompatibility.apply_join_dependency(self).pluck_all(*column_names) if has_include
59
58
 
60
59
  result = select_all(column_names)
61
60
  attribute_types = RailsCompatibility.attribute_types(klass)
@@ -1,70 +1,70 @@
1
- # frozen_string_literal: true
2
- module Mongoid
3
- module Document::ClassMethods
4
- def pluck_array(*fields)
5
- where(nil).pluck_array(*fields)
6
- end
7
-
8
- def pluck_all(*fields)
9
- where(nil).pluck_all(*fields)
10
- end
11
- end
12
-
13
- module Findable
14
- delegate :pluck_all, :pluck_array, to: :with_default_scope
15
- end
16
-
17
- module Contextual
18
- delegate :pluck_all, :pluck_array, to: :context
19
-
20
- class None
21
- def pluck_array(*)
22
- []
23
- end
24
-
25
- def pluck_all(*)
26
- []
27
- end
28
- end
29
-
30
- class Mongo
31
- def pluck_array(*fields)
32
- normalized_select = get_normalized_select(fields)
33
- get_query_data(normalized_select).reduce([]) do |plucked, doc|
34
- values = normalized_select.keys.map(&plucked_value_mapper(:array, doc))
35
- plucked << (values.size == 1 ? values.first : values)
36
- end
37
- end
38
-
39
- def pluck_all(*fields)
40
- normalized_select = get_normalized_select(fields)
41
- get_query_data(normalized_select).reduce([]) do |plucked, doc|
42
- values = normalized_select.keys.map(&plucked_value_mapper(:all, doc))
43
- plucked << values.to_h
44
- end
45
- end
46
-
47
- private
48
-
49
- def plucked_value_mapper(type, doc)
50
- proc do |n|
51
- values = [n, n =~ /\./ ? doc[n.partition('.')[0]] : doc[n]]
52
- case type
53
- when :array then values[1]
54
- when :all then values
55
- end
56
- end
57
- end
58
-
59
- def get_query_data(normalized_select)
60
- return (@view ? @view.projection(normalized_select) : query.dup.select(normalized_select))
61
- end
62
-
63
- def get_normalized_select(fields)
64
- fields.each_with_object({}) do |f, hash|
65
- hash[klass.database_field_name(f)] = 1
66
- end
67
- end
68
- end
69
- end
70
- end
1
+ # frozen_string_literal: true
2
+ module Mongoid
3
+ module Document::ClassMethods
4
+ def pluck_array(*fields)
5
+ where(nil).pluck_array(*fields)
6
+ end
7
+
8
+ def pluck_all(*fields)
9
+ where(nil).pluck_all(*fields)
10
+ end
11
+ end
12
+
13
+ module Findable
14
+ delegate :pluck_all, :pluck_array, to: :with_default_scope
15
+ end
16
+
17
+ module Contextual
18
+ delegate :pluck_all, :pluck_array, to: :context
19
+
20
+ class None
21
+ def pluck_array(*)
22
+ []
23
+ end
24
+
25
+ def pluck_all(*)
26
+ []
27
+ end
28
+ end
29
+
30
+ class Mongo
31
+ def pluck_array(*fields)
32
+ normalized_select = get_normalized_select(fields)
33
+ get_query_data(normalized_select).reduce([]) do |plucked, doc|
34
+ values = normalized_select.keys.map(&plucked_value_mapper(:array, doc))
35
+ plucked << (values.size == 1 ? values.first : values)
36
+ end
37
+ end
38
+
39
+ def pluck_all(*fields)
40
+ normalized_select = get_normalized_select(fields)
41
+ get_query_data(normalized_select).reduce([]) do |plucked, doc|
42
+ values = normalized_select.keys.map(&plucked_value_mapper(:all, doc))
43
+ plucked << values.to_h
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def plucked_value_mapper(type, doc)
50
+ proc do |n|
51
+ values = [n, n =~ /\./ ? doc[n.partition('.')[0]] : doc[n]]
52
+ case type
53
+ when :array then values[1]
54
+ when :all then values
55
+ end
56
+ end
57
+ end
58
+
59
+ def get_query_data(normalized_select)
60
+ return (@view ? @view.projection(normalized_select) : query.dup.select(normalized_select))
61
+ end
62
+
63
+ def get_normalized_select(fields)
64
+ fields.each_with_object({}) do |f, hash|
65
+ hash[klass.database_field_name(f)] = 1
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,13 +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
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PluckAll
3
- VERSION = '2.3.0'
3
+ VERSION = '2.3.1'
4
4
  end
data/pluck_all.gemspec CHANGED
@@ -1,43 +1,43 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'pluck_all/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'pluck_all'
8
- spec.version = PluckAll::VERSION
9
- spec.authors = ['khiav reoy']
10
- spec.email = ['mrtmrt15xn@yahoo.com.tw']
11
-
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
-
17
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
- # delete this section to allow pushing this gem to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
- # else
22
- # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
- # end
24
-
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
- }
36
-
37
- spec.add_dependency 'activesupport', '>= 3.0.0'
38
- spec.add_dependency 'rails_compatibility', '>= 0.0.2'
39
-
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'
43
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pluck_all/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'pluck_all'
8
+ spec.version = PluckAll::VERSION
9
+ spec.authors = ['khiav reoy']
10
+ spec.email = ['mrtmrt15xn@yahoo.com.tw']
11
+
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
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
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
+ }
36
+
37
+ spec.add_dependency 'activesupport', '>= 3.0.0'
38
+ spec.add_dependency 'rails_compatibility', '>= 0.0.7'
39
+
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'
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluck_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.2
33
+ version: 0.0.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.2
40
+ version: 0.0.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement