gh-events 0.6.2 → 0.7.0

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
  SHA256:
3
- metadata.gz: 7f9a4fc61ec5714b1d49249d449496180f7a7e378b327a9c2e8d7e467c06b9a5
4
- data.tar.gz: 83d0c56649117b8a3f091215223467f327e326b28e81874e9dce4cb5e2ac61b7
3
+ metadata.gz: 816a9b68c1d37a66b90de0a48614bd57b94715faa53a5edd8245a2fe5e5a2d5b
4
+ data.tar.gz: 752dc0d3e42566b280b75fc39cacf4c456b4c16e7132366516fe5dd77166b138
5
5
  SHA512:
6
- metadata.gz: 1e688bda0e36e9dee4b97b3a166bf2b1e2a574767a19099d666ec5ed1fa07c7d6e0193226b92b4d67d652f3228f990308dc700cfbb37f80bfce1abc7821e2189
7
- data.tar.gz: dd7072f3c14de36c0f63c33430f129f790db2c0908f7ce900c84ee0c049427b1f442bdbf77360058d5670cf909141bbaa100bcf3204712c2dc220af602854bc8
6
+ metadata.gz: 3ee613e1900e42bfe45554e8d4cf36800bcb6fb14524d24faf89b2d8a20213603960f5f1c7c0ad47149bf51bd3bd48f5b0da5473e9dbb75e26a88ad31efc95d3
7
+ data.tar.gz: f273b92f4fe2124555e42c5c60391e75a6c7d941825047ea6ea1613b2324036f44c536763f7c9da36a93c7d3f2cea83687f4cd0ba09f16020b24801a8d41791c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gh-events (0.6.2)
4
+ gh-events (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,32 @@
1
- # Github::Events
1
+ # Github Events
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/github/events`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Via Webhooks Github can send a plethora of events, which can be used to facilitate all kinds of automation.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ These events are _untyped_, meaning they clearly lack a property `type` to identify the type of event received. (The rationale here might be that one would have differen webhook endpoints for each type of events. But maintaining lots of endpoints is cumbersome. When all the events end up in one endpoint, this library helps by adding a property `type` to the event.)
6
+
7
+ Additionally this library provides means of translating the plain event into a human readable textutal representation. This functionality is wrapped in a command line utility, for your convenience.
8
+
9
+ ## Example Usage
10
+
11
+ You can use the command `gh-events` to list the types of events stortef in JSON files.
12
+
13
+ ```
14
+ % gh-events spec/fixtures/*.json
15
+ events/001.json: commit_comment
16
+ events/002.json: create
17
+ events/003.json: delete
18
+ events/004.json: deployment
19
+ events/005.json: deployment_status
20
+ events/006.json: fork
21
+ ...
22
+ ```
23
+
24
+ Let's say you have a github _commit_comment_ event stored in a file `event.json`
25
+
26
+ ```
27
+ % cat event.json | gh-event2text
28
+ ...
29
+ ```
6
30
 
7
31
  ## Installation
8
32
 
@@ -20,10 +44,6 @@ Or install it yourself as:
20
44
 
21
45
  $ gem install gh-events
22
46
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
47
  ## References
28
48
 
29
49
  - https://developer.github.com/v3/activity/events/types/
data/exe/gh-events ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path("../../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'gh/events'
7
+
8
+ ARGV.each do |file|
9
+ type = GH::Events.typeof(File.read(file))
10
+ puts "#{file}: #{type}"
11
+ end
data/lib/gh/events.rb CHANGED
@@ -14,6 +14,7 @@ module GH
14
14
  HEURISTICS = YAML.load_file(PATH)
15
15
 
16
16
  def typeof(payload)
17
+ payload = JSON.parse(payload) if payload.is_a?(String)
17
18
  payload = payload.marshal_dump if payload.is_a?(OpenStruct)
18
19
  keys = payload.keys.map(&:to_s)
19
20
  HEURISTICS.each do |type, characteristics|
@@ -1,5 +1,5 @@
1
1
  module GH
2
2
  module Events
3
- VERSION = "0.6.2"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Hofmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-27 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,7 @@ email:
57
57
  - phil@200ok.ch
58
58
  executables:
59
59
  - gh-event2slack
60
+ - gh-events
60
61
  extensions: []
61
62
  extra_rdoc_files: []
62
63
  files:
@@ -70,6 +71,7 @@ files:
70
71
  - bin/console
71
72
  - bin/setup
72
73
  - exe/gh-event2slack
74
+ - exe/gh-events
73
75
  - gh-events.gemspec
74
76
  - lib/gh-events.rb
75
77
  - lib/gh/events.rb