piggly-nsd 2.3.3
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 +7 -0
- data/README.md +170 -0
- data/Rakefile +33 -0
- data/bin/piggly +8 -0
- data/lib/piggly/command/base.rb +148 -0
- data/lib/piggly/command/report.rb +162 -0
- data/lib/piggly/command/trace.rb +90 -0
- data/lib/piggly/command/untrace.rb +78 -0
- data/lib/piggly/command.rb +8 -0
- data/lib/piggly/compiler/cache_dir.rb +119 -0
- data/lib/piggly/compiler/coverage_report.rb +63 -0
- data/lib/piggly/compiler/trace_compiler.rb +117 -0
- data/lib/piggly/compiler.rb +7 -0
- data/lib/piggly/config.rb +80 -0
- data/lib/piggly/dumper/index.rb +121 -0
- data/lib/piggly/dumper/qualified_name.rb +36 -0
- data/lib/piggly/dumper/qualified_type.rb +141 -0
- data/lib/piggly/dumper/reified_procedure.rb +172 -0
- data/lib/piggly/dumper/skeleton_procedure.rb +112 -0
- data/lib/piggly/dumper.rb +9 -0
- data/lib/piggly/installer.rb +137 -0
- data/lib/piggly/parser/grammar.tt +748 -0
- data/lib/piggly/parser/nodes.rb +378 -0
- data/lib/piggly/parser/traversal.rb +50 -0
- data/lib/piggly/parser/treetop_ruby19_patch.rb +21 -0
- data/lib/piggly/parser.rb +69 -0
- data/lib/piggly/profile.rb +108 -0
- data/lib/piggly/reporter/base.rb +106 -0
- data/lib/piggly/reporter/html_dsl.rb +63 -0
- data/lib/piggly/reporter/index.rb +114 -0
- data/lib/piggly/reporter/procedure.rb +129 -0
- data/lib/piggly/reporter/resources/highlight.js +38 -0
- data/lib/piggly/reporter/resources/piggly.css +515 -0
- data/lib/piggly/reporter/resources/sortable.js +493 -0
- data/lib/piggly/reporter.rb +8 -0
- data/lib/piggly/tags.rb +280 -0
- data/lib/piggly/task.rb +215 -0
- data/lib/piggly/util/blankslate.rb +114 -0
- data/lib/piggly/util/cacheable.rb +19 -0
- data/lib/piggly/util/enumerable.rb +44 -0
- data/lib/piggly/util/file.rb +17 -0
- data/lib/piggly/util/process_queue.rb +96 -0
- data/lib/piggly/util/thunk.rb +39 -0
- data/lib/piggly/util.rb +9 -0
- data/lib/piggly/version.rb +15 -0
- data/lib/piggly.rb +20 -0
- data/spec/examples/compiler/cacheable_spec.rb +190 -0
- data/spec/examples/compiler/report_spec.rb +25 -0
- data/spec/examples/compiler/trace_spec.rb +123 -0
- data/spec/examples/config_spec.rb +63 -0
- data/spec/examples/dumper/index_spec.rb +199 -0
- data/spec/examples/dumper/procedure_spec.rb +116 -0
- data/spec/examples/grammar/expression_spec.rb +302 -0
- data/spec/examples/grammar/statements/assignment_spec.rb +70 -0
- data/spec/examples/grammar/statements/declaration_spec.rb +21 -0
- data/spec/examples/grammar/statements/exception_spec.rb +78 -0
- data/spec/examples/grammar/statements/if_spec.rb +191 -0
- data/spec/examples/grammar/statements/loop_spec.rb +41 -0
- data/spec/examples/grammar/statements/sql_spec.rb +71 -0
- data/spec/examples/grammar/tokens/comment_spec.rb +58 -0
- data/spec/examples/grammar/tokens/datatype_spec.rb +58 -0
- data/spec/examples/grammar/tokens/identifier_spec.rb +74 -0
- data/spec/examples/grammar/tokens/keyword_spec.rb +44 -0
- data/spec/examples/grammar/tokens/label_spec.rb +40 -0
- data/spec/examples/grammar/tokens/literal_spec.rb +30 -0
- data/spec/examples/grammar/tokens/lval_spec.rb +50 -0
- data/spec/examples/grammar/tokens/number_spec.rb +34 -0
- data/spec/examples/grammar/tokens/sqlkeywords_spec.rb +45 -0
- data/spec/examples/grammar/tokens/string_spec.rb +54 -0
- data/spec/examples/grammar/tokens/whitespace_spec.rb +40 -0
- data/spec/examples/installer_spec.rb +59 -0
- data/spec/examples/parser/nodes_spec.rb +73 -0
- data/spec/examples/parser/traversal_spec.rb +14 -0
- data/spec/examples/parser_spec.rb +118 -0
- data/spec/examples/profile_spec.rb +153 -0
- data/spec/examples/reporter/html/dsl_spec.rb +0 -0
- data/spec/examples/reporter/html/index_spec.rb +0 -0
- data/spec/examples/reporter/html_spec.rb +1 -0
- data/spec/examples/reporter_spec.rb +0 -0
- data/spec/examples/tags_spec.rb +285 -0
- data/spec/examples/task_spec.rb +0 -0
- data/spec/examples/util/cacheable_spec.rb +41 -0
- data/spec/examples/util/enumerable_spec.rb +64 -0
- data/spec/examples/util/file_spec.rb +40 -0
- data/spec/examples/util/process_queue_spec.rb +16 -0
- data/spec/examples/util/thunk_spec.rb +59 -0
- data/spec/examples/version_spec.rb +0 -0
- data/spec/issues/007_spec.rb +25 -0
- data/spec/issues/008_spec.rb +73 -0
- data/spec/issues/018_spec.rb +25 -0
- data/spec/issues/028_spec.rb +48 -0
- data/spec/issues/032_spec.rb +98 -0
- data/spec/issues/036_spec.rb +41 -0
- data/spec/spec_helper.rb +312 -0
- data/spec/spec_suite.rb +5 -0
- metadata +162 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Piggly
|
|
4
|
+
describe "github issue #32" do
|
|
5
|
+
|
|
6
|
+
# note: both -r always subtracts and -s always adds
|
|
7
|
+
# from left-to-right.
|
|
8
|
+
#
|
|
9
|
+
# if the first filter is -s, then the set starts empty
|
|
10
|
+
# and -s adds to it.
|
|
11
|
+
#
|
|
12
|
+
# if the first filter is -r, then the set starts with
|
|
13
|
+
# all procedures and -r removes from it.
|
|
14
|
+
|
|
15
|
+
def result(args)
|
|
16
|
+
index = double("index", :procedures => [
|
|
17
|
+
double("public.a", :name => "public.a"),
|
|
18
|
+
double("public.b", :name => "public.b"),
|
|
19
|
+
double("public.c", :name => "public.c"),
|
|
20
|
+
double("public.d", :name => "public.d")])
|
|
21
|
+
config = Command::Trace.configure(args.dup)
|
|
22
|
+
result = Command::Trace.filter(config, index)
|
|
23
|
+
result.map(&:name).sort
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context "with one -s argument" do
|
|
27
|
+
let(:args) { %w(-s public.c) }
|
|
28
|
+
|
|
29
|
+
it "selects matching procs" do
|
|
30
|
+
result(args).should == ["public.c"]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with -s regular expression" do
|
|
35
|
+
let(:args) { %w(-s /public.[bcd]/) }
|
|
36
|
+
|
|
37
|
+
it "selects matching procs" do
|
|
38
|
+
result(args).should == [
|
|
39
|
+
"public.b",
|
|
40
|
+
"public.c",
|
|
41
|
+
"public.d"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "with two -s arguments" do
|
|
46
|
+
let(:args) { %w(-s public.b -s public.d) }
|
|
47
|
+
|
|
48
|
+
it "adds matching procs" do
|
|
49
|
+
result(args).should == [
|
|
50
|
+
"public.b",
|
|
51
|
+
"public.d"]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "with one -r argument" do
|
|
56
|
+
let(:args) { %w(-r public.c) }
|
|
57
|
+
|
|
58
|
+
it "rejects matching procs" do
|
|
59
|
+
result(args).should == [
|
|
60
|
+
"public.a",
|
|
61
|
+
"public.b",
|
|
62
|
+
"public.d"]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "with two -r arguments" do
|
|
67
|
+
let(:args) { %w(-r public.b -r public.d) }
|
|
68
|
+
|
|
69
|
+
it "subtracts rejected procs" do
|
|
70
|
+
result(args).should == [
|
|
71
|
+
"public.a",
|
|
72
|
+
"public.c"]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "with -s then -r" do
|
|
77
|
+
let(:args) { %w(-s /\.[abc]/ -r public.b -r public.d) }
|
|
78
|
+
|
|
79
|
+
it "-r removes from -s matches" do
|
|
80
|
+
result(args).should == [
|
|
81
|
+
"public.a",
|
|
82
|
+
"public.c"]
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context "with -r then -s" do
|
|
87
|
+
let(:args) { %w(-r /\.[bc]/ -s public.b -s public.a) }
|
|
88
|
+
|
|
89
|
+
it "-s adds to -r non-matches" do
|
|
90
|
+
result(args).should == [
|
|
91
|
+
"public.a",
|
|
92
|
+
"public.b",
|
|
93
|
+
"public.d"]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Piggly
|
|
4
|
+
describe "github issue #32" do
|
|
5
|
+
include GrammarHelper
|
|
6
|
+
|
|
7
|
+
it "can parse a GET DIAGNOSTICS statement" do
|
|
8
|
+
node = parse(:statement, "GET DIAGNOSTICS v_cnt = ROw_COUNT;")
|
|
9
|
+
node.should be_statement
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "can parse a procedure with GET DIAGNOSTICS" do
|
|
13
|
+
body = <<-SQL
|
|
14
|
+
DECLARE
|
|
15
|
+
v_cnt INTEGER;
|
|
16
|
+
BEGIN
|
|
17
|
+
INSERT INTO foo.foo_table(bar, barbar_fl, foofoo_fl, bazbaz_ts)
|
|
18
|
+
SELECT
|
|
19
|
+
a.zoorzoor_id,
|
|
20
|
+
b.zap_fl,
|
|
21
|
+
b.zip_fl,
|
|
22
|
+
current_timestamp
|
|
23
|
+
FROM unnest(p_baz) a
|
|
24
|
+
INNER JOIN foo.zimzam b
|
|
25
|
+
ON a.zoor_id = b.zoor_id
|
|
26
|
+
ON CONFLICT (bar)
|
|
27
|
+
DO UPDATE SET barbar_fl= excluded.barbar_fl, foofoo_fl= excluded.foofoo_fl, last_updt_ts=current_timestamp;
|
|
28
|
+
GET DIAGNOSTICS v_cnt = ROW_COUNT;
|
|
29
|
+
RAISE NOTICE Updated % bar stuffs', v_cnt;
|
|
30
|
+
RETURN v_cnt;
|
|
31
|
+
END;
|
|
32
|
+
SQL
|
|
33
|
+
|
|
34
|
+
node = parse(:start, body.strip.downcase)
|
|
35
|
+
node.count{|e| e.sql? }.should == 1
|
|
36
|
+
node.count{|e| Parser::Nodes::Raise === e }.should == 1
|
|
37
|
+
node.count{|e| Parser::Nodes::Return === e }.should == 1
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
require "rspec"
|
|
2
|
+
require "ostruct"
|
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/piggly")
|
|
4
|
+
|
|
5
|
+
# RSpec 3 configuration
|
|
6
|
+
RSpec.configure do |config|
|
|
7
|
+
# Enable both should and expect syntax during transition
|
|
8
|
+
config.expect_with :rspec do |expectations|
|
|
9
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
10
|
+
expectations.syntax = [:should, :expect]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
config.mock_with :rspec do |mocks|
|
|
14
|
+
mocks.verify_partial_doubles = true
|
|
15
|
+
mocks.syntax = [:should, :expect]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# load runtime dependencies
|
|
22
|
+
Piggly::Parser.parser
|
|
23
|
+
|
|
24
|
+
module Piggly
|
|
25
|
+
module GrammarHelper
|
|
26
|
+
|
|
27
|
+
COMMENTS = ["abc defghi", "abc -- abc", "quote's", "a 'str'"]
|
|
28
|
+
|
|
29
|
+
SQLWORDS = %w[select insert update delete drop alter commit set start]
|
|
30
|
+
|
|
31
|
+
KEYWORDS = %w[as := = alias begin by constant continue
|
|
32
|
+
cursor debug declare diagnostics else elsif elseif
|
|
33
|
+
end exception execute exit for from get if
|
|
34
|
+
in info insert into is log loop not notice
|
|
35
|
+
null or raise rename result_oid return
|
|
36
|
+
reverse row_count scroll strict then to type warning
|
|
37
|
+
when while]
|
|
38
|
+
|
|
39
|
+
def parse(root, input)
|
|
40
|
+
string = input.downcase
|
|
41
|
+
parser = Parser.parser
|
|
42
|
+
parser.root = root
|
|
43
|
+
parser.consume_all_input = true
|
|
44
|
+
parser.parse(string) or raise Parser::Failure, parser.failure_reason
|
|
45
|
+
ensure
|
|
46
|
+
string.replace input
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def parse_some(root, input)
|
|
50
|
+
string = input.downcase
|
|
51
|
+
parser = Parser.parser
|
|
52
|
+
parser.root = root
|
|
53
|
+
parser.consume_all_input = false
|
|
54
|
+
node = parser.parse(string)
|
|
55
|
+
raise Parser::Failure, parser.failure_reason unless node
|
|
56
|
+
return node, input[parser.index..-1]
|
|
57
|
+
ensure
|
|
58
|
+
string.replace input
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# mock NodeClass
|
|
63
|
+
class N < OpenStruct
|
|
64
|
+
# Constructs a terminal
|
|
65
|
+
def self.terminal(text, hash = {})
|
|
66
|
+
new({:text_value => text,
|
|
67
|
+
:terminal? => true}.update(hash))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.keyword(text)
|
|
71
|
+
terminal(text)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Create a tSpace node
|
|
75
|
+
def self.space(text = ' ')
|
|
76
|
+
terminal(text)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Constructs an inline tComment
|
|
80
|
+
def self.inline_comment(text)
|
|
81
|
+
terminal("/* #{text} */",
|
|
82
|
+
:content => text,
|
|
83
|
+
:elements => ['/*', " #{text} ", '*/'])
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Constructs a rest-of-the-line comment
|
|
87
|
+
def self.line_comment(text)
|
|
88
|
+
terminal("-- #{text}\n",
|
|
89
|
+
:content => text,
|
|
90
|
+
:elements => ['--', " #{text}", "\n"])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Constructs a stubNode
|
|
94
|
+
def self.stub
|
|
95
|
+
terminal("")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Constructs an expressionUntil-type node
|
|
99
|
+
def self.expr(code)
|
|
100
|
+
Node.new :head => ' ',
|
|
101
|
+
:expr => code,
|
|
102
|
+
:tail => ' ',
|
|
103
|
+
:elements => [:head, :expr, :tail]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Constructs a sequence (of statements usually)
|
|
107
|
+
def self.sequence(*elements)
|
|
108
|
+
Node.new :elements => elements
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Constructs BEGIN/END block or ELSE block
|
|
112
|
+
def self.block(declare, statements)
|
|
113
|
+
Node.new :bodySpace => ' ',
|
|
114
|
+
:bodyStub => stub,
|
|
115
|
+
:body => sequence(*statements),
|
|
116
|
+
:elements => [keyword('begin'), :bodySpace, :bodyStub, :body, keyword('end'), terminal(';')]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Construct a CASE with a match expression
|
|
120
|
+
def self.case(expression, *whens)
|
|
121
|
+
Node.new :expr => expr(expression),
|
|
122
|
+
:cases => whens,
|
|
123
|
+
:elements => [keyword('case'), space, :expr, :cases, keyword('end'), space, keyword('case'), terminal(';')]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Construct a CASE with no match expression
|
|
127
|
+
def self.cond(*whens)
|
|
128
|
+
Node.new :cases => whens,
|
|
129
|
+
:elements => [keyword('case'), space, :cases, keyword('end'), space, keyword('case'), terminal(';')]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Constructs a WHEN branch for a CASE with a match expression
|
|
133
|
+
def self.casewhen(pattern, *statements)
|
|
134
|
+
Node.new :condSpace => space,
|
|
135
|
+
:cond => expr(pattern),
|
|
136
|
+
:bodySpace => space,
|
|
137
|
+
:body => sequence(*statements),
|
|
138
|
+
:elements => [keyword('when'), :condSpace, :cond, keyword('then'), :bodySpace, :bodyStub, :body]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Constructs a WHEN branch for a CASE with no match expression
|
|
142
|
+
def self.condwhen(expression, *statements)
|
|
143
|
+
Node.new :condSpace => space,
|
|
144
|
+
:condStub => stub,
|
|
145
|
+
:cond => expr(expression),
|
|
146
|
+
:bodySpace => space,
|
|
147
|
+
:body => sequence(*statements),
|
|
148
|
+
:elements => [keyword('when'), :condSpace, :condStub, :cond, keyword('then'), :bodySpace, :bodyStub, :body]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Constructs an IF or ELSIF
|
|
152
|
+
def self.if(cond, body, other)
|
|
153
|
+
Node.new :condSpace => nil,
|
|
154
|
+
:condStub => stub,
|
|
155
|
+
:cond => expr(cond),
|
|
156
|
+
:bodySpace => ' ',
|
|
157
|
+
:bodyStub => stub,
|
|
158
|
+
:body => body,
|
|
159
|
+
:else => other,
|
|
160
|
+
:elements => [keyword('if'), :condSpace, :condStub, :cond, keyword('then'), :bodySpace, :body, :else, keyword('end'), space, keyword('if'), terminal(';')]
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Constructs an unconditional LOOP
|
|
164
|
+
def self.loop(*statements)
|
|
165
|
+
Node.new :bodySpace => space,
|
|
166
|
+
:bodyStub => stub,
|
|
167
|
+
:body => sequence(*statements),
|
|
168
|
+
:doneStub => stub,
|
|
169
|
+
:elements => [keyword('loop'), :bodySpace, :bodyStub, :body, :doneStub, keyword('end'), space, keyword('loop'), terminal(';'), :exitStub]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Constructs a WHILE loop
|
|
173
|
+
def self.while(condition, *statements)
|
|
174
|
+
Node.new :condSpace => space,
|
|
175
|
+
:condStub => stub,
|
|
176
|
+
:cond => expr(condition),
|
|
177
|
+
:bodySpace => space,
|
|
178
|
+
:bodyStub => stub,
|
|
179
|
+
:body => sequence(*statements),
|
|
180
|
+
:exitStub => stub,
|
|
181
|
+
:elements => [keyword('while'), :condSpace, :condStub, :cond, keyword('loop'), :bodySpace, :bodyStub, :body, keyword('end'), space, keyword('loop'), terminal(';')]
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Constructs a FOR loop
|
|
185
|
+
def self.for(idents, iterator, *statements)
|
|
186
|
+
Node.new :condSpace => space,
|
|
187
|
+
:cond => expr(iterator),
|
|
188
|
+
:bodySpace => space,
|
|
189
|
+
:bodyStub => stub,
|
|
190
|
+
:body => sequence(*statements),
|
|
191
|
+
:doneStub => stub,
|
|
192
|
+
:exitStub => stub,
|
|
193
|
+
:elements => [keyword('for'), space, idents, keyword('in'), :condSpace, :cond, keyword('loop'), :bodySpace, :bodyStub, :body, :doneStub, keyword('end'), space, keyword('loop'), terminal(';'), :exitStub]
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Constructs an EXIT statement
|
|
197
|
+
def self.exit(condition = nil)
|
|
198
|
+
if condition
|
|
199
|
+
Node.new :body => keyword('exit'),
|
|
200
|
+
:condSpace => space,
|
|
201
|
+
:condStub => stub,
|
|
202
|
+
:cond => expr(condition),
|
|
203
|
+
:elements => [:body, space, keyword('when'), :condSpace, :condStub, :cond, terminal(';')]
|
|
204
|
+
else
|
|
205
|
+
Node.new :bodyStub => stub,
|
|
206
|
+
:body => keyword('exit'),
|
|
207
|
+
:elements => [:bodyStub, :body, ';']
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Constructs a CONTINUE statement
|
|
212
|
+
def self.continue(condition = nil)
|
|
213
|
+
if condition
|
|
214
|
+
Node.new :body => keyword('continue'),
|
|
215
|
+
:condSpace => space,
|
|
216
|
+
:condStub => stub,
|
|
217
|
+
:cond => expr(condition),
|
|
218
|
+
:elements => [:body, space, keyword('when'), :condSpace, :condStub, :cond, terminal(';')]
|
|
219
|
+
else
|
|
220
|
+
Node.new :bodyStub => stub,
|
|
221
|
+
:body => keyword('exit'),
|
|
222
|
+
:elements => [:bodyStub, :body, ';']
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Constructs a RETURN statement
|
|
227
|
+
def self.return(value)
|
|
228
|
+
Node.new :bodyStub => stubNode,
|
|
229
|
+
:body => sequence(keyword('return'), expr(value)),
|
|
230
|
+
:elements => [:bodyStub, :body]
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Constructs a RAISE statement
|
|
234
|
+
def self.raise(level, message)
|
|
235
|
+
if level == 'exception'
|
|
236
|
+
Node.new :bodyStub => stubNode,
|
|
237
|
+
:body => sequence(keyword('raise'), space, keyword('exception'), space, expr(message), terminal(';')),
|
|
238
|
+
:elements => [:bodyStub, :body]
|
|
239
|
+
else
|
|
240
|
+
Node.new :elements => [keyword('raise'), space, keyword(level), space, expr(message), terminal(';')]
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
class Node < N
|
|
245
|
+
def initialize(hash)
|
|
246
|
+
if elements = hash[:elements]
|
|
247
|
+
elements.map!{|e| e.is_a?(Symbol) ? hash.fetch(e) : e }
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
super(hash)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def text_value
|
|
254
|
+
@text_value ||= elements.inject('') do |string, e|
|
|
255
|
+
string << e.text_value
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def initialize(hash)
|
|
261
|
+
super({:parent => nil,
|
|
262
|
+
:terminal? => false,
|
|
263
|
+
:expression? => false,
|
|
264
|
+
:branch? => false,
|
|
265
|
+
:block? => false,
|
|
266
|
+
:stub? => false,
|
|
267
|
+
:loop? => false,
|
|
268
|
+
:for? => false,
|
|
269
|
+
:while? => false,
|
|
270
|
+
:style => nil,
|
|
271
|
+
:sourceText => nil }.update(hash))
|
|
272
|
+
|
|
273
|
+
elements.each{|c| c.parent = self } if elements
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Recursively compute the byte-offsets within the source text
|
|
277
|
+
def interval(start=0)
|
|
278
|
+
@start ||= start
|
|
279
|
+
@stop ||= if terminal?
|
|
280
|
+
@start + text_value.size
|
|
281
|
+
else
|
|
282
|
+
# recursively compute intervals
|
|
283
|
+
elements.inject(@start) do |prev, e|
|
|
284
|
+
e.interval(prev).end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
@start...@stop
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def source_text
|
|
291
|
+
@source_text || text_value
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def tap
|
|
295
|
+
yield self
|
|
296
|
+
self
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
module Enumerable
|
|
302
|
+
def test_each
|
|
303
|
+
each do |o|
|
|
304
|
+
begin
|
|
305
|
+
yield o
|
|
306
|
+
rescue
|
|
307
|
+
$!.message << "; while evaluating #{o}"
|
|
308
|
+
raise
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
end
|
data/spec/spec_suite.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: piggly-nsd
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.3.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kvle Putnam
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: treetop
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 1.4.14
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 1.4.14
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: pg
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.18.4
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 0.18.4
|
|
40
|
+
description: PostgreSQL PL/pgSQL stored procedure code coverage (NSD fork)
|
|
41
|
+
email: putnam.kvle@gmail.com
|
|
42
|
+
executables:
|
|
43
|
+
- piggly
|
|
44
|
+
extensions: []
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- README.md
|
|
48
|
+
- Rakefile
|
|
49
|
+
- bin/piggly
|
|
50
|
+
- lib/piggly.rb
|
|
51
|
+
- lib/piggly/command.rb
|
|
52
|
+
- lib/piggly/command/base.rb
|
|
53
|
+
- lib/piggly/command/report.rb
|
|
54
|
+
- lib/piggly/command/trace.rb
|
|
55
|
+
- lib/piggly/command/untrace.rb
|
|
56
|
+
- lib/piggly/compiler.rb
|
|
57
|
+
- lib/piggly/compiler/cache_dir.rb
|
|
58
|
+
- lib/piggly/compiler/coverage_report.rb
|
|
59
|
+
- lib/piggly/compiler/trace_compiler.rb
|
|
60
|
+
- lib/piggly/config.rb
|
|
61
|
+
- lib/piggly/dumper.rb
|
|
62
|
+
- lib/piggly/dumper/index.rb
|
|
63
|
+
- lib/piggly/dumper/qualified_name.rb
|
|
64
|
+
- lib/piggly/dumper/qualified_type.rb
|
|
65
|
+
- lib/piggly/dumper/reified_procedure.rb
|
|
66
|
+
- lib/piggly/dumper/skeleton_procedure.rb
|
|
67
|
+
- lib/piggly/installer.rb
|
|
68
|
+
- lib/piggly/parser.rb
|
|
69
|
+
- lib/piggly/parser/grammar.tt
|
|
70
|
+
- lib/piggly/parser/nodes.rb
|
|
71
|
+
- lib/piggly/parser/traversal.rb
|
|
72
|
+
- lib/piggly/parser/treetop_ruby19_patch.rb
|
|
73
|
+
- lib/piggly/profile.rb
|
|
74
|
+
- lib/piggly/reporter.rb
|
|
75
|
+
- lib/piggly/reporter/base.rb
|
|
76
|
+
- lib/piggly/reporter/html_dsl.rb
|
|
77
|
+
- lib/piggly/reporter/index.rb
|
|
78
|
+
- lib/piggly/reporter/procedure.rb
|
|
79
|
+
- lib/piggly/reporter/resources/highlight.js
|
|
80
|
+
- lib/piggly/reporter/resources/piggly.css
|
|
81
|
+
- lib/piggly/reporter/resources/sortable.js
|
|
82
|
+
- lib/piggly/tags.rb
|
|
83
|
+
- lib/piggly/task.rb
|
|
84
|
+
- lib/piggly/util.rb
|
|
85
|
+
- lib/piggly/util/blankslate.rb
|
|
86
|
+
- lib/piggly/util/cacheable.rb
|
|
87
|
+
- lib/piggly/util/enumerable.rb
|
|
88
|
+
- lib/piggly/util/file.rb
|
|
89
|
+
- lib/piggly/util/process_queue.rb
|
|
90
|
+
- lib/piggly/util/thunk.rb
|
|
91
|
+
- lib/piggly/version.rb
|
|
92
|
+
- spec/examples/compiler/cacheable_spec.rb
|
|
93
|
+
- spec/examples/compiler/report_spec.rb
|
|
94
|
+
- spec/examples/compiler/trace_spec.rb
|
|
95
|
+
- spec/examples/config_spec.rb
|
|
96
|
+
- spec/examples/dumper/index_spec.rb
|
|
97
|
+
- spec/examples/dumper/procedure_spec.rb
|
|
98
|
+
- spec/examples/grammar/expression_spec.rb
|
|
99
|
+
- spec/examples/grammar/statements/assignment_spec.rb
|
|
100
|
+
- spec/examples/grammar/statements/declaration_spec.rb
|
|
101
|
+
- spec/examples/grammar/statements/exception_spec.rb
|
|
102
|
+
- spec/examples/grammar/statements/if_spec.rb
|
|
103
|
+
- spec/examples/grammar/statements/loop_spec.rb
|
|
104
|
+
- spec/examples/grammar/statements/sql_spec.rb
|
|
105
|
+
- spec/examples/grammar/tokens/comment_spec.rb
|
|
106
|
+
- spec/examples/grammar/tokens/datatype_spec.rb
|
|
107
|
+
- spec/examples/grammar/tokens/identifier_spec.rb
|
|
108
|
+
- spec/examples/grammar/tokens/keyword_spec.rb
|
|
109
|
+
- spec/examples/grammar/tokens/label_spec.rb
|
|
110
|
+
- spec/examples/grammar/tokens/literal_spec.rb
|
|
111
|
+
- spec/examples/grammar/tokens/lval_spec.rb
|
|
112
|
+
- spec/examples/grammar/tokens/number_spec.rb
|
|
113
|
+
- spec/examples/grammar/tokens/sqlkeywords_spec.rb
|
|
114
|
+
- spec/examples/grammar/tokens/string_spec.rb
|
|
115
|
+
- spec/examples/grammar/tokens/whitespace_spec.rb
|
|
116
|
+
- spec/examples/installer_spec.rb
|
|
117
|
+
- spec/examples/parser/nodes_spec.rb
|
|
118
|
+
- spec/examples/parser/traversal_spec.rb
|
|
119
|
+
- spec/examples/parser_spec.rb
|
|
120
|
+
- spec/examples/profile_spec.rb
|
|
121
|
+
- spec/examples/reporter/html/dsl_spec.rb
|
|
122
|
+
- spec/examples/reporter/html/index_spec.rb
|
|
123
|
+
- spec/examples/reporter/html_spec.rb
|
|
124
|
+
- spec/examples/reporter_spec.rb
|
|
125
|
+
- spec/examples/tags_spec.rb
|
|
126
|
+
- spec/examples/task_spec.rb
|
|
127
|
+
- spec/examples/util/cacheable_spec.rb
|
|
128
|
+
- spec/examples/util/enumerable_spec.rb
|
|
129
|
+
- spec/examples/util/file_spec.rb
|
|
130
|
+
- spec/examples/util/process_queue_spec.rb
|
|
131
|
+
- spec/examples/util/thunk_spec.rb
|
|
132
|
+
- spec/examples/version_spec.rb
|
|
133
|
+
- spec/issues/007_spec.rb
|
|
134
|
+
- spec/issues/008_spec.rb
|
|
135
|
+
- spec/issues/018_spec.rb
|
|
136
|
+
- spec/issues/028_spec.rb
|
|
137
|
+
- spec/issues/032_spec.rb
|
|
138
|
+
- spec/issues/036_spec.rb
|
|
139
|
+
- spec/spec_helper.rb
|
|
140
|
+
- spec/spec_suite.rb
|
|
141
|
+
homepage: https://github.com/sergeiboikov/piggly
|
|
142
|
+
licenses:
|
|
143
|
+
- BSD-2-Clause
|
|
144
|
+
metadata: {}
|
|
145
|
+
rdoc_options: []
|
|
146
|
+
require_paths:
|
|
147
|
+
- lib
|
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
|
+
requirements:
|
|
155
|
+
- - ">="
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: '0'
|
|
158
|
+
requirements: []
|
|
159
|
+
rubygems_version: 3.6.9
|
|
160
|
+
specification_version: 4
|
|
161
|
+
summary: PL/pgSQL code coverage tool (NSD fork)
|
|
162
|
+
test_files: []
|