piggly 2.2.1 → 2.2.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: 0aca5c86391dab9ddd1b0529e469c67f440ce9c8
4
- data.tar.gz: aa7ced6807ad226312f95fb428d6e1ea36aa6af4
3
+ metadata.gz: b7b807efe5c5d12d4a91d3be46379b423094471e
4
+ data.tar.gz: 733371c4f0c66f954ed0992b2084b48795fa4f61
5
5
  SHA512:
6
- metadata.gz: 9a77dc4124175df8e45f1223e0b46c3dee9bb2f8282f0552b61dcccf4dc5348da072a5c5672bb77656c05f1b4e29fc9d0e47392d7d90fcad3396539f5c782e3e
7
- data.tar.gz: 438b3ceb842971d0233eb16e9f41513b4494e50457e0bd8879f3aaa0858feeb4bf1ee11e17430b3b537f5c503e4a362deffa48b5a3739c24d38ca0f02536e7d2
6
+ metadata.gz: 6d545575f7e1a105b61be250cf8dcfd48748792d473e9737036265979449159a4c5f1f1d5862426c9da8508e2bfb127e545db52a4d1a85203edb2bc76dfdfdcb
7
+ data.tar.gz: ee79b0de1bce8668ad3e0354d2d132a7bc6d1a8f29446efa16c5a60b96a39a3257634d7b93dfb3823313f2595d036529c881480fa2d226ebc8f5887ce1a33f3c
data/README.md CHANGED
@@ -23,7 +23,7 @@ these events and generates prettified source code that is annotated with coverag
23
23
 
24
24
  ## Features
25
25
 
26
- * Readable and easily-navigable reports (see [example] [5])
26
+ * Readable and easily-navigable reports (see [example](http://kputnam.github.com/piggly/reports/index.html))
27
27
  * Language agnostic - write your tests in Ruby, Python, Java, SQL scripts etc
28
28
  * Branch, block, and loop coverage analysis
29
29
  * Instrumenting source-to-source compiler
@@ -39,8 +39,8 @@ these events and generates prettified source code that is annotated with coverag
39
39
 
40
40
  ## Requirements
41
41
 
42
- * [Treetop] [2]: `gem install treetop`
43
- * The [ruby-pg driver] [3]: `gem install pg`
42
+ * [Treetop](http://github.com/nathansobo/treetop): `gem install treetop`
43
+ * The [ruby-pg driver](http://bitbucket.org/ged/ruby-pg/): `gem install pg`
44
44
  * The examples require ActiveRecord: `gem install activerecord`
45
45
 
46
46
  ## How to Install
@@ -154,10 +154,4 @@ Once the report is built you can open it in `piggly/reports/index.html`.
154
154
 
155
155
  ## Bugs & Issues
156
156
 
157
- Please report any issues or feature requests on the [github tracker] [4].
158
-
159
- [1]: http://github.com/relevance/rcov/
160
- [2]: http://github.com/nathansobo/treetop
161
- [3]: http://bitbucket.org/ged/ruby-pg/
162
- [4]: http://github.com/kputnam/piggly/issues
163
- [5]: http://kputnam.github.com/piggly/reports/index.html
157
+ Please report any issues or feature requests on the [github tracker](http://github.com/kputnam/piggly/issues).
data/lib/piggly/config.rb CHANGED
@@ -56,6 +56,7 @@ module Piggly
56
56
  :filters
57
57
 
58
58
  alias accumulate? accumulate
59
+ alias dry_run? dry_run
59
60
 
60
61
  def path(*args)
61
62
  self.class.path(*args)
@@ -1,6 +1,26 @@
1
1
  module Piggly
2
2
  module Dumper
3
3
 
4
+ # used for RETURN TABLE(...)
5
+ class RecordType
6
+ attr_reader :types, :names, :modes, :defaults
7
+
8
+ def initialize(types, names, modes, defaults)
9
+ @types, @names, @modes, @defaults =
10
+ types, names, modes, defaults
11
+ end
12
+
13
+ def quote
14
+ "table (#{@types.zip(@names, @modes, @defaults).map do |type, name, mode, default|
15
+ "#{name.quote + " " if name}#{type.quote}#{" default " + default if default}"
16
+ end.join(", ")})"
17
+ end
18
+
19
+ def table?
20
+ true
21
+ end
22
+ end
23
+
4
24
  class QualifiedType
5
25
  attr_reader :schema, :name
6
26
 
@@ -36,6 +56,10 @@ module Piggly
36
56
  @schema, @name, @array = schema, name, array
37
57
  end
38
58
 
59
+ def table?
60
+ false
61
+ end
62
+
39
63
  def shorten
40
64
  self.class.new(nil, @name, @array)
41
65
  end
@@ -7,9 +7,20 @@ module Piggly
7
7
  #
8
8
  class ReifiedProcedure < SkeletonProcedure
9
9
 
10
- def initialize(source, *args)
11
- super(*args)
10
+ def initialize(source, oid, name, strict, secdef, setof, type, volatility, arg_modes, arg_names, arg_types, arg_defaults)
12
11
  @source = source.strip
12
+
13
+ if type.name == "record" and type.schema == "pg_catalog" and arg_modes.include?("t")
14
+ prefix = arg_modes.take_while{|m| m != "t" }.length
15
+ type = RecordType.new(arg_types[prefix..-1], arg_names[prefix..-1], arg_modes[prefix..-1], arg_defaults[prefix..-1])
16
+ arg_modes = arg_modes[0, prefix]
17
+ arg_types = arg_types[0, prefix]
18
+ arg_names = arg_names[0, prefix]
19
+ arg_defaults = arg_defaults[0, prefix]
20
+ setof = false
21
+ end
22
+
23
+ super(oid, name, strict, secdef, setof, type, volatility, arg_modes, arg_names, arg_types, arg_defaults)
13
24
  end
14
25
 
15
26
  # @return [String]
@@ -132,10 +143,13 @@ module Piggly
132
143
  hash["setof"] == "t",
133
144
  QualifiedType.parse(hash["tschema"].to_s, hash["type"].to_s),
134
145
  volatility(hash["volatility"]),
135
- coalesce(hash["arg_modes"].to_s.split(",").map{|x| mode(x.strip) }, ["in"]*hash["arg_count"].to_i),
146
+ coalesce(hash["arg_modes"].to_s.split(",").map{|x| mode(x.strip) },
147
+ ["in"]*hash["arg_count"].to_i),
136
148
  hash["arg_names"].to_s.split(",").map{|x| QualifiedName.new(nil, x.strip) },
137
149
  hash["arg_types"].to_s.split(",").map{|x| QualifiedType.parse(x.strip) },
138
- defaults(hash["arg_defaults"], hash["arg_defaults_count"].to_i, hash["arg_count"].to_i))
150
+ defaults(hash["arg_defaults"],
151
+ hash["arg_defaults_count"].to_i,
152
+ hash["arg_count"].to_i))
139
153
  end
140
154
 
141
155
  def coalesce(value, default)
@@ -8,12 +8,13 @@ module Piggly
8
8
  class SkeletonProcedure
9
9
 
10
10
  attr_reader :oid, :name, :type, :arg_types, :arg_modes, :arg_names,
11
- :strict, :type, :setof, :volatility, :secdef, :identifier
11
+ :strict, :setof, :volatility, :secdef, :identifier
12
12
 
13
13
  def initialize(oid, name, strict, secdef, setof, type, volatility, arg_modes, arg_names, arg_types, arg_defaults)
14
14
  @oid, @name, @strict, @secdef, @type, @volatility, @setof, @arg_modes, @arg_names, @arg_types, @arg_defaults =
15
15
  oid, name, strict, secdef, type, volatility, setof, arg_modes, arg_names, arg_types, arg_defaults
16
16
 
17
+
17
18
  @identifier = Digest::MD5.hexdigest(signature)
18
19
  end
19
20
 
@@ -21,26 +22,26 @@ module Piggly
21
22
  # @return [String]
22
23
  def arguments
23
24
  @arg_types.zip(@arg_names, @arg_modes, @arg_defaults).map do |type, name, mode, default|
24
- "#{mode + " " if mode}#{name.quote + " " if name}#{type.quote}#{" DEFAULT " + default if default}"
25
+ "#{mode + " " if mode}#{name.quote + " " if name}#{type.quote}#{" default " + default if default}"
25
26
  end.join(", ")
26
27
  end
27
28
 
28
29
  # Returns source text for return type
29
30
  # @return [String]
30
31
  def setof
31
- @setof ? "setof " : ""
32
+ @setof ? "setof " : nil
32
33
  end
33
34
 
34
35
  # Returns source text for strictness
35
36
  # @return [String]
36
37
  def strictness
37
- @strict ? "strict" : ""
38
+ @strict ? "strict" : nil
38
39
  end
39
40
 
40
41
  # Returns source text for security
41
42
  # @return [String]
42
43
  def security
43
- @secdef ? "security definer" : ""
44
+ @secdef ? "security definer" : nil
44
45
  end
45
46
 
46
47
  # Returns source SQL function definition statement
@@ -73,7 +73,19 @@ module Piggly
73
73
 
74
74
  string << arguments << " )"
75
75
  string << "\n<span class='tK'>RETURNS#{procedure.setof ? ' SETOF' : ''}</span>"
76
- string << " <span class='tD'>#{procedure.type.shorten}</span>"
76
+
77
+ if procedure.type.table?
78
+ fields = procedure.type.types.zip(procedure.type.names).map do |rtype, rname|
79
+ rname = "<span class='tI'>#{rname}</span>\t"
80
+ rtype = "<span class='tD'>#{rtype}</span>"
81
+ "#{rname}#{rtype}"
82
+ end.join(",\n\t")
83
+
84
+ string << " <span class='tK'>TABLE</span> (\n\t" << fields << " )"
85
+ else
86
+ string << " <span class='tD'>#{procedure.type.shorten}</span>"
87
+ end
88
+
77
89
  string << "\n <span class='tK'>SECURITY DEFINER</span>" if procedure.secdef
78
90
  string << "\n <span class='tK'>STRICT</span>" if procedure.strict
79
91
  string << "\n <span class='tK'>#{procedure.volatility.upcase}</span>"
@@ -2,9 +2,9 @@ module Piggly
2
2
  module VERSION
3
3
  MAJOR = 2
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
- RELEASE_DATE = "2017-10-13"
7
+ RELEASE_DATE = "2017-10-23"
8
8
  end
9
9
 
10
10
  class << VERSION
@@ -4,8 +4,7 @@ module Piggly
4
4
  describe "github issue #32" do
5
5
 
6
6
  # note: both -r always subtracts and -s always adds
7
- # from left-to-right (first-to-last), so -r Y -s Y
8
- # or -s Y -r Y undo each other and have no effect.
7
+ # from left-to-right.
9
8
  #
10
9
  # if the first filter is -s, then the set starts empty
11
10
  # and -s adds to it.
@@ -13,7 +12,6 @@ module Piggly
13
12
  # if the first filter is -r, then the set starts with
14
13
  # all procedures and -r removes from it.
15
14
 
16
-
17
15
  def result(args)
18
16
  index = double("index", :procedures => [
19
17
  double("public.a", :name => "public.a"),
@@ -21,8 +19,6 @@ module Piggly
21
19
  double("public.c", :name => "public.c"),
22
20
  double("public.d", :name => "public.d")])
23
21
  config = Command::Trace.configure(args.dup)
24
- p config.object_id, config.filters.object_id
25
-
26
22
  result = Command::Trace.filter(config, index)
27
23
  result.map(&:name).sort
28
24
  end
@@ -52,7 +48,7 @@ module Piggly
52
48
  it "adds matching procs" do
53
49
  result(args).should == [
54
50
  "public.b",
55
- "public.d"] #
51
+ "public.d"]
56
52
  end
57
53
  end
58
54
 
@@ -63,7 +59,7 @@ module Piggly
63
59
  result(args).should == [
64
60
  "public.a",
65
61
  "public.b",
66
- "public.d"] #
62
+ "public.d"]
67
63
  end
68
64
  end
69
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piggly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kvle Putnam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-14 00:00:00.000000000 Z
11
+ date: 2017-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -158,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.2.2
161
+ rubygems_version: 2.6.14
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: PL/pgSQL code coverage tool
165
165
  test_files: []
166
- has_rdoc: false