gadget 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gadget.rb +45 -6
  3. data/lib/gadget/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81afaef3c2ab2c77023e0e8b89ecbf4b2f38795b
4
- data.tar.gz: 5e36fbf9faeaf870d7d9d9c4039d4fffe881d19c
3
+ metadata.gz: 4c4ee82ad59af21e41af87425042ad51394fd412
4
+ data.tar.gz: 80aa411a7b0e3cad37dcd6b27f88dd8e31a85e82
5
5
  SHA512:
6
- metadata.gz: a81e148597a096d48f7557ce50a51460faee9fea0bdf9ce43d98cc954417735b8cfbf7e2c697a49d7aeabaa7751584f591d6f5cbd9a7fc09e2f297ae6e368a10
7
- data.tar.gz: 70e7140504c889acd899be663c4e02a3ada4356d5843e8a2e74f745f098bb1b7d092f87a81d27dd3688d5405421e6166119f2bdb08cf7490d6b9e52e863ebb19
6
+ metadata.gz: 3bfca7af601de89b47c3111839ba5fcc88b7ca8d4b6721114fd29e4a25896147ac495372a280fef7901428d56c13211c097f993afd6b12b0a35bae5972f57125
7
+ data.tar.gz: 62dbac736ffa02902e9c4cf63183e79a9f83681e49cb0da8cee44b0736322152e526c5562765ae6ee63ceaf1bb833ee6571c995b600574bd20f33af6325fe2bf
@@ -17,7 +17,12 @@ module Gadget
17
17
 
18
18
  def self.tables(conn)
19
19
  rs = conn.exec("SELECT c.oid, t.tablename FROM pg_tables t INNER JOIN pg_class c ON c.relname=t.tablename WHERE t.schemaname='public' ORDER BY t.tablename")
20
- tuples = rs.reduce({}) { | h, row | h[row['tablename']] = { :oid => row['oid'] }; h }
20
+ tuples = rs.reduce({}) do | h, row |
21
+ h[row['tablename']] = {
22
+ :oid => row['oid'].to_i,
23
+ }
24
+ h
25
+ end
21
26
  rs.clear
22
27
  tuples
23
28
  end
@@ -36,7 +41,11 @@ WHERE a.attnum >= 0
36
41
  sql += " AND t.tablename = $1"
37
42
  rs = conn.exec_params(sql, [ tablename ])
38
43
  end
39
- tuples = rs.reduce({}) { | h, row | h[row['tablename']] ||= { :columns => [] }; h[row['tablename']][:columns] << row['attname']; h }
44
+ tuples = rs.reduce({}) do | h, row |
45
+ h[row['tablename']] ||= { :columns => [] }
46
+ h[row['tablename']][:columns] << row['attname']
47
+ h
48
+ end
40
49
  rs.clear
41
50
  tuples
42
51
  end
@@ -155,27 +164,57 @@ WHERE t.schemaname = 'public'
155
164
 
156
165
  def self.functions(conn)
157
166
  rs = conn.exec(<<-END_OF_SQL)
158
- SELECT p.oid, p.proname
167
+ SELECT p.oid, p.proname, p.proargtypes
159
168
  FROM pg_catalog.pg_proc p
160
169
  INNER JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
161
170
  WHERE n.nspname = 'public'
162
171
  END_OF_SQL
163
172
 
164
- tuples = rs.reduce({}) { | h, row | h[row['proname']] = { :oid => row['oid'] }; h }
173
+ tuples = rs.reduce({}) do | h, row |
174
+ h[row['proname']] = {
175
+ :oid => row['oid'].to_i,
176
+ :arg_types => row['proargtypes'].split(/\s+/).map(&:to_i),
177
+ }
178
+ h
179
+ end
165
180
  rs.clear
166
181
  tuples
167
182
  end
168
183
 
169
184
  def self.triggers(conn)
170
185
  rs = conn.exec(<<-END_OF_SQL)
171
- SELECT tg.oid, tg.tgname, t.tablename
186
+ SELECT tg.oid, tg.tgname, t.tablename, p.proname
172
187
  FROM pg_catalog.pg_trigger tg
173
188
  INNER JOIN pg_catalog.pg_class c ON tg.tgrelid = c.oid
174
189
  INNER JOIN pg_catalog.pg_tables t ON c.relname = t.tablename
190
+ INNER JOIN pg_catalog.pg_proc p ON tg.tgfoid = p.oid
175
191
  WHERE tg.tgconstrrelid = 0
176
192
  END_OF_SQL
177
193
 
178
- tuples = rs.reduce({}) { | h, row | h[row['tgname']] = { :oid => row['oid'], :tablename => row['tablename'] }; h }
194
+ tuples = rs.reduce({}) do | h, row |
195
+ h[row['tgname']] = {
196
+ :oid => row['oid'].to_i,
197
+ :tablename => row['tablename'],
198
+ :functionname => row['proname'],
199
+ }
200
+ h
201
+ end
202
+ rs.clear
203
+ tuples
204
+ end
205
+
206
+ def self.types(conn)
207
+ rs = conn.exec(<<-END_OF_SQL)
208
+ SELECT t.oid, t.typname
209
+ FROM pg_catalog.pg_type t
210
+ END_OF_SQL
211
+
212
+ tuples = rs.reduce({}) do | h, row |
213
+ h[row['typname']] = {
214
+ :oid => row['oid'].to_i,
215
+ }
216
+ h
217
+ end
179
218
  rs.clear
180
219
  tuples
181
220
  end
@@ -1,3 +1,3 @@
1
1
  module Gadget
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig S. Cottingham