pluckex 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: a8985a2797e08a17723fbfcff744ae983828ae45
4
- data.tar.gz: 5dd2764db924e582f6d287f179437be308918991
3
+ metadata.gz: c2687ada5f02845f7a2e8f6c4b5a229cc22f7cff
4
+ data.tar.gz: e69865d5537d47a09e84e6c152b93a53d5a58f64
5
5
  SHA512:
6
- metadata.gz: 0f49af65d8733c74806fe7a430c487754058ec6ce7c4a0813ce65942402bc3fe0d8ab9b2eb274eeb409d0be48a53345edd3bc2bc9612e73d475d275af392392a
7
- data.tar.gz: 5a8bec23611bc9f73dfcfbc250461773563e99d8cf684dd17c5092d78e315a34d50b2125556bc63edbb818597898fa644a657963738cd2fa7e1fa6fb5bf2deb0
6
+ metadata.gz: 59e6abb9f46f6189a0669303d38d4380f82e84c1d5bbf1441f8201c5542d20e9bd0b49ad520ccc71198d950f1d22e128bec07f84a7cfbcc5ecfa95fdd70c7824
7
+ data.tar.gz: 808126460bc9fbca57d40279d89989c4175d929f82eab07b90623688d554d1b373217a758f29bb672ae348ad53355b0b3186650033a0ffa1e80dc59baed27d8b
@@ -1,4 +1,4 @@
1
- module ActiveRecord
1
+ module Pluckex
2
2
  module Calculations
3
3
  # Person.pluck_tied_by_id(:name)
4
4
  # # => {1=>'David', 2=>'Jeremy', 3=>'Jose'}
@@ -1,3 +1,3 @@
1
1
  module Pluckex
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/pluckex.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "pluckex/version"
2
- require "pluckex/active_record/relation/calculations"
2
+ require "pluckex/calculations"
3
+ require 'active_record'
3
4
 
4
- module Pluckex
5
- end
5
+ ActiveRecord::Base.extend Pluckex::Calculations
data/pluckex.gemspec CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "sqlite3"
25
+ spec.add_development_dependency "activerecord"
24
26
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pluckex do
4
+ describe 'activerecord extention' do
5
+ let(:people) { Person.all }
6
+ describe 'pluck_tied_by_id' do
7
+ subject { Person.pluck_tied_by_id(:name) }
8
+ it do
9
+ expect(subject).to eq(
10
+ people.first.id => people.first.name,
11
+ people.second.id => people.second.name,
12
+ )
13
+ end
14
+ end
15
+ describe 'pluck_with_keys' do
16
+ subject { Person.pluck_with_keys(:id, :name) }
17
+ it do
18
+ expect(subject).to eq([
19
+ {:id => people.first.id, :name => people.first.name},
20
+ {:id => people.second.id, :name => people.second.name},
21
+ ])
22
+ end
23
+ end
24
+ end
25
+ end
Binary file
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,11 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'pluckex'
3
+
4
+ ActiveRecord::Base.establish_connection(
5
+ :adapter => "sqlite3",
6
+ :database => File.dirname(__FILE__) + "/pluckex.sqlite3"
7
+ )
8
+
9
+ load File.dirname(__FILE__) + '/support/schema.rb'
10
+ load File.dirname(__FILE__) + '/support/models.rb'
11
+ load File.dirname(__FILE__) + '/support/data.rb'
@@ -0,0 +1,2 @@
1
+ Person.create(:name => "kidach1", :age => 25)
2
+ Person.create(:name => "bob", :age => 27)
@@ -0,0 +1,2 @@
1
+ class Person < ActiveRecord::Base
2
+ end
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Schema.define do
2
+ self.verbose = false
3
+
4
+ create_table :people, :force => true do |t|
5
+ t.string :name
6
+ t.integer :age
7
+ t.timestamps
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluckex
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
  - Daiki Taniguchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-09 00:00:00.000000000 Z
11
+ date: 2014-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Pluckex!
56
84
  email:
57
85
  - daiki.taniguchi@aktsk.jp
@@ -67,11 +95,15 @@ files:
67
95
  - README.md
68
96
  - Rakefile
69
97
  - lib/pluckex.rb
70
- - lib/pluckex/active_record/relation/calculations.rb
98
+ - lib/pluckex/calculations.rb
71
99
  - lib/pluckex/version.rb
72
100
  - pluckex.gemspec
73
- - spec/pluckex_spec.rb
101
+ - spec/lib/pluckex_spec.rb
102
+ - spec/pluckex.sqlite3
74
103
  - spec/spec_helper.rb
104
+ - spec/support/data.rb
105
+ - spec/support/models.rb
106
+ - spec/support/schema.rb
75
107
  homepage: ''
76
108
  licenses:
77
109
  - MIT
@@ -97,6 +129,10 @@ signing_key:
97
129
  specification_version: 4
98
130
  summary: Pluckex.
99
131
  test_files:
100
- - spec/pluckex_spec.rb
132
+ - spec/lib/pluckex_spec.rb
133
+ - spec/pluckex.sqlite3
101
134
  - spec/spec_helper.rb
135
+ - spec/support/data.rb
136
+ - spec/support/models.rb
137
+ - spec/support/schema.rb
102
138
  has_rdoc:
data/spec/pluckex_spec.rb DELETED
@@ -1,11 +0,0 @@
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