pg-doc 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50222b07884abd889b86cc5cc645916e0c2f992a
4
- data.tar.gz: b49449f6ff9e3ac829231db3e4c5290e35f209c0
3
+ metadata.gz: edd4c08d6e5821b6faa98209653d65c20239881a
4
+ data.tar.gz: 8bcbf6a133bd04de380e7802c196ca65cf6b81d3
5
5
  SHA512:
6
- metadata.gz: aa70ad7c57bcff40d6bd6d0080760e354bdf13e3a9171ba7b69ef2278c3719b3f21f89cf7d4dd4d24ecf396c6fd6f78327d3f65f97be5605950b3484ce21df45
7
- data.tar.gz: 6775c5074e41bf81874bbf483bbab6bcc3e7f111485f79f26d0bfba45e56ae20170b4b69fd550ece99c88ea405be02a08fc1ca731ccb51590ff53f334d393ebc
6
+ metadata.gz: 6f5a640423d6e0f65b98f4fd375bb319f89781322a7a22656e6900725ba0076c22e54ee6174479d56ceef97bed7257bffbe74d195a3a2efcb5b0cbf7339cad63
7
+ data.tar.gz: 9c7f27cf75762c7c440fb4f64c9a6b4d2adad5231bdf143b516a55af37b0e65243d45e3a7b268d0f2d61d1105f7178935bc5d223570e0a0dcde63e720e3fd2ab
@@ -3,6 +3,7 @@ require "pg/doc/version"
3
3
  require "pg/doc/engine"
4
4
 
5
5
  require "base64"
6
+ require "cgi"
6
7
  require "mime-types"
7
8
  require "redcarpet"
8
9
 
@@ -67,7 +67,8 @@ module PG
67
67
  h[:schemas][row["schema_name"]] = {
68
68
  tables: {},
69
69
  views: {},
70
- functions: {}
70
+ functions: {},
71
+ triggers: {}
71
72
  }
72
73
  }
73
74
 
@@ -81,6 +82,7 @@ module PG
81
82
  information_schema.tables
82
83
  WHERE
83
84
  #{@schema_filter.call :table_schema}
85
+ AND table_type != 'VIEW'
84
86
  ORDER BY
85
87
  1, 2
86
88
  SQL
@@ -150,6 +152,8 @@ module PG
150
152
  routine_definition,
151
153
  external_language,
152
154
  pg_get_function_identity_arguments((routine_schema || '.' || routine_name)::regproc) as arguments,
155
+ pg_get_functiondef((routine_schema || '.' || routine_name)::regproc) as function_definition,
156
+ pg_get_function_result((routine_schema || '.' || routine_name)::regproc) as function_result,
153
157
  obj_description((routine_schema || '.' || routine_name)::regproc::oid, 'pg_proc') as comment
154
158
  FROM
155
159
  information_schema.routines
@@ -160,10 +164,13 @@ module PG
160
164
  1, 2
161
165
  SQL
162
166
  _recordset.each_with_object(@cache){ |row, h|
163
- h[:schemas][row["routine_schema"]][:functions][row["routine_name"]] = {
167
+ dest = row["function_result"] == "trigger" ? :triggers : :functions
168
+ h[:schemas][row["routine_schema"]][dest][row["routine_name"]] = {
164
169
  external_language: row["external_language"],
165
170
  comment: row["comment"],
166
- arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg }
171
+ arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg },
172
+ function_definition: row["function_definition"],
173
+ function_result: row["function_result"]
167
174
  }
168
175
  }
169
176
 
@@ -271,7 +278,7 @@ module PG
271
278
  type = arg
272
279
  end
273
280
 
274
- {name: name, type: type, mode: argmode}
281
+ {"name" => name, "type" => type, "mode" => argmode}
275
282
 
276
283
  end
277
284
 
@@ -1,5 +1,5 @@
1
1
  module PG
2
2
  module Doc
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- $(document).ready(() =>
1
+ $(document).ready(() => {
2
2
 
3
3
  // Toggles submenues in navigation
4
4
  $(document).on("click", ".js-submenu", (event) => {
@@ -6,4 +6,9 @@ $(document).ready(() =>
6
6
  $(event.currentTarget).next("DIV.menu").transition('toggle')
7
7
  })
8
8
 
9
- );
9
+ // Handles code highlighting
10
+ $('PRE').each((i, block) => {
11
+ hljs.highlightBlock(block)
12
+ })
13
+
14
+ });
@@ -34,7 +34,14 @@
34
34
  <% unless data[:functions].empty? %>
35
35
  <div class="subheader">Functions</div>
36
36
  <% data[:functions].each do |routine_name, routine| %>
37
- <a class="item" href="<%= url "/schemas/#{schema}/functions/#{routine_name}" %>"><span><i class="table icon"></i> <%= routine_name %></span></a>
37
+ <a class="item" href="<%= url "/schemas/#{schema}/functions/#{routine_name}" %>"><span><i class="code icon"></i> <%= routine_name %></span></a>
38
+ <% end %>
39
+ <% end %>
40
+
41
+ <% unless data[:triggers].empty? %>
42
+ <div class="subheader">Triggers</div>
43
+ <% data[:triggers].each do |routine_name, routine| %>
44
+ <a class="item" href="<%= url "/schemas/#{schema}/triggers/#{routine_name}" %>"><span><i class="lightning icon"></i> <%= routine_name %></span></a>
38
45
  <% end %>
39
46
  <% end %>
40
47
 
@@ -10,10 +10,13 @@
10
10
  <title>Database Documentation</title>
11
11
 
12
12
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
13
+ <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/foundation.min.css">
13
14
  <link rel="stylesheet" type="text/css" href="<%= url '/style.css' %>">
14
15
 
15
16
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
16
17
  <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
18
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
19
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/sql.min.js"></script>
17
20
  <script src="<%= url '/pg-doc.js' %>"></script>
18
21
 
19
22
  </head>
@@ -1 +1,33 @@
1
- <%= object %>
1
+ <h1>
2
+ <%= object[:external_language]%> Function - <code><%= params["schema"] %>.<%= params["name"] %></code>
3
+ </h1>
4
+
5
+ <% if object[:comment] %>
6
+ <h2>Description</h2>
7
+ <p><%= object[:comment] %></p>
8
+ <% end %>
9
+
10
+ <%= render_markdown "schema/#{params["schema"]}/functions/#{params["name"]}.md" %>
11
+
12
+ <h2>Function Arguments</h2>
13
+ <table class="ui compact fixed celled table">
14
+ <thead>
15
+ <th>Argument Name</th>
16
+ <th>Data Type</th>
17
+ <th>Argument Mode</th>
18
+ </thead>
19
+ <tbody>
20
+ <% object[:arguments].each do |row| %>
21
+ <tr>
22
+ <td><%= row["name"] %></td>
23
+ <td><%= row["type"] %></td>
24
+ <td><%= row["mode"] %></td>
25
+ </tr>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+
30
+ <% if object[:function_definition] %>
31
+ <h2>Function Definition</h2>
32
+ <pre class="ui segment sql"><%= CGI.escapeHTML object[:function_definition] %></pre>
33
+ <% end %>
@@ -14,7 +14,7 @@ end
14
14
  </h1>
15
15
 
16
16
  <% if object[:comment] %>
17
- <h2>Database Comment</h2>
17
+ <h2>Description</h2>
18
18
  <p><%= object[:comment] %></p>
19
19
  <% end %>
20
20
 
@@ -0,0 +1,15 @@
1
+ <h1>
2
+ <%= object[:external_language]%> Trigger - <code><%= params["schema"] %>.<%= params["name"] %></code>
3
+ </h1>
4
+
5
+ <% if object[:comment] %>
6
+ <h2>Description</h2>
7
+ <p><%= object[:comment] %></p>
8
+ <% end %>
9
+
10
+ <%= render_markdown "schema/#{params["schema"]}/triggers/#{params["name"]}.md" %>
11
+
12
+ <% if object[:function_definition] %>
13
+ <h2>Trigger Definition</h2>
14
+ <pre class="ui segment sql"><%= CGI.escapeHTML object[:function_definition] %></pre>
15
+ <% end %>
@@ -1 +1,33 @@
1
- <h2>Coming Soon!</h2>
1
+ <h1>
2
+ View - <code><%= params["schema"] %>.<%= params["name"] %></code>
3
+ </h1>
4
+
5
+ <% if object[:comment] %>
6
+ <h2>Description</h2>
7
+ <p><%= object[:comment] %></p>
8
+ <% end %>
9
+
10
+ <%= render_markdown "schema/#{params["schema"]}/views/#{params["name"]}.md" %>
11
+
12
+ <table class="ui compact fixed celled table">
13
+ <thead>
14
+ <th>Column Name</th>
15
+ <th>Data Type</th>
16
+ <th>Comment</th>
17
+ </thead>
18
+ <tbody>
19
+ <% object[:columns].each do |row| %>
20
+ <tr>
21
+ <td><%= row["column_name"] %></td>
22
+ <td><%= row["data_type"] %></td>
23
+ <td><%= row["comment"] %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <h2>View Definition</h2>
30
+
31
+ <pre class="ui segment sql">
32
+ <%= CGI.escapeHTML object[:view_definition] %>
33
+ </pre>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg-doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenaniah Cerny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -169,6 +169,7 @@ files:
169
169
  - views/objects/function.erb
170
170
  - views/objects/schema.erb
171
171
  - views/objects/table.erb
172
+ - views/objects/trigger.erb
172
173
  - views/objects/view.erb
173
174
  homepage: https://github.com/kenaniah/pg-doc
174
175
  licenses: