webhook-parcel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b83d0d473d434fd83428e3ff99448308648490de
4
+ data.tar.gz: 7269e3f21828dda1c3571161f682669cdeff15d3
5
+ SHA512:
6
+ metadata.gz: 355455ba1c1c428d2a60e153b0981bbd539c12303de8a956ebed506f111ea6edf75d7ed48b3e6984fd7b84d72121f284c93b8209ddb4e7721b2cfe8a7f0635e6
7
+ data.tar.gz: 5c453afd0fe3fc640173938fc7f084b9556e4a5a2ece7cb7896125569cbe214253cec4b2886218b5610df5e2b6bdd418ada5b08aff721cb4fae649715cd789df
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in parcel.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Michael Stock
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ ## Parcel
2
+ Ruby wrapper for Github Webhook Payloads
3
+
4
+ [![Build Status](https://travis-ci.org/devlocker/parcel.svg?branch=master)](https://travis-ci.org/devlocker/parcel)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "parcel"
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install parcel
21
+
22
+ ## Usage
23
+
24
+ To use, create a Parcel::Payload
25
+
26
+ ```ruby
27
+ # hash of webhook JSON
28
+ webhook_hash
29
+ # => {"ref"=>"refs/heads/mas/webhooks",
30
+ # "before"=>"905ad37282d0cee53139f4ec8396a7d6985dd2de",
31
+ # "after"=>"59f4f57da2e4eff5c349141bc9e267d47f70c417",
32
+ # "created"=>false,
33
+ # "deleted"=>false,
34
+ # "forced"=>false,
35
+ # "base_ref"=>nil,
36
+ # "compare"=>"https://github.com/mikeastock/devlocker/compare/905ad37282d0...59f4f57da2e4",
37
+ # "commits"=>
38
+ # [{"id"=>"59f4f57da2e4eff5c349141bc9e267d47f70c417",
39
+ # "distinct"=>true,
40
+ # "message"=>"Add headers to webhook request",
41
+ # "timestamp"=>"2014-11-30T20:34:52-08:00",
42
+
43
+ parcel = Parcel::Payload.new(webhook_hash)
44
+ # => #<Parcel::Payload:0x007ffb552ae6c8
45
+ # @after="59f4f57da2e4eff5c349141bc9e267d47f70c417",
46
+ # @base_ref=nil,
47
+ # @before="905ad37282d0cee53139f4ec8396a7d6985dd2de",
48
+ # @commits=
49
+ # [#<Parcel::Commit:0x007ffb552964d8
50
+ # @added=[],
51
+ # @author=
52
+ # #<Parcel::Person:0x007ffb5525dd18
53
+ # @avatar_url=nil,
54
+ # @email="mikeastock@gmail.com",
55
+ # @events_url=nil,
56
+ # @followers_url=nil,
57
+ # @following_url=nil,
58
+ # @gists_url=nil,
59
+ # @gravatar_id=nil,
60
+ # @html_url=nil,
61
+ # @id=nil,
62
+ # @login=nil,
63
+ # @name="Michael Stock",
64
+ ```
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it ( https://github.com/devlocker/parcel/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << ["test"]
6
+ t.pattern = "test/**/*.rb"
7
+ t.warning = true
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,10 @@
1
+ require "virtus"
2
+
3
+ require "parcel/version"
4
+ require "parcel/person"
5
+ require "parcel/repository"
6
+ require "parcel/commit"
7
+ require "parcel/payload"
8
+
9
+ module Parcel
10
+ end
@@ -0,0 +1,14 @@
1
+ class Parcel::Commit
2
+ include Virtus.model
3
+
4
+ attribute :id, Integer
5
+ attribute :distinct, Boolean
6
+ attribute :message, String
7
+ attribute :timestamp, DateTime
8
+ attribute :url, String
9
+ attribute :author, Parcel::Person
10
+ attribute :committer, Parcel::Person
11
+ attribute :added, Array[String]
12
+ attribute :removed, Array[String]
13
+ attribute :modified, Array[String]
14
+ end
@@ -0,0 +1,17 @@
1
+ class Parcel::Payload
2
+ include Virtus.model
3
+
4
+ attribute :ref, String
5
+ attribute :before, String
6
+ attribute :after, String
7
+ attribute :created, Boolean
8
+ attribute :deleted, Boolean
9
+ attribute :forced, Boolean
10
+ attribute :base_ref, String
11
+ attribute :compare, String
12
+ attribute :commits, Array[Parcel::Commit]
13
+ attribute :head_commit, Parcel::Commit
14
+ attribute :repository, Parcel::Repository
15
+ attribute :pusher, Parcel::Person
16
+ attribute :sender, Parcel::Person
17
+ end
@@ -0,0 +1,24 @@
1
+ class Parcel::Person
2
+ include Virtus.model
3
+
4
+ attribute :name, String
5
+ attribute :login, String
6
+ attribute :email, String
7
+ attribute :username, String
8
+ attribute :id, Integer
9
+ attribute :avatar_url, String
10
+ attribute :gravatar_id, String
11
+ attribute :url, String
12
+ attribute :html_url, String
13
+ attribute :followers_url, String
14
+ attribute :following_url, String
15
+ attribute :gists_url, String
16
+ attribute :starred_url, String
17
+ attribute :subscriptions_url, String
18
+ attribute :organizations_url, String
19
+ attribute :repos_url, String
20
+ attribute :events_url, String
21
+ attribute :received_events_url, String
22
+ attribute :type, String
23
+ attribute :site_admin, Boolean
24
+ end
@@ -0,0 +1,72 @@
1
+ class Parcel::Repository
2
+ include Virtus.model
3
+
4
+ attribute :id, Integer
5
+ attribute :name, String
6
+ attribute :full_name, String
7
+ attribute :owner, Hash[Symbol => String]
8
+ attribute :private, Boolean
9
+ attribute :html_url, String
10
+ attribute :description, String
11
+ attribute :fork, Boolean
12
+ attribute :url, String
13
+ attribute :forks_url, String
14
+ attribute :keys_url, String
15
+ attribute :collaborators_url, String
16
+ attribute :teams_url, String
17
+ attribute :hooks_url, String
18
+ attribute :issue_events_url, String
19
+ attribute :events_url, String
20
+ attribute :assignees_url, String
21
+ attribute :branches_url, String
22
+ attribute :tags_url, String
23
+ attribute :blobs_url, String
24
+ attribute :git_tags_url, String
25
+ attribute :git_refs_url, String
26
+ attribute :trees_url, String
27
+ attribute :statuses_url, String
28
+ attribute :languages_url, String
29
+ attribute :stargazers_url, String
30
+ attribute :contributors_url, String
31
+ attribute :subscribers_url, String
32
+ attribute :subscription_url, String
33
+ attribute :commits_url, String
34
+ attribute :git_commits_url, String
35
+ attribute :comments_url, String
36
+ attribute :issue_comment_url, String
37
+ attribute :contents_url, String
38
+ attribute :compare_url, String
39
+ attribute :merges_url, String
40
+ attribute :archive_url, String
41
+ attribute :downloads_url, String
42
+ attribute :issues_url, String
43
+ attribute :pulls_url, String
44
+ attribute :milestones_url, String
45
+ attribute :notifications_url, String
46
+ attribute :labels_url, String
47
+ attribute :created_at, Integer
48
+ attribute :updated_at, Integer
49
+ attribute :pushed_at, Integer
50
+ attribute :git_url, String
51
+ attribute :ssh_url, String
52
+ attribute :clone_url, String
53
+ attribute :svn_url, String
54
+ attribute :homepage, String
55
+ attribute :size, Integer
56
+ attribute :stargazers_count, Integer
57
+ attribute :watchers_count, Integer
58
+ attribute :language, String
59
+ attribute :has_issues, Boolean
60
+ attribute :has_downloads, Boolean
61
+ attribute :has_wiki, Boolean
62
+ attribute :has_pages, Boolean
63
+ attribute :forks_count, Integer
64
+ attribute :mirror_url, String
65
+ attribute :open_issues_count, Integer
66
+ attribute :forks, Integer
67
+ attribute :open_issues, Integer
68
+ attribute :watchers, Integer
69
+ attribute :default_branch, String
70
+ attribute :stargazers, Integer
71
+ attribute :master_branch, String
72
+ end
@@ -0,0 +1,3 @@
1
+ module Parcel
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'parcel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "webhook-parcel"
8
+ spec.version = Parcel::VERSION
9
+ spec.authors = ["DevLocker Engineering"]
10
+ spec.email = ["dev@devlocker.io"]
11
+ spec.summary = %q{Ruby wrapper for Github Webhook Payloads}
12
+ spec.description = %q{Provide objects for Github Webhook Payloads as well as parse URI's, Filenames into Ruby objects}
13
+ spec.homepage = "https://github.com/devlocker/parcel"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "virtus", "~> 1.0"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
25
+ end
@@ -0,0 +1,161 @@
1
+ {
2
+ "ref": "refs/heads/mas/webhooks",
3
+ "before": "905ad37282d0cee53139f4ec8396a7d6985dd2de",
4
+ "after": "59f4f57da2e4eff5c349141bc9e267d47f70c417",
5
+ "created": false,
6
+ "deleted": false,
7
+ "forced": false,
8
+ "base_ref": null,
9
+ "compare": "https://github.com/mikeastock/devlocker/compare/905ad37282d0...59f4f57da2e4",
10
+ "commits": [
11
+ {
12
+ "id": "59f4f57da2e4eff5c349141bc9e267d47f70c417",
13
+ "distinct": true,
14
+ "message": "Add headers to webhook request",
15
+ "timestamp": "2014-11-30T20:34:52-08:00",
16
+ "url": "https://github.com/mikeastock/devlocker/commit/59f4f57da2e4eff5c349141bc9e267d47f70c417",
17
+ "author": {
18
+ "name": "Michael Stock",
19
+ "email": "mikeastock@gmail.com",
20
+ "username": "mikeastock"
21
+ },
22
+ "committer": {
23
+ "name": "Michael Stock",
24
+ "email": "mikeastock@gmail.com",
25
+ "username": "mikeastock"
26
+ },
27
+ "added": [
28
+
29
+ ],
30
+ "removed": [
31
+
32
+ ],
33
+ "modified": [
34
+ "spec/controllers/github/repos_controller_spec.rb"
35
+ ]
36
+ }
37
+ ],
38
+ "head_commit": {
39
+ "id": "59f4f57da2e4eff5c349141bc9e267d47f70c417",
40
+ "distinct": true,
41
+ "message": "Add headers to webhook request",
42
+ "timestamp": "2014-11-30T20:34:52-08:00",
43
+ "url": "https://github.com/mikeastock/devlocker/commit/59f4f57da2e4eff5c349141bc9e267d47f70c417",
44
+ "author": {
45
+ "name": "Michael Stock",
46
+ "email": "mikeastock@gmail.com",
47
+ "username": "mikeastock"
48
+ },
49
+ "committer": {
50
+ "name": "Michael Stock",
51
+ "email": "mikeastock@gmail.com",
52
+ "username": "mikeastock"
53
+ },
54
+ "added": [
55
+
56
+ ],
57
+ "removed": [
58
+
59
+ ],
60
+ "modified": [
61
+ "spec/controllers/github/repos_controller_spec.rb"
62
+ ]
63
+ },
64
+ "repository": {
65
+ "id": 27007704,
66
+ "name": "devlocker",
67
+ "full_name": "mikeastock/devlocker",
68
+ "owner": {
69
+ "name": "mikeastock",
70
+ "email": "mikeastock@gmail.com"
71
+ },
72
+ "private": true,
73
+ "html_url": "https://github.com/mikeastock/devlocker",
74
+ "description": "",
75
+ "fork": true,
76
+ "url": "https://github.com/mikeastock/devlocker",
77
+ "forks_url": "https://api.github.com/repos/mikeastock/devlocker/forks",
78
+ "keys_url": "https://api.github.com/repos/mikeastock/devlocker/keys{/key_id}",
79
+ "collaborators_url": "https://api.github.com/repos/mikeastock/devlocker/collaborators{/collaborator}",
80
+ "teams_url": "https://api.github.com/repos/mikeastock/devlocker/teams",
81
+ "hooks_url": "https://api.github.com/repos/mikeastock/devlocker/hooks",
82
+ "issue_events_url": "https://api.github.com/repos/mikeastock/devlocker/issues/events{/number}",
83
+ "events_url": "https://api.github.com/repos/mikeastock/devlocker/events",
84
+ "assignees_url": "https://api.github.com/repos/mikeastock/devlocker/assignees{/user}",
85
+ "branches_url": "https://api.github.com/repos/mikeastock/devlocker/branches{/branch}",
86
+ "tags_url": "https://api.github.com/repos/mikeastock/devlocker/tags",
87
+ "blobs_url": "https://api.github.com/repos/mikeastock/devlocker/git/blobs{/sha}",
88
+ "git_tags_url": "https://api.github.com/repos/mikeastock/devlocker/git/tags{/sha}",
89
+ "git_refs_url": "https://api.github.com/repos/mikeastock/devlocker/git/refs{/sha}",
90
+ "trees_url": "https://api.github.com/repos/mikeastock/devlocker/git/trees{/sha}",
91
+ "statuses_url": "https://api.github.com/repos/mikeastock/devlocker/statuses/{sha}",
92
+ "languages_url": "https://api.github.com/repos/mikeastock/devlocker/languages",
93
+ "stargazers_url": "https://api.github.com/repos/mikeastock/devlocker/stargazers",
94
+ "contributors_url": "https://api.github.com/repos/mikeastock/devlocker/contributors",
95
+ "subscribers_url": "https://api.github.com/repos/mikeastock/devlocker/subscribers",
96
+ "subscription_url": "https://api.github.com/repos/mikeastock/devlocker/subscription",
97
+ "commits_url": "https://api.github.com/repos/mikeastock/devlocker/commits{/sha}",
98
+ "git_commits_url": "https://api.github.com/repos/mikeastock/devlocker/git/commits{/sha}",
99
+ "comments_url": "https://api.github.com/repos/mikeastock/devlocker/comments{/number}",
100
+ "issue_comment_url": "https://api.github.com/repos/mikeastock/devlocker/issues/comments/{number}",
101
+ "contents_url": "https://api.github.com/repos/mikeastock/devlocker/contents/{+path}",
102
+ "compare_url": "https://api.github.com/repos/mikeastock/devlocker/compare/{base}...{head}",
103
+ "merges_url": "https://api.github.com/repos/mikeastock/devlocker/merges",
104
+ "archive_url": "https://api.github.com/repos/mikeastock/devlocker/{archive_format}{/ref}",
105
+ "downloads_url": "https://api.github.com/repos/mikeastock/devlocker/downloads",
106
+ "issues_url": "https://api.github.com/repos/mikeastock/devlocker/issues{/number}",
107
+ "pulls_url": "https://api.github.com/repos/mikeastock/devlocker/pulls{/number}",
108
+ "milestones_url": "https://api.github.com/repos/mikeastock/devlocker/milestones{/number}",
109
+ "notifications_url": "https://api.github.com/repos/mikeastock/devlocker/notifications{?since,all,participating}",
110
+ "labels_url": "https://api.github.com/repos/mikeastock/devlocker/labels{/name}",
111
+ "releases_url": "https://api.github.com/repos/mikeastock/devlocker/releases{/id}",
112
+ "created_at": 1416680049,
113
+ "updated_at": "2014-11-25T04:30:40Z",
114
+ "pushed_at": 1417408510,
115
+ "git_url": "git://github.com/mikeastock/devlocker.git",
116
+ "ssh_url": "git@github.com:mikeastock/devlocker.git",
117
+ "clone_url": "https://github.com/mikeastock/devlocker.git",
118
+ "svn_url": "https://github.com/mikeastock/devlocker",
119
+ "homepage": null,
120
+ "size": 358,
121
+ "stargazers_count": 0,
122
+ "watchers_count": 0,
123
+ "language": "Ruby",
124
+ "has_issues": false,
125
+ "has_downloads": true,
126
+ "has_wiki": true,
127
+ "has_pages": false,
128
+ "forks_count": 0,
129
+ "mirror_url": null,
130
+ "open_issues_count": 2,
131
+ "forks": 0,
132
+ "open_issues": 2,
133
+ "watchers": 0,
134
+ "default_branch": "master",
135
+ "stargazers": 0,
136
+ "master_branch": "master"
137
+ },
138
+ "pusher": {
139
+ "name": "mikeastock",
140
+ "email": "mikeastock@gmail.com"
141
+ },
142
+ "sender": {
143
+ "login": "mikeastock",
144
+ "id": 1907044,
145
+ "avatar_url": "https://avatars.githubusercontent.com/u/1907044?v=3",
146
+ "gravatar_id": "",
147
+ "url": "https://api.github.com/users/mikeastock",
148
+ "html_url": "https://github.com/mikeastock",
149
+ "followers_url": "https://api.github.com/users/mikeastock/followers",
150
+ "following_url": "https://api.github.com/users/mikeastock/following{/other_user}",
151
+ "gists_url": "https://api.github.com/users/mikeastock/gists{/gist_id}",
152
+ "starred_url": "https://api.github.com/users/mikeastock/starred{/owner}{/repo}",
153
+ "subscriptions_url": "https://api.github.com/users/mikeastock/subscriptions",
154
+ "organizations_url": "https://api.github.com/users/mikeastock/orgs",
155
+ "repos_url": "https://api.github.com/users/mikeastock/repos",
156
+ "events_url": "https://api.github.com/users/mikeastock/events{/privacy}",
157
+ "received_events_url": "https://api.github.com/users/mikeastock/received_events",
158
+ "type": "User",
159
+ "site_admin": false
160
+ }
161
+ }
@@ -0,0 +1,7 @@
1
+ require "minitest/autorun"
2
+ require "parcel"
3
+ require "json"
4
+
5
+ class Parcel::TestCase < MiniTest::Test
6
+
7
+ end
@@ -0,0 +1,48 @@
1
+ require "helper"
2
+
3
+ class TestCommit < MiniTest::Test
4
+ def setup
5
+ json = JSON.parse(File.read("test/commit_webhook.json"))
6
+ @commit = Parcel::Commit.new(json["commits"].first)
7
+ end
8
+
9
+ def test_id
10
+ assert_equal "59f4f57da2e4eff5c349141bc9e267d47f70c417", @commit.id
11
+ end
12
+
13
+ def test_distinct
14
+ assert_equal true, @commit.distinct
15
+ end
16
+
17
+ def test_message
18
+ assert_equal "Add headers to webhook request", @commit.message
19
+ end
20
+
21
+ def test_timestamp
22
+ assert_equal DateTime.parse("2014-11-30T20:34:52-08:00"), @commit.timestamp
23
+ end
24
+
25
+ def test_url
26
+ assert_equal "https://github.com/mikeastock/devlocker/commit/59f4f57da2e4eff5c349141bc9e267d47f70c417", @commit.url
27
+ end
28
+
29
+ def test_author
30
+ assert_instance_of Parcel::Person, @commit.author
31
+ end
32
+
33
+ def test_committer
34
+ assert_instance_of Parcel::Person, @commit.committer
35
+ end
36
+
37
+ def test_added
38
+ assert_equal [], @commit.added
39
+ end
40
+
41
+ def test_removed
42
+ assert_equal [], @commit.removed
43
+ end
44
+
45
+ def test_modified
46
+ assert_equal ["spec/controllers/github/repos_controller_spec.rb"], @commit.modified
47
+ end
48
+ end
@@ -0,0 +1,60 @@
1
+ require "helper"
2
+
3
+ class TestPayload < MiniTest::Test
4
+ def setup
5
+ json = JSON.parse(File.read("test/commit_webhook.json"))
6
+ @payload = Parcel::Payload.new(json)
7
+ end
8
+
9
+ def test_ref
10
+ assert_equal "refs/heads/mas/webhooks", @payload.ref
11
+ end
12
+
13
+ def test_before
14
+ assert_equal "905ad37282d0cee53139f4ec8396a7d6985dd2de", @payload.before
15
+ end
16
+
17
+ def test_after
18
+ assert_equal "59f4f57da2e4eff5c349141bc9e267d47f70c417", @payload.after
19
+ end
20
+
21
+ def test_created
22
+ assert_equal false, @payload.created
23
+ end
24
+
25
+ def test_deleted
26
+ assert_equal false, @payload.deleted
27
+ end
28
+
29
+ def test_forced
30
+ assert_equal false, @payload.forced
31
+ end
32
+
33
+ def test_base_ref
34
+ assert_equal nil, @payload.base_ref
35
+ end
36
+
37
+ def test_compare
38
+ assert_equal "https://github.com/mikeastock/devlocker/compare/905ad37282d0...59f4f57da2e4", @payload.compare
39
+ end
40
+
41
+ def test_commits
42
+ assert_instance_of Parcel::Commit, @payload.commits[0]
43
+ end
44
+
45
+ def test_head_commit
46
+ assert_instance_of Parcel::Commit, @payload.head_commit
47
+ end
48
+
49
+ def test_repository
50
+ assert_instance_of Parcel::Repository, @payload.repository
51
+ end
52
+
53
+ def test_pusher
54
+ assert_instance_of Parcel::Person, @payload.pusher
55
+ end
56
+
57
+ def test_sender
58
+ assert_instance_of Parcel::Person, @payload.sender
59
+ end
60
+ end
@@ -0,0 +1,76 @@
1
+ require "helper"
2
+
3
+ class TestPerson < MiniTest::Test
4
+ def setup
5
+ json = JSON.parse(File.read("test/commit_webhook.json"))
6
+ @person = Parcel::Person.new(json["sender"])
7
+ end
8
+
9
+ def test_login
10
+ assert_equal "mikeastock", @person.login
11
+ end
12
+
13
+ def test_id
14
+ assert_equal 1907044, @person.id
15
+ end
16
+
17
+ def test_avatar_url
18
+ assert_equal "https://avatars.githubusercontent.com/u/1907044?v=3", @person.avatar_url
19
+ end
20
+
21
+ def test_gravatar_id
22
+ assert_equal "", @person.gravatar_id
23
+ end
24
+
25
+ def test_url
26
+ assert_equal "https://api.github.com/users/mikeastock", @person.url
27
+ end
28
+
29
+ def test_html_url
30
+ assert_equal "https://github.com/mikeastock", @person.html_url
31
+ end
32
+
33
+ def test_followers_url
34
+ assert_equal "https://api.github.com/users/mikeastock/followers", @person.followers_url
35
+ end
36
+
37
+ def test_following_url
38
+ assert_equal "https://api.github.com/users/mikeastock/following{/other_user}", @person.following_url
39
+ end
40
+
41
+ def test_gists_url
42
+ assert_equal "https://api.github.com/users/mikeastock/gists{/gist_id}", @person.gists_url
43
+ end
44
+
45
+ def test_starred_url
46
+ assert_equal "https://api.github.com/users/mikeastock/starred{/owner}{/repo}", @person.starred_url
47
+ end
48
+
49
+ def test_subscriptions_url
50
+ assert_equal "https://api.github.com/users/mikeastock/subscriptions", @person.subscriptions_url
51
+ end
52
+
53
+ def test_organizations_url
54
+ assert_equal "https://api.github.com/users/mikeastock/orgs", @person.organizations_url
55
+ end
56
+
57
+ def test_repos_url
58
+ assert_equal "https://api.github.com/users/mikeastock/repos", @person.repos_url
59
+ end
60
+
61
+ def test_events_url
62
+ assert_equal "https://api.github.com/users/mikeastock/events{/privacy}", @person.events_url
63
+ end
64
+
65
+ def test_received_events_url
66
+ assert_equal "https://api.github.com/users/mikeastock/received_events", @person.received_events_url
67
+ end
68
+
69
+ def test_type
70
+ assert_equal "User", @person.type
71
+ end
72
+
73
+ def test_site_admin
74
+ assert_equal false, @person.site_admin
75
+ end
76
+ end
@@ -0,0 +1,282 @@
1
+ require "helper"
2
+
3
+ class TestRepo < MiniTest::Test
4
+ def setup
5
+ json = JSON.parse(File.read("test/commit_webhook.json"))
6
+ @repo = Parcel::Repository.new(json["repository"])
7
+ end
8
+
9
+ def test_id
10
+ assert_equal 27007704, @repo.id
11
+ end
12
+
13
+ def test_name
14
+ assert_equal "devlocker", @repo.name
15
+ end
16
+
17
+
18
+ def test_full_name
19
+ assert_equal "mikeastock/devlocker", @repo.full_name
20
+ end
21
+
22
+ def test_owner
23
+ assert_equal "mikeastock", @repo.owner[:name]
24
+ assert_equal "mikeastock@gmail.com", @repo.owner[:email]
25
+ end
26
+
27
+ def test_private
28
+ assert_equal true, @repo.private
29
+ end
30
+
31
+ def test_html_url
32
+ assert_equal "https://github.com/mikeastock/devlocker", @repo.html_url
33
+ end
34
+
35
+ def test_description
36
+ assert_equal "", @repo.description
37
+ end
38
+
39
+ def test_fork
40
+ assert_equal true, @repo.fork
41
+ end
42
+
43
+ def test_url
44
+ assert_equal "https://github.com/mikeastock/devlocker", @repo.url
45
+ end
46
+
47
+ def test_forks_url
48
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/forks", @repo.forks_url
49
+ end
50
+
51
+ def test_keys_url
52
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/keys{/key_id}", @repo.keys_url
53
+ end
54
+
55
+ def test_collaborators_url
56
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/collaborators{/collaborator}", @repo.collaborators_url
57
+ end
58
+
59
+ def test_teams_url
60
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/teams", @repo.teams_url
61
+ end
62
+
63
+ def test_hooks_url
64
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/hooks", @repo.hooks_url
65
+ end
66
+
67
+ def test_issue_events_url
68
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/issues/events{/number}", @repo.issue_events_url
69
+ end
70
+
71
+ def test_events_url
72
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/events", @repo.events_url
73
+ end
74
+
75
+ def test_assignees_url
76
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/assignees{/user}", @repo.assignees_url
77
+ end
78
+
79
+ def test_branches_url
80
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/branches{/branch}", @repo.branches_url
81
+ end
82
+
83
+ def test_tags_url
84
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/tags", @repo.tags_url
85
+ end
86
+
87
+ def test_blobs_url
88
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/git/blobs{/sha}", @repo.blobs_url
89
+ end
90
+
91
+ def test_git_tags_url
92
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/git/tags{/sha}", @repo.git_tags_url
93
+ end
94
+
95
+ def test_git_refs_url
96
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/git/refs{/sha}", @repo.git_refs_url
97
+ end
98
+
99
+ def test_trees_url
100
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/git/trees{/sha}", @repo.trees_url
101
+ end
102
+
103
+ def test_statuses_url
104
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/statuses/{sha}", @repo.statuses_url
105
+ end
106
+
107
+ def test_languages_url
108
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/languages", @repo.languages_url
109
+ end
110
+
111
+ def test_stargazers_url
112
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/stargazers", @repo.stargazers_url
113
+ end
114
+
115
+ def test_contributors_url
116
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/contributors", @repo.contributors_url
117
+ end
118
+
119
+ def test_subscribers_url
120
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/subscribers", @repo.subscribers_url
121
+ end
122
+
123
+ def test_subscription_url
124
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/subscription", @repo.subscription_url
125
+ end
126
+
127
+ def test_commits_url
128
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/commits{/sha}", @repo.commits_url
129
+ end
130
+
131
+ def test_git_commits_url
132
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/git/commits{/sha}", @repo.git_commits_url
133
+ end
134
+
135
+ def test_comments_url
136
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/comments{/number}", @repo.comments_url
137
+ end
138
+
139
+ def test_issue_comment_url
140
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/issues/comments/{number}", @repo.issue_comment_url
141
+ end
142
+
143
+ def test_contents_url
144
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/contents/{+path}", @repo.contents_url
145
+ end
146
+
147
+ def test_compare_url
148
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/compare/{base}...{head}", @repo.compare_url
149
+ end
150
+
151
+ def test_merges_url
152
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/merges", @repo.merges_url
153
+ end
154
+
155
+ def test_archive_url
156
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/{archive_format}{/ref}", @repo.archive_url
157
+ end
158
+
159
+ def test_downloads_url
160
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/downloads", @repo.downloads_url
161
+ end
162
+
163
+ def test_issues_url
164
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/issues{/number}", @repo.issues_url
165
+ end
166
+
167
+ def test_pulls_url
168
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/pulls{/number}", @repo.pulls_url
169
+ end
170
+
171
+ def test_milestones_url
172
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/milestones{/number}", @repo.milestones_url
173
+ end
174
+
175
+ def test_notifications_url
176
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/notifications{?since,all,participating}", @repo.notifications_url
177
+ end
178
+
179
+ def test_labels_url
180
+ assert_equal "https://api.github.com/repos/mikeastock/devlocker/labels{/name}", @repo.labels_url
181
+ end
182
+
183
+ def test_created_at
184
+ assert_equal 1416680049, @repo.created_at
185
+ end
186
+
187
+ def test_updated_at
188
+ assert_equal "2014-11-25T04:30:40Z", @repo.updated_at
189
+ end
190
+
191
+ def test_pushed_at
192
+ assert_equal 1417408510, @repo.pushed_at
193
+ end
194
+
195
+ def test_git_url
196
+ assert_equal "git://github.com/mikeastock/devlocker.git", @repo.git_url
197
+ end
198
+
199
+ def test_ssh_url
200
+ assert_equal "https://github.com/mikeastock/devlocker.git", @repo.clone_url
201
+ end
202
+
203
+ def test_clone_url
204
+ assert_equal "https://github.com/mikeastock/devlocker.git", @repo.clone_url
205
+ end
206
+
207
+ def test_svn_url
208
+ assert_equal "https://github.com/mikeastock/devlocker", @repo.svn_url
209
+ end
210
+
211
+ def test_homepage
212
+ assert_equal nil, @repo.homepage
213
+ end
214
+
215
+ def test_size
216
+ assert_equal 358, @repo.size
217
+ end
218
+
219
+ def test_stargazers_count
220
+ assert_equal 0, @repo.stargazers_count
221
+ end
222
+
223
+ def test_watchers_count
224
+ assert_equal 0, @repo.watchers_count
225
+ end
226
+
227
+ def test_language
228
+ assert_equal "Ruby", @repo.language
229
+ end
230
+
231
+ def test_has_issues
232
+ assert_equal false, @repo.has_issues
233
+ end
234
+
235
+ def test_has_downloads
236
+ assert_equal true, @repo.has_downloads
237
+ end
238
+
239
+ def test_has_wiki
240
+ assert_equal true, @repo.has_wiki
241
+ end
242
+
243
+ def test_has_pages
244
+ assert_equal false, @repo.has_pages
245
+ end
246
+
247
+ def test_forks_count
248
+ assert_equal 0, @repo.forks_count
249
+ end
250
+
251
+ def test_mirror_url
252
+ assert_equal nil, @repo.mirror_url
253
+ end
254
+
255
+ def test_open_issues_count
256
+ assert_equal 2, @repo.open_issues_count
257
+ end
258
+
259
+ def test_forks
260
+ assert_equal 0, @repo.forks
261
+ end
262
+
263
+ def test_open_issues
264
+ assert_equal 2, @repo.open_issues
265
+ end
266
+
267
+ def test_watchers
268
+ assert_equal 0, @repo.watchers
269
+ end
270
+
271
+ def test_default_branch
272
+ assert_equal "master", @repo.default_branch
273
+ end
274
+
275
+ def test_stargazers
276
+ assert_equal 0, @repo.stargazers
277
+ end
278
+
279
+ def test_master_branch
280
+ assert_equal "master", @repo.master_branch
281
+ end
282
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webhook-parcel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - DevLocker Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provide objects for Github Webhook Payloads as well as parse URI's, Filenames
70
+ into Ruby objects
71
+ email:
72
+ - dev@devlocker.io
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/parcel.rb
84
+ - lib/parcel/commit.rb
85
+ - lib/parcel/payload.rb
86
+ - lib/parcel/person.rb
87
+ - lib/parcel/repository.rb
88
+ - lib/parcel/version.rb
89
+ - parcel.gemspec
90
+ - test/commit_webhook.json
91
+ - test/helper.rb
92
+ - test/parcel/test_commit.rb
93
+ - test/parcel/test_payload.rb
94
+ - test/parcel/test_person.rb
95
+ - test/parcel/test_repository.rb
96
+ homepage: https://github.com/devlocker/parcel
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.2.2
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Ruby wrapper for Github Webhook Payloads
120
+ test_files:
121
+ - test/commit_webhook.json
122
+ - test/helper.rb
123
+ - test/parcel/test_commit.rb
124
+ - test/parcel/test_payload.rb
125
+ - test/parcel/test_person.rb
126
+ - test/parcel/test_repository.rb