pluckex 0.0.2 → 0.0.3

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: 6959e79ec183204a0f4f8273d1f60841139dc8bc
4
- data.tar.gz: 8f3acaa30cf64ceffa57cdbbee46ed2dbcdf218b
3
+ metadata.gz: a8985a2797e08a17723fbfcff744ae983828ae45
4
+ data.tar.gz: 5dd2764db924e582f6d287f179437be308918991
5
5
  SHA512:
6
- metadata.gz: c7cf1a78f2954e87143ee259fede29f8410b9efd9b7a1571f89612bccb3b2434e38ec6ec1d75b7b9b4e2761d97fe0c735afbe5fa39460f2cd1b552c1af4474e7
7
- data.tar.gz: 9af8f5078f8f9e191a258674012efdc4f0fb1913f92d4fe60fa07fff27d83eac1ed0a094f0c1085f6aed8ffba3ccbba532fe82124b6c984c0ce7a7e73c0dfe9d
6
+ metadata.gz: 0f49af65d8733c74806fe7a430c487754058ec6ce7c4a0813ce65942402bc3fe0d8ab9b2eb274eeb409d0be48a53345edd3bc2bc9612e73d475d275af392392a
7
+ data.tar.gz: 5a8bec23611bc9f73dfcfbc250461773563e99d8cf684dd17c5092d78e315a34d50b2125556bc63edbb818597898fa644a657963738cd2fa7e1fa6fb5bf2deb0
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pluckex.gemspec
4
+ gemspec
@@ -1,4 +1,6 @@
1
- Copyright 2014 YOURNAME
1
+ Copyright (c) 2014 Daiki Taniguchi
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Pluckex
2
+
3
+ Pluckex add pluck-extended methods.
4
+
5
+ [ActiveRecord::Caluculations#pluck](http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-pluck).
6
+
7
+ Like this.
8
+
9
+ ### pluck_tied_by_id
10
+
11
+ ```
12
+ # Person.pluck_tied_by_id(:name)
13
+ # # => {1=>'David', 2=>'Jeremy', 3=>'Jose'}
14
+ ```
15
+ ### pluck_with_keys
16
+
17
+ ```
18
+ # Person.pluck_with_keys(:id, :name)
19
+ # # => [{:id=>1, :name=>'David'}, {:id=>2, :name=>'Jeremy'}, {:id=>3, :name=>'Jose'}]
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'pluckex'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Or install it yourself as:
35
+
36
+ $ gem install pluckex
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/[my-github-username]/pluckex/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,23 +1,7 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
6
3
 
7
- require 'rdoc/task'
4
+ RSpec::Core::RakeTask.new(:spec)
8
5
 
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Pluckex'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
-
22
- Bundler::GemHelper.install_tasks
6
+ task :default => :spec
23
7
 
@@ -0,0 +1,21 @@
1
+ module ActiveRecord
2
+ module Calculations
3
+ # Person.pluck_tied_by_id(:name)
4
+ # # => {1=>'David', 2=>'Jeremy', 3=>'Jose'}
5
+ def pluck_tied_by_id(col_name)
6
+ col_names = [:id] << col_name
7
+ Hash[*self.pluck(*col_names).flatten]
8
+ end
9
+
10
+ # Person.pluck_with_keys(:id, :name)
11
+ # # => [{:id=>1, :name=>'David'}, {:id=>2, :name=>'Jeremy'}, {:id=>3, :name=>'Jose'}]
12
+ def pluck_with_keys(*col_names)
13
+ self.pluck(*col_names).map do |element|
14
+ hash = {}
15
+ col_names.map.with_index do |col, i|
16
+ hash.merge!(col => element[i])
17
+ end.uniq
18
+ end.flatten
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Pluckex
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/pluckex.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "pluckex/engine"
2
- require "active_record_extension"
1
+ require "pluckex/version"
2
+ require "pluckex/active_record/relation/calculations"
3
3
 
4
4
  module Pluckex
5
5
  end
data/pluckex.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pluckex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pluckex"
8
+ spec.version = Pluckex::VERSION
9
+ spec.authors = ["Daiki Taniguchi"]
10
+ spec.email = ["daiki.taniguchi@aktsk.jp"]
11
+ spec.summary = %q{Pluckex.}
12
+ spec.description = %q{Pluckex!}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pluckex do
4
+ it 'has a version number' do
5
+ expect(Pluckex::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pluckex'
metadata CHANGED
@@ -1,44 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluckex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - kidachi_
7
+ - Daiki Taniguchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - '>='
18
46
  - !ruby/object:Gem::Version
19
- version: 4.0.0
20
- type: :runtime
47
+ version: '0'
48
+ type: :development
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
52
  - - '>='
25
53
  - !ruby/object:Gem::Version
26
- version: 4.0.0
54
+ version: '0'
27
55
  description: Pluckex!
28
56
  email:
29
- - t.daiki50@gmail.com
57
+ - daiki.taniguchi@aktsk.jp
30
58
  executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
- - MIT-LICENSE
62
+ - .gitignore
63
+ - .rspec
64
+ - .travis.yml
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
35
68
  - Rakefile
36
- - config/routes.rb
37
- - lib/active_record_extension.rb
38
69
  - lib/pluckex.rb
39
- - lib/pluckex/engine.rb
70
+ - lib/pluckex/active_record/relation/calculations.rb
40
71
  - lib/pluckex/version.rb
41
- - lib/tasks/pluckex_tasks.rake
72
+ - pluckex.gemspec
73
+ - spec/pluckex_spec.rb
74
+ - spec/spec_helper.rb
42
75
  homepage: ''
43
76
  licenses:
44
77
  - MIT
@@ -62,5 +95,8 @@ rubyforge_project:
62
95
  rubygems_version: 2.4.1
63
96
  signing_key:
64
97
  specification_version: 4
65
- summary: Pluckex
66
- test_files: []
98
+ summary: Pluckex.
99
+ test_files:
100
+ - spec/pluckex_spec.rb
101
+ - spec/spec_helper.rb
102
+ has_rdoc:
data/config/routes.rb DELETED
@@ -1,2 +0,0 @@
1
- Rails.application.routes.draw do
2
- end
@@ -1,24 +0,0 @@
1
- # Extensions for ActiveRecord.
2
- module ActiveRecord
3
- class Base
4
- class << self
5
- # Person.pluck_tied_by_id(:name)
6
- # # => {1=>'David', 2=>'Jeremy', 3=>'Jose'}
7
- def pluck_tied_by_id(col_name)
8
- col_names = [:id] << col_name
9
- Hash[*self.pluck(*col_names).flatten]
10
- end
11
-
12
- # Person.pluck_with_keys(:id, :name)
13
- # # => [{:id=>1, :name=>'David'}, {:id=>2, :name=>'Jeremy'}, {:id=>3, :name=>'Jose'}]
14
- def pluck_with_keys(*col_names)
15
- self.pluck(*col_names).map do |element|
16
- hash = {}
17
- col_names.map.with_index do |col, i|
18
- hash.merge!(col => element[i])
19
- end.uniq
20
- end.flatten
21
- end
22
- end
23
- end
24
- end
@@ -1,4 +0,0 @@
1
- module Pluckex
2
- class Engine < ::Rails::Engine
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :pluckex do
3
- # # Task goes here
4
- # end