jackal-github 0.1.0 → 0.1.2

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: eec50fd5e3f0c4fcabb04c701e0d7227aa0afcf3
4
- data.tar.gz: e87d0e1e9420ee420993619f4a51e72f030378b9
3
+ metadata.gz: 6cc925771741af3b924cf5056e9067012df12180
4
+ data.tar.gz: cf4e8e925b5fee8f7f0e7b8e87b96e6dddbaa2bf
5
5
  SHA512:
6
- metadata.gz: 55115b081234606af980b53d5e176af0683514841cc416b9128ce9036743488556d7f35ba11235c37b8ddeabe1b89e17ee62d01b9695a32427b99d8adc5240ad
7
- data.tar.gz: 4a1f2dd0da9e664d7804e9270499a8f8056812b9e0f736042232f139c965a4bda3bfdd8f14254757d4c313a110f84e871cfa3790a12df4e8b6564c9ea3d0e69f
6
+ metadata.gz: 25c98ea2d30358dd5e145865437a718fcd11c50c48cff89dd4ed0d0bf6f773630d2d5c20ebe9d07768b3f7300876d868c0b2199a1f8c97c59442b3c9f23a6ae7
7
+ data.tar.gz: 762c40bc84dce3d4b1adb20d12ac073bc23e08adef47b5c43df5fe9a9bf39f6a1a37e57e42b3eb97151f026bf22280d9680f03bbf040d8a085c55defaaf61f39
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ # v0.1.2
2
+ * Add extra filtering ability via formatters based on git information
3
+
1
4
  # v0.1.0
2
5
  * Initial release
@@ -22,10 +22,60 @@ module Jackal
22
22
  failure_wrap(message) do |_|
23
23
  content = format_payload(message)
24
24
  payload = new_payload(name_for_payload(content), content)
25
- job_completed(:github, payload, message)
25
+ filter(message, payload) do
26
+ job_completed(:github, payload, message)
27
+ end
26
28
  end
27
29
  end
28
30
 
31
+ # Apply filters to payload. If filters are enabled
32
+ # and no filter matches, discard payload
33
+ #
34
+ # @param message [Carnivore::Message]
35
+ # @param payload [Smash]
36
+ # @yield block to execute if payload is allowed
37
+ def filter(message, payload)
38
+ valid = true
39
+ a_events = allowed_events(payload)
40
+ r_events = restricted_events(payload)
41
+ if(a_events && !a_events.include?(payload.get(:data, :github, :event)))
42
+ valid = false
43
+ end
44
+ if(r_events && r_events.include?(payload.get(:data, :github, :event)))
45
+ valid = false
46
+ end
47
+ if(valid)
48
+ yield
49
+ else
50
+ warn "Message has been filtered and is restricted from entering pipeline (#{message})"
51
+ message.confirm!
52
+ end
53
+ end
54
+
55
+ # Event types allowed to be dropped into pipeline
56
+ #
57
+ # @param payload [Smash]
58
+ # @return [Array, NilClass]
59
+ def allowed_events(payload)
60
+ a_events = config.fetch(:events, :allowed, [])
61
+ a_events += payload.fetch(:data, :github, :query, {}).map do |k,v|
62
+ k if v == 'enabled'
63
+ end.compact
64
+ a_events.empty? ? nil : a_events
65
+ end
66
+
67
+ # Event types restricted from being dropped into pipeline
68
+ #
69
+ # @param payload [Smash]
70
+ # @return [Array, NilClass]
71
+ def restricted_events(payload)
72
+ r_events = config.fetch(:events, :restricted, [])
73
+ r_events += payload.fetch(:data, :github, :query, {}).map do |k,v|
74
+ k if v == 'disabled'
75
+ end.compact
76
+ r_events.empty? ? nil : a_events
77
+ end
78
+
29
79
  # Format the github event to store within the payload
30
80
  #
31
81
  # @param message [Carnivore::Message]
@@ -1,5 +1,5 @@
1
1
  module Jackal
2
2
  module Github
3
- VERSION = Gem::Version.new('0.1.0')
3
+ VERSION = Gem::Version.new('0.1.2')
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackal-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jackal