deep_pluck 0.0.3 → 0.0.4

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: 44d38789b1249442a2a97cf7206309ce2a5125e3
4
- data.tar.gz: 5e07435ba363c3fbe2a325dc8cd1fec1791228b8
3
+ metadata.gz: f04ba29f0ba05add69bb0765e11b4c72541cb7a5
4
+ data.tar.gz: f5fe6993d0004478facd381dcbb851aeebe92d9d
5
5
  SHA512:
6
- metadata.gz: 44b321b33fdadcefd60a4d1b2319c8b03cb57cd2331888921f7082b830bc664a1d3d66e9533b0f0f12b70a7991b3da888aedb11e68e7532463604a7f5a6c66bc
7
- data.tar.gz: c28edcfd210948743d1e883f44d2e40f73db88ae92f05d8efd48e423006566e6c5903f3f255688e609438852a6306bec8725b13d968d636165a23aa8d827e128
6
+ metadata.gz: 801eb82d2d1340ab93f60006a6be0d44588afd00c4354ec309af5c3714bc3aba9cca4074e2d6072d4e9a508a0bd6bd264d66e5a01a12700589a42f177d247a89
7
+ data.tar.gz: 8e416508a72b631d70112e3f6ef527a23930dd1f0b9db332aec12f431e2e1bb26e690bc0cf8aaf094f7d734bcf60aa525656d39bf52030aa29cf12cbbb68d36d
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
+ # DeepPluck
2
+
1
3
  [![Gem Version](https://img.shields.io/gem/v/deep_pluck.svg?style=flat)](http://rubygems.org/gems/deep_pluck)
2
4
  [![Build Status](https://travis-ci.org/khiav223577/deep_pluck.svg?branch=master)](https://travis-ci.org/khiav223577/deep_pluck)
3
5
  [![RubyGems](http://img.shields.io/gem/dt/deep_pluck.svg?style=flat)](http://rubygems.org/gems/deep_pluck)
4
6
  [![Code Climate](https://codeclimate.com/github/khiav223577/deep_pluck/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/deep_pluck)
5
7
  [![Test Coverage](https://codeclimate.com/github/khiav223577/deep_pluck/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/deep_pluck/coverage)
6
8
 
7
- # DeepPluck
8
-
9
-
9
+ Use deep_pluck as a shortcut to select one or more attributes and include associated models without loading a bunch of records. And DRY up your code when using #as_json.
10
10
 
11
11
 
12
12
  ## Installation
data/deep_pluck.gemspec CHANGED
@@ -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{}
13
- spec.description = %q{}
12
+ spec.summary = %q{Use deep_pluck as a shortcut to select one or more attributes and include associated models without loading a bunch of records.}
13
+ spec.description = %q{Use deep_pluck as a shortcut to select one or more attributes and include associated models without loading a bunch of records. And DRY up your code when using #as_json.}
14
14
  spec.homepage = "https://github.com/khiav223577/deep_pluck"
15
15
  spec.license = "MIT"
16
16
 
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "minitest", "~> 5.0"
34
34
 
35
35
  spec.add_dependency "rails", ">= 3"
36
- spec.add_dependency "pluck_all", "~> 1.2.1"
36
+ spec.add_dependency "pluck_all", "~> 1.2.2"
37
37
 
38
38
  end
data/gemfiles/3.2.gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in pluck_all.gemspec
4
4
 
5
5
  gem "activerecord", "~> 3.2"
6
- gem "pluck_all", "~> 1.2.1"
6
+ gem "pluck_all", "~> 1.2.2"
7
7
 
8
8
  group :test do
9
9
  gem "simplecov"
data/gemfiles/4.2.gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in pluck_all.gemspec
4
4
 
5
5
  gem "activerecord", "~> 4.2"
6
- gem "pluck_all", "~> 1.2.1"
6
+ gem "pluck_all", "~> 1.2.2"
7
7
 
8
8
  group :test do
9
9
  gem "simplecov"
data/gemfiles/5.0.gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in pluck_all.gemspec
4
4
 
5
5
  gem "activerecord", "~> 5.0"
6
- gem "pluck_all", "~> 1.2.1"
6
+ gem "pluck_all", "~> 1.2.2"
7
7
 
8
8
  group :test do
9
9
  gem "simplecov"
@@ -79,11 +79,13 @@ module DeepPluck
79
79
  prev_need_columns = @parent_model.get_foreign_key(@parent_association_key, true) if @parent_model
80
80
  next_need_columns = @associations.map{|key, _| get_foreign_key(key) }.uniq
81
81
  all_need_columns = [*prev_need_columns, *next_need_columns, *@need_columns].uniq
82
- @extra_columns = all_need_columns - @need_columns
83
82
  @relation = yield(@relation) if block_given?
84
83
  @data = @relation.pluck_all(*all_need_columns)
85
- @associations.each do |key, model|
86
- set_includes_data(@data, key, model)
84
+ if @data.size != 0
85
+ @extra_columns = all_need_columns - @need_columns #for delete_extra_column_data!
86
+ @associations.each do |key, model|
87
+ set_includes_data(@data, key, model)
88
+ end
87
89
  end
88
90
  return @data
89
91
  end
@@ -93,7 +95,8 @@ module DeepPluck
93
95
  return @data
94
96
  end
95
97
  def delete_extra_column_data!
96
- @data.each{|s| s.except!(*@extra_columns) } if @data
98
+ return if @data.blank?
99
+ @data.each{|s| s.except!(*@extra_columns) }
97
100
  @associations.each{|_, model| model.delete_extra_column_data! }
98
101
  end
99
102
  end
@@ -1,3 +1,3 @@
1
1
  module DeepPluck
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_pluck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,15 +86,17 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2.1
89
+ version: 1.2.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2.1
97
- description: ''
96
+ version: 1.2.2
97
+ description: 'Use deep_pluck as a shortcut to select one or more attributes and include
98
+ associated models without loading a bunch of records. And DRY up your code when
99
+ using #as_json.'
98
100
  email:
99
101
  - mrtmrt15xn@yahoo.com.tw
100
102
  executables: []
@@ -139,5 +141,6 @@ rubyforge_project:
139
141
  rubygems_version: 2.6.8
140
142
  signing_key:
141
143
  specification_version: 4
142
- summary: ''
144
+ summary: Use deep_pluck as a shortcut to select one or more attributes and include
145
+ associated models without loading a bunch of records.
143
146
  test_files: []