activerecord-raw-data 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e6a04299fc4000c230a640a07ea0ced7af74422
|
4
|
+
data.tar.gz: ce9f59a27f67d55662de920f5f6004f98b81b446
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4570d705996b3507aa12185ad3a5c864527e0e7a13c67750ff7efe413b5bc3348f6e728f82cb42d09f950243182eb163b42ca2cbe00c617919796dd96a6f18fd
|
7
|
+
data.tar.gz: f6ac74b94f05bda6f4fbf78b72dcd11ebc083b4a4fb511abe783f31054c990f5396194ffa04494cd10f6c16d717133e28ddc6d1fcea7182186f8e78cb06df569
|
@@ -1,28 +1,32 @@
|
|
1
|
-
|
2
1
|
require 'active_record'
|
3
2
|
require 'activerecord-raw-data/version'
|
3
|
+
require 'activerecord-raw-data/compatibility_adapter'
|
4
4
|
|
5
5
|
module ActiveRecord
|
6
6
|
module RawData
|
7
|
+
mattr_accessor :adapter
|
8
|
+
|
7
9
|
def self.included(klass)
|
8
10
|
klass.extend(ClassMethods)
|
9
11
|
end
|
10
12
|
|
13
|
+
self.adapter = ActiveRecord::RawData::CompatibilityAdapter.new(ActiveRecord::VERSION::MAJOR)
|
14
|
+
|
11
15
|
module ClassMethods
|
12
16
|
def raw_data
|
13
|
-
connection.select_all
|
17
|
+
RawData.adapter.result_to_hash(connection.select_all RawData.adapter.blank_scope(self).to_sql)
|
14
18
|
end
|
15
19
|
|
16
20
|
def raw_rows
|
17
|
-
connection.select_rows
|
21
|
+
connection.select_rows RawData.adapter.blank_scope(self).to_sql
|
18
22
|
end
|
19
23
|
|
20
24
|
def raw_values
|
21
|
-
connection.select_values
|
25
|
+
connection.select_values RawData.adapter.blank_scope(self).to_sql
|
22
26
|
end
|
23
27
|
|
24
28
|
def raw_data_by_sql(sql)
|
25
|
-
connection.select_all sanitize_sql(sql)
|
29
|
+
RawData.adapter.result_to_hash(connection.select_all sanitize_sql(sql))
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module ActiveRecord
|
3
|
+
module RawData
|
4
|
+
class CompatibilityAdapter
|
5
|
+
def initialize(version)
|
6
|
+
@version = version
|
7
|
+
end
|
8
|
+
|
9
|
+
def ar4?
|
10
|
+
@version == 4
|
11
|
+
end
|
12
|
+
|
13
|
+
def blank_scope(klass)
|
14
|
+
ar4? ? klass.all : klass.scoped
|
15
|
+
end
|
16
|
+
|
17
|
+
def result_to_hash(result)
|
18
|
+
return result unless ar4?
|
19
|
+
|
20
|
+
result.to_hash
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -14,9 +14,9 @@ describe ActiveRecord::RawData do
|
|
14
14
|
|
15
15
|
it "should result raw data" do
|
16
16
|
User.raw_data.should eq [
|
17
|
-
{"id"=>
|
18
|
-
{"id"=>
|
19
|
-
{"id"=>
|
17
|
+
{"id"=> alice.id, "name"=>"alice", "mail"=>"alice@example.com"},
|
18
|
+
{"id"=> bob.id, "name"=>"bob", "mail"=>"bob@example.com"},
|
19
|
+
{"id"=> carol.id, "name"=>"carol", "mail"=>"carol@example.com"}
|
20
20
|
]
|
21
21
|
end
|
22
22
|
|
@@ -30,9 +30,9 @@ describe ActiveRecord::RawData do
|
|
30
30
|
|
31
31
|
it "should result raw rows" do
|
32
32
|
User.raw_rows.should eq [
|
33
|
-
[
|
34
|
-
[
|
35
|
-
[
|
33
|
+
[alice.id, "alice", "alice@example.com"],
|
34
|
+
[bob.id, "bob", "bob@example.com"],
|
35
|
+
[carol.id, "carol", "carol@example.com"]
|
36
36
|
]
|
37
37
|
end
|
38
38
|
|
@@ -44,9 +44,8 @@ describe ActiveRecord::RawData do
|
|
44
44
|
]
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
47
|
it "should result raw values" do
|
49
|
-
User.raw_values.should eq [
|
48
|
+
User.raw_values.should eq [alice.id, bob.id, carol.id]
|
50
49
|
end
|
51
50
|
|
52
51
|
it "should result raw values with select" do
|
metadata
CHANGED
@@ -1,82 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-raw-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Yuichi Tateno
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.8.0
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.0
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- - ~>
|
45
|
+
- - "~>"
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 2.8.0
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.8.0
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: pry
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: sqlite3
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: database_cleaner
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
|
-
- -
|
87
|
+
- - ">="
|
75
88
|
- !ruby/object:Gem::Version
|
76
89
|
version: '0'
|
77
90
|
type: :development
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
80
97
|
description: Get raw data from ActiveRecord
|
81
98
|
email:
|
82
99
|
- hotchpotch@gmail.com
|
@@ -84,47 +101,41 @@ executables: []
|
|
84
101
|
extensions: []
|
85
102
|
extra_rdoc_files: []
|
86
103
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
89
106
|
- Gemfile
|
90
107
|
- LICENSE
|
91
108
|
- README.md
|
92
109
|
- Rakefile
|
93
110
|
- activerecord-raw-data.gemspec
|
94
111
|
- lib/activerecord-raw-data.rb
|
112
|
+
- lib/activerecord-raw-data/compatibility_adapter.rb
|
95
113
|
- lib/activerecord-raw-data/version.rb
|
96
114
|
- spec/activerecord-raw-data_spec.rb
|
97
115
|
- spec/database.rb
|
98
116
|
- spec/spec_helper.rb
|
99
117
|
homepage: https://github.com/hotchpotch/activerecord-raw-data
|
100
118
|
licenses: []
|
119
|
+
metadata: {}
|
101
120
|
post_install_message:
|
102
121
|
rdoc_options: []
|
103
122
|
require_paths:
|
104
123
|
- lib
|
105
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
125
|
requirements:
|
108
|
-
- -
|
126
|
+
- - ">="
|
109
127
|
- !ruby/object:Gem::Version
|
110
128
|
version: '0'
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
hash: -243093227698944520
|
114
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
130
|
requirements:
|
117
|
-
- -
|
131
|
+
- - ">="
|
118
132
|
- !ruby/object:Gem::Version
|
119
133
|
version: '0'
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
hash: -243093227698944520
|
123
134
|
requirements: []
|
124
135
|
rubyforge_project:
|
125
|
-
rubygems_version:
|
136
|
+
rubygems_version: 2.4.5
|
126
137
|
signing_key:
|
127
|
-
specification_version:
|
138
|
+
specification_version: 4
|
128
139
|
summary: Get raw data from ActiveRecord
|
129
140
|
test_files:
|
130
141
|
- spec/activerecord-raw-data_spec.rb
|