gh-events 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a55bebd661fa282ed77d62961d6c3536884bcc73445d7ae322d649f5b96ae6d2
4
+ data.tar.gz: 2adf190eee10e83cd1e5c3e86f53c7f846ef7c737377dc3a04bfa2e42864783e
5
+ SHA512:
6
+ metadata.gz: 8ff6eba75025b4703b4bfa2c6c74c6da65ba5806650ba6815efd24df01f85c4512de48b92a80cea16cf8d3a76a7ea32583928e7f298a0b43e607de609625fda2
7
+ data.tar.gz: fd3ae344746ba5165f4fcdeab5067437db11076cd65365966eea3bd803fd7c845a96fcb567e6a8cf1b7c9e1589bd116df50502b0f9d5a2fe0942733b177fa6a8
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gh-events.gemspec
4
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gh-events (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.9.0)
12
+ rspec-core (~> 3.9.0)
13
+ rspec-expectations (~> 3.9.0)
14
+ rspec-mocks (~> 3.9.0)
15
+ rspec-core (3.9.0)
16
+ rspec-support (~> 3.9.0)
17
+ rspec-expectations (3.9.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.9.0)
20
+ rspec-mocks (3.9.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-support (3.9.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 2.0)
30
+ gh-events!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 2.0.1
@@ -0,0 +1,35 @@
1
+ # Github::Events
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.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'gh-events'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gh-events
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/200ok-ch/gh-events.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "github/events"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gh/events/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gh-events"
8
+ spec.version = GH::Events::VERSION
9
+ spec.authors = ["Phil Hofmann"]
10
+ spec.email = ["phil@200ok.ch"]
11
+
12
+ spec.summary = %q{Determine Github event types by their payload.}
13
+ spec.description = %q{Determine Github event types by their payload.}
14
+ spec.homepage = "https://github.com/200ok-ch/gh-events"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+ spec.metadata["changelog_uri"] = spec.homepage
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.0"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path(File.join(%w(.. gh events)), __FILE__)
@@ -0,0 +1,37 @@
1
+ require "gh/events/version"
2
+
3
+ require 'yaml'
4
+
5
+ module GH
6
+ module Events
7
+ class Error < StandardError; end
8
+
9
+ extend self
10
+
11
+ PATH = File.expand_path(File.join(%w(.. .. .. res events.yml)), __FILE__)
12
+ HEURISTICS = YAML.load_file(PATH)
13
+
14
+ def typeof(payload)
15
+ keys = payload.keys
16
+ HEURISTICS.each do |type, characteristics|
17
+ # all keys in `present` are there
18
+ x = ((characteristics['present'] || []) - keys)
19
+ next unless x.empty?
20
+
21
+ # non of the keys in `absent` are there
22
+ y = ((characteristics['absent'] || []) & keys)
23
+ next unless y.empty?
24
+
25
+ # everything in `exactly` is there including the values
26
+ z = payload.dup.merge(characteristics['exactly'] || {}) == payload
27
+ next unless z
28
+
29
+ next if characteristics['number_of_keys'] &&
30
+ keys.count != characteristics['number_of_keys']
31
+
32
+ return type.to_sym
33
+ end
34
+ return :unknown
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module GH
2
+ module Events
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,194 @@
1
+ ---
2
+ # https://developer.github.com/v3/activity/events/types/
3
+
4
+ # the order is crucial, first match wins!
5
+
6
+ watch: # 49
7
+ present:
8
+ - action
9
+ - repository
10
+ exactly:
11
+ action: started
12
+
13
+ # check_run # 1
14
+
15
+ # check_suite # 2
16
+
17
+ commit_comment: # 3
18
+ present:
19
+ - comment
20
+ - repository
21
+ absent:
22
+ - issue
23
+ - pull_request
24
+
25
+ # content_reference # 4
26
+
27
+ create: # 5
28
+ present:
29
+ - ref_type
30
+ - ref
31
+ - master_branch
32
+ - description
33
+ - repository
34
+
35
+ delete: # 6
36
+ present:
37
+ - ref_type
38
+ - ref
39
+ - repository
40
+ absent:
41
+ - master_branch
42
+
43
+ # deploy_key # 7
44
+
45
+ deployment: # 8
46
+ present:
47
+ - deployment
48
+ - repository
49
+ absent:
50
+ - deployment_status
51
+
52
+ deployment_status: # 9
53
+ present:
54
+ - deployment
55
+ - deployment_status
56
+ - repository
57
+
58
+ # download # 10
59
+
60
+ # follow # 11
61
+
62
+ fork: # 12
63
+ present:
64
+ - forkee
65
+ - repository
66
+
67
+ # fork_apply # 13
68
+
69
+ # git_hub_app_authorization # 14
70
+
71
+ # gist # 15
72
+
73
+ gollum: # 16
74
+ present:
75
+ - pages
76
+ - repository
77
+
78
+ # installation: # 17
79
+
80
+ # installation_repositories: # 18
81
+
82
+ issue_comment: # 19
83
+ present:
84
+ - issue
85
+ - comment
86
+ - repository
87
+
88
+ issues: # 20
89
+ present:
90
+ - issue
91
+ - repository
92
+ absent:
93
+ - comment
94
+
95
+ # label # 21
96
+
97
+ # marketplace_purchase # 22
98
+
99
+ member: # 23
100
+ present:
101
+ - member
102
+ - repository
103
+
104
+ membership: # 24
105
+ present:
106
+ - scope
107
+ - member
108
+ - team
109
+ - organization
110
+
111
+ # meta # 25
112
+
113
+ # milestone # 26
114
+
115
+ # organization # 27
116
+
117
+ # org_block # 28
118
+
119
+ page_build: # 29
120
+ present:
121
+ - build
122
+ - repository
123
+
124
+ # project_card # 30
125
+
126
+ # project_column # 31
127
+
128
+ # project # 32
129
+
130
+ public: # 33
131
+ present:
132
+ - repository
133
+ number_of_keys: 2
134
+
135
+ pull_request: # 34
136
+ present:
137
+ - pull_request
138
+ - repository
139
+ absent:
140
+ - comment
141
+
142
+ # pull_request_review # 35
143
+
144
+ pull_request_review_comment: # 36
145
+ present:
146
+ - comment
147
+ - pull_request
148
+ - repository
149
+
150
+ push: # 37
151
+ present:
152
+ - ref
153
+ - before
154
+ - commits
155
+ - repository
156
+
157
+ # registry_package # 38
158
+
159
+ release: # 39
160
+ present:
161
+ - release
162
+ - repository
163
+
164
+ # repository_dispatch # 40
165
+
166
+ repository: # 41
167
+ present:
168
+ - action
169
+ - repository
170
+ number_of_keys: 3
171
+
172
+ # repository_import # 42
173
+
174
+ # repository_vulnerability_report # 43
175
+
176
+ # security_advisory # 44
177
+
178
+ star: # 45
179
+ present:
180
+ - starred_at
181
+
182
+ status: # 46
183
+ present:
184
+ - sha
185
+ - state
186
+ - description
187
+ - branches
188
+
189
+ # team # 47
190
+
191
+ team_add: # 48
192
+ present:
193
+ - team
194
+ - repository
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gh-events
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Phil Hofmann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Determine Github event types by their payload.
56
+ email:
57
+ - phil@200ok.ch
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - gh-events.gemspec
71
+ - lib/gh-events.rb
72
+ - lib/gh/events.rb
73
+ - lib/gh/events/version.rb
74
+ - res/events.yml
75
+ homepage: https://github.com/200ok-ch/gh-events
76
+ licenses: []
77
+ metadata:
78
+ homepage_uri: https://github.com/200ok-ch/gh-events
79
+ source_code_uri: https://github.com/200ok-ch/gh-events
80
+ changelog_uri: https://github.com/200ok-ch/gh-events
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.7.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Determine Github event types by their payload.
101
+ test_files: []