piggly 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c6bf40f9aa03c6a2ebf7dc77185b8d0fb17cb1b
4
- data.tar.gz: 72e0c24978ea9924e1a1c83a4022fa3556a492ad
3
+ metadata.gz: 0aca5c86391dab9ddd1b0529e469c67f440ce9c8
4
+ data.tar.gz: aa7ced6807ad226312f95fb428d6e1ea36aa6af4
5
5
  SHA512:
6
- metadata.gz: 3bfa8e89afcd5a97f4e5dca7f16b610ac47aa900b2053c2a3cd436131f3d0c49caf24c16f9ac9bb60d80c994fe6f80d536d80f710fd42c1d14b4fe08290aac4d
7
- data.tar.gz: 924a46543d48d96cd15b4fdb0c02ff5bd24097d2a48e8ba0a099ac71c7241449f3e88649938ba9c571e9e47a1d3e1d9c24faf1a8580cacdb647541464b471279
6
+ metadata.gz: 9a77dc4124175df8e45f1223e0b46c3dee9bb2f8282f0552b61dcccf4dc5348da072a5c5672bb77656c05f1b4e29fc9d0e47392d7d90fcad3396539f5c782e3e
7
+ data.tar.gz: 438b3ceb842971d0233eb16e9f41513b4494e50457e0bd8879f3aaa0858feeb4bf1ee11e17430b3b537f5c503e4a362deffa48b5a3739c24d38ca0f02536e7d2
@@ -16,8 +16,6 @@ module Piggly
16
16
  end
17
17
  end
18
18
 
19
- private
20
-
21
19
  # @return [(Class, Array<String>)]
22
20
  def command(argv)
23
21
  return if argv.empty?
@@ -67,26 +65,16 @@ module Piggly
67
65
  else
68
66
  head, _ = config.filters
69
67
 
70
- start = index.procedures
68
+ start =
69
+ case head.first
70
+ when :+; []
71
+ when :-; index.procedures
72
+ end
71
73
 
72
74
  config.filters.inject(start) do |s, pair|
73
75
  case pair.first
74
- when :+
75
- puts "Selecting procedures"
76
- o = s.select(&pair.last)
77
- puts "Selected #{ o.count} procedures"
78
- puts "Selected:"
79
- o.each do |x| puts x.name end
80
- puts "---"
81
- o
82
- when :-
83
- puts "Rejecting procedures"
84
- o = s.reject(&pair.last)
85
- puts "Rejected #{s.count - o.count} procedures"
86
- puts "Rejected:"
87
- ((o-s)|(s-o)).each do |x| puts x.name end
88
- puts "---"
89
- o
76
+ when :+; s | index.procedures.select(&pair.last)
77
+ when :-; s.reject(&pair.last)
90
78
  end
91
79
  end
92
80
  end
data/lib/piggly/config.rb CHANGED
@@ -45,15 +45,15 @@ module Piggly
45
45
  end
46
46
 
47
47
  class Config
48
- config_accessor \
49
- :cache_root => File.expand_path("#{Dir.pwd}/piggly/cache"),
50
- :report_root => File.expand_path("#{Dir.pwd}/piggly/reports"),
51
- :database_yml => nil,
52
- :connection_name => "piggly",
53
- :trace_prefix => "PIGGLY",
54
- :accumulate => false,
55
- :dry_run => false,
56
- :filters => []
48
+ attr_accessor \
49
+ :cache_root,
50
+ :report_root,
51
+ :database_yml,
52
+ :connection_name,
53
+ :trace_prefix,
54
+ :accumulate,
55
+ :dry_run,
56
+ :filters
57
57
 
58
58
  alias accumulate? accumulate
59
59
 
@@ -64,5 +64,16 @@ module Piggly
64
64
  def mkpath(*args)
65
65
  self.class.mkpath(*args)
66
66
  end
67
+
68
+ def initialize
69
+ @cache_root = File.expand_path("#{Dir.pwd}/piggly/cache")
70
+ @report_root = File.expand_path("#{Dir.pwd}/piggly/reports")
71
+ @database_yml = nil
72
+ @connection_name = "piggly"
73
+ @trace_prefix = "PIGGLY"
74
+ @accumulate = false
75
+ @dry_run = false
76
+ @filters = []
77
+ end
67
78
  end
68
79
  end
@@ -2,9 +2,9 @@ module Piggly
2
2
  module VERSION
3
3
  MAJOR = 2
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
- RELEASE_DATE = "2017-09-07"
7
+ RELEASE_DATE = "2017-10-13"
8
8
  end
9
9
 
10
10
  class << VERSION
@@ -17,15 +17,15 @@ describe Config do
17
17
  end
18
18
 
19
19
  it "has default values" do
20
- @config.cache_root = nil
20
+ # @config.cache_root = nil
21
21
  @config.cache_root.should_not be_nil
22
22
  @config.cache_root.should =~ /cache$/
23
23
 
24
- @config.report_root = nil
24
+ # @config.report_root = nil
25
25
  @config.report_root.should_not be_nil
26
26
  @config.report_root.should =~ /reports$/
27
27
 
28
- @config.trace_prefix = nil
28
+ # @config.trace_prefix = nil
29
29
  @config.trace_prefix.should_not be_nil
30
30
  @config.trace_prefix.should == 'PIGGLY'
31
31
  end
File without changes
@@ -0,0 +1,102 @@
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 (first-to-last), so -r Y -s Y
8
+ # or -s Y -r Y undo each other and have no effect.
9
+ #
10
+ # if the first filter is -s, then the set starts empty
11
+ # and -s adds to it.
12
+ #
13
+ # if the first filter is -r, then the set starts with
14
+ # all procedures and -r removes from it.
15
+
16
+
17
+ def result(args)
18
+ index = double("index", :procedures => [
19
+ double("public.a", :name => "public.a"),
20
+ double("public.b", :name => "public.b"),
21
+ double("public.c", :name => "public.c"),
22
+ double("public.d", :name => "public.d")])
23
+ config = Command::Trace.configure(args.dup)
24
+ p config.object_id, config.filters.object_id
25
+
26
+ result = Command::Trace.filter(config, index)
27
+ result.map(&:name).sort
28
+ end
29
+
30
+ context "with one -s argument" do
31
+ let(:args) { %w(-s public.c) }
32
+
33
+ it "selects matching procs" do
34
+ result(args).should == ["public.c"]
35
+ end
36
+ end
37
+
38
+ context "with -s regular expression" do
39
+ let(:args) { %w(-s /public.[bcd]/) }
40
+
41
+ it "selects matching procs" do
42
+ result(args).should == [
43
+ "public.b",
44
+ "public.c",
45
+ "public.d"]
46
+ end
47
+ end
48
+
49
+ context "with two -s arguments" do
50
+ let(:args) { %w(-s public.b -s public.d) }
51
+
52
+ it "adds matching procs" do
53
+ result(args).should == [
54
+ "public.b",
55
+ "public.d"] #
56
+ end
57
+ end
58
+
59
+ context "with one -r argument" do
60
+ let(:args) { %w(-r public.c) }
61
+
62
+ it "rejects matching procs" do
63
+ result(args).should == [
64
+ "public.a",
65
+ "public.b",
66
+ "public.d"] #
67
+ end
68
+ end
69
+
70
+ context "with two -r arguments" do
71
+ let(:args) { %w(-r public.b -r public.d) }
72
+
73
+ it "subtracts rejected procs" do
74
+ result(args).should == [
75
+ "public.a",
76
+ "public.c"]
77
+ end
78
+ end
79
+
80
+ context "with -s then -r" do
81
+ let(:args) { %w(-s /\.[abc]/ -r public.b -r public.d) }
82
+
83
+ it "-r removes from -s matches" do
84
+ result(args).should == [
85
+ "public.a",
86
+ "public.c"]
87
+ end
88
+ end
89
+
90
+ context "with -r then -s" do
91
+ let(:args) { %w(-r /\.[bc]/ -s public.b -s public.a) }
92
+
93
+ it "-s adds to -r non-matches" do
94
+ result(args).should == [
95
+ "public.a",
96
+ "public.b",
97
+ "public.d"]
98
+ end
99
+ end
100
+
101
+ end
102
+ end
data/spec/spec_helper.rb CHANGED
@@ -7,10 +7,6 @@ end
7
7
  require "ostruct"
8
8
  require File.expand_path("#{File.dirname(__FILE__)}/../lib/piggly")
9
9
 
10
- #Dir[File.join(File.dirname(__FILE__), 'mocks', '*')].each do |m|
11
- # require File.expand_path(m)
12
- #end
13
-
14
10
  # load runtime dependencies
15
11
  Piggly::Parser.parser
16
12
 
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.0
4
+ version: 2.2.1
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-09-08 00:00:00.000000000 Z
11
+ date: 2017-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -90,7 +90,6 @@ files:
90
90
  - lib/piggly/util/process_queue.rb
91
91
  - lib/piggly/util/thunk.rb
92
92
  - lib/piggly/version.rb
93
- - spec/028_spec.rb
94
93
  - spec/examples/compiler/cacheable_spec.rb
95
94
  - spec/examples/compiler/report_spec.rb
96
95
  - spec/examples/compiler/trace_spec.rb
@@ -135,6 +134,8 @@ files:
135
134
  - spec/issues/007_spec.rb
136
135
  - spec/issues/008_spec.rb
137
136
  - spec/issues/018_spec.rb
137
+ - spec/issues/028_spec.rb
138
+ - spec/issues/032_spec.rb
138
139
  - spec/spec_helper.rb
139
140
  - spec/spec_suite.rb
140
141
  homepage: http://github.com/kputnam/piggly