magnum-payload 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +24 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE +18 -0
  6. data/README.md +107 -0
  7. data/Rakefile +10 -0
  8. data/lib/magnum/payload/base.rb +62 -0
  9. data/lib/magnum/payload/beanstalk.rb +43 -0
  10. data/lib/magnum/payload/bitbucket.rb +53 -0
  11. data/lib/magnum/payload/custom.rb +19 -0
  12. data/lib/magnum/payload/github.rb +50 -0
  13. data/lib/magnum/payload/gitlab.rb +38 -0
  14. data/lib/magnum/payload/gitslice.rb +21 -0
  15. data/lib/magnum/payload/message_parser.rb +11 -0
  16. data/lib/magnum/payload/version.rb +5 -0
  17. data/lib/magnum/payload.rb +24 -0
  18. data/magnum-payload.gemspec +23 -0
  19. data/spec/fixtures/beanstalk/git.json +28 -0
  20. data/spec/fixtures/beanstalk/hg.json +27 -0
  21. data/spec/fixtures/beanstalk/svn.json +15 -0
  22. data/spec/fixtures/bitbucket/git.json +48 -0
  23. data/spec/fixtures/bitbucket/hg.json +48 -0
  24. data/spec/fixtures/github/deleted.json +39 -0
  25. data/spec/fixtures/github/forced.json +58 -0
  26. data/spec/fixtures/github/new_branch.json +77 -0
  27. data/spec/fixtures/github/new_tag.json +58 -0
  28. data/spec/fixtures/github.json +113 -0
  29. data/spec/fixtures/gitlab/commits.json +34 -0
  30. data/spec/fixtures/gitlab/create_branch.json +15 -0
  31. data/spec/fixtures/gitlab/delete_branch.json +15 -0
  32. data/spec/fixtures/gitslice.json +9 -0
  33. data/spec/payload/base_spec.rb +52 -0
  34. data/spec/payload/beanstalk_spec.rb +114 -0
  35. data/spec/payload/bitbucket_spec.rb +94 -0
  36. data/spec/payload/github_spec.rb +74 -0
  37. data/spec/payload/gitlab_spec.rb +53 -0
  38. data/spec/payload/gitslice_spec.rb +33 -0
  39. data/spec/payload/message_parser_spec.rb +45 -0
  40. data/spec/payload_spec.rb +35 -0
  41. data/spec/spec_helper.rb +17 -0
  42. metadata +177 -0
@@ -0,0 +1,21 @@
1
+ module Magnum
2
+ class Payload::Gitslice < Payload::Base
3
+ def parse!
4
+ assign_payload
5
+ end
6
+
7
+ private
8
+
9
+ def assign_payload
10
+ @commit = data.commit
11
+ @author = data.author
12
+ @author_email = data.author_email
13
+ @committer = data.committer
14
+ @committer_email = data.committer_email
15
+ @message = data.message
16
+ @branch = data.branch
17
+ @commit_url = data.commit_url
18
+ @compare_url = data.compare_url
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module Magnum
2
+ module Payload
3
+ module MessageParser
4
+ REGEX_SKIP = /\[(ci skip|ci-skip|skip ci|skip-ci)\]/i
5
+
6
+ def skip_message?
7
+ message.to_s.split("\n").first =~ REGEX_SKIP ? true : false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Magnum
2
+ module Payload
3
+ VERSION = '0.3.0'
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'magnum/payload/version'
2
+
3
+ module Magnum
4
+ module Payload
5
+ class ParseError < StandardError ; end
6
+ class PayloadError < StandardError ; end
7
+
8
+ autoload :Base, 'magnum/payload/base'
9
+ autoload :Custom, 'magnum/payload/custom'
10
+ autoload :Github, 'magnum/payload/github'
11
+ autoload :Gitlab, 'magnum/payload/gitlab'
12
+ autoload :Gitslice, 'magnum/payload/gitslice'
13
+ autoload :Bitbucket, 'magnum/payload/bitbucket'
14
+ autoload :Beanstalk, 'magnum/payload/beanstalk'
15
+ autoload :MessageParser, 'magnum/payload/message_parser'
16
+
17
+ def self.parse(source, payload)
18
+ klass = Magnum::Payload.const_get(source.to_s.capitalize)
19
+ klass.new(payload)
20
+ rescue NameError
21
+ raise PayloadError, "Invalid payload type: #{source}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../lib/magnum/payload/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "magnum-payload"
5
+ s.version = Magnum::Payload::VERSION
6
+ s.summary = "Code payload parser"
7
+ s.description = "Allows to parse code payloads from Github, Bitbucket and many more"
8
+ s.homepage = "https://github.com/magnumci/magnum-payload"
9
+ s.authors = ["Dan Sosedoff"]
10
+ s.email = ["dan.sosedoff@gmail.com"]
11
+
12
+ s.add_development_dependency 'rake', '~> 10'
13
+ s.add_development_dependency 'rspec', '~> 2.13'
14
+ s.add_development_dependency 'simplecov', '~> 0.7'
15
+
16
+ s.add_runtime_dependency 'json', '>= 1.8'
17
+ s.add_runtime_dependency 'hashr', '>= 0'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,28 @@
1
+ {
2
+ "after": "1111111111111111111111111111111111111111",
3
+ "before": "0000000000000000000000000000000000000000",
4
+ "branch": "master",
5
+ "commits": [{
6
+ "author": {
7
+ "email": "john.jones@gmail.com",
8
+ "name": "Mr Jones"
9
+ },
10
+ "id": "1111111111111111111111111111111111111111",
11
+ "message": "Fake commit message",
12
+ "timestamp": "2013-01-30T16:45:07+00:00",
13
+ "url": "http://sosedoff.beanstalkapp.com/xml-sitemap/changesets/1111111111111111111111111111111111111111"
14
+ }],
15
+ "pusher_id": 158046,
16
+ "pusher_name": "Dan Sosedoff",
17
+ "ref": "refs/heads/master",
18
+ "repository": {
19
+ "name": "xml-sitemap",
20
+ "owner": {
21
+ "email": "dan.sosedoff@gmail.com",
22
+ "name": "Dan Sosedoff"
23
+ },
24
+ "private": true,
25
+ "url": "http://sosedoff.beanstalkapp.com/xml-sitemap"
26
+ },
27
+ "uri": "git@sosedoff.beanstalkapp.com:/xml-sitemap.git"
28
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "after": "1111111111111111111111111111111111111111",
3
+ "before": "0000000000000000000000000000000000000000",
4
+ "branch": "default",
5
+ "commits": [{
6
+ "author": {
7
+ "email": "john.jones@gmail.com",
8
+ "name": "Mr Jones"
9
+ },
10
+ "id": "1111111111111111111111111111111111111111",
11
+ "message": "Fake commit message",
12
+ "timestamp": "2013-03-17T05:29:12+00:00",
13
+ "url": "http://sosedoff.beanstalkapp.com/beanstalk-hg1/changesets/1111111111111111111111111111111111111111"
14
+ }],
15
+ "pusher_id": 158046,
16
+ "pusher_name": "Dan Sosedoff",
17
+ "repository": {
18
+ "name": "beanstalk-hg1",
19
+ "owner": {
20
+ "email": "dan.sosedoff@gmail.com",
21
+ "name": "Dan Sosedoff"
22
+ },
23
+ "private": true,
24
+ "url": "http://sosedoff.beanstalkapp.com/beanstalk-hg1"
25
+ },
26
+ "uri": "ssh://hg@sosedoff.beanstalkapp.com:/beanstalk-hg1"
27
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "author": "admin",
3
+ "author_email": null,
4
+ "author_full_name": null,
5
+ "changed_dirs": [
6
+ ["trunk", "add"],
7
+ ["tags", "add"],
8
+ ["branches", "add"]
9
+ ],
10
+ "changed_files": [],
11
+ "changeset_url": "http://sosedoff.beanstalkapp.com/foobar/changesets/1",
12
+ "message": "Creating initial repository structure",
13
+ "revision": 1,
14
+ "time": "2013/02/02 12:32:19 -0600"
15
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "canon_url": "https://bitbucket.org",
3
+ "commits": [{
4
+ "author": "sosedoff",
5
+ "branch": null,
6
+ "branches": [],
7
+ "files": [{
8
+ "file": "date",
9
+ "type": "modified"
10
+ }],
11
+ "message": "Commit Sat Jan 19 18:42:38 CST 2013\n",
12
+ "node": "e15c6013c0f6",
13
+ "parents": ["b160ae1c0007"],
14
+ "raw_author": "Dan Sosedoff <dan.sosedoff@gmail.com>",
15
+ "raw_node": "e15c6013c0f6232153e53b003b97da51d338da3a",
16
+ "revision": null,
17
+ "size": -1,
18
+ "timestamp": "2013-01-20 01:42:38",
19
+ "utctimestamp": "2013-01-20 00:42:38+00:00"
20
+ }, {
21
+ "author": "sosedoff",
22
+ "branch": "master",
23
+ "files": [{
24
+ "file": "date",
25
+ "type": "modified"
26
+ }],
27
+ "message": "Commit Sat Jan 19 18:42:40 CST 2013\n",
28
+ "node": "f15566c42759",
29
+ "parents": ["e15c6013c0f6"],
30
+ "raw_author": "Dan Sosedoff <dan.sosedoff@gmail.com>",
31
+ "raw_node": "f15566c42759198fd32a70963d2509f3f8309586",
32
+ "revision": null,
33
+ "size": -1,
34
+ "timestamp": "2013-01-20 01:42:40",
35
+ "utctimestamp": "2013-01-20 00:42:40+00:00"
36
+ }],
37
+ "repository": {
38
+ "absolute_url": "/sosedoff/test1/",
39
+ "fork": false,
40
+ "is_private": true,
41
+ "name": "test1",
42
+ "owner": "sosedoff",
43
+ "scm": "git",
44
+ "slug": "test1",
45
+ "website": ""
46
+ },
47
+ "user": "sosedoff"
48
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "canon_url": "https://bitbucket.org",
3
+ "commits": [{
4
+ "author": "sosedoff",
5
+ "branch": "default",
6
+ "files": [{
7
+ "file": "date",
8
+ "type": "modified"
9
+ }],
10
+ "message": "Commit 1",
11
+ "node": "c6171d570ebf",
12
+ "parents": ["6dc2aa0cd1d9"],
13
+ "raw_author": "Dan Sosedoff <dan.sosedoff@gmail.com>",
14
+ "raw_node": "c6171d570ebf3283efe24917bd368af7793ea573",
15
+ "revision": 3,
16
+ "size": -1,
17
+ "timestamp": "2013-03-17 06:47:22",
18
+ "utctimestamp": "2013-03-17 05:47:22+00:00"
19
+ }, {
20
+ "author": "sosedoff",
21
+ "branch": "default",
22
+ "files": [{
23
+ "file": "date",
24
+ "type": "modified"
25
+ }],
26
+ "message": "Commit 2",
27
+ "node": "728c1fcc08f1",
28
+ "parents": ["c6171d570ebf"],
29
+ "raw_author": "Dan Sosedoff <dan.sosedoff@gmail.com>",
30
+ "raw_node": "728c1fcc08f1df6bbb0285b980af20e2ef6ea08a",
31
+ "revision": 4,
32
+ "size": -1,
33
+ "timestamp": "2013-03-17 06:47:30",
34
+ "utctimestamp": "2013-03-17 05:47:30+00:00"
35
+ }],
36
+ "repository": {
37
+ "absolute_url": "/sosedoff/mercurial-test/",
38
+ "fork": false,
39
+ "is_private": true,
40
+ "name": "mercurial-test",
41
+ "owner": "sosedoff",
42
+ "scm": "hg",
43
+ "slug": "mercurial-test",
44
+ "website": ""
45
+ },
46
+ "truncated": false,
47
+ "user": "sosedoff"
48
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "forced": true,
3
+ "deleted": true,
4
+ "compare": "https://github.com/sosedoff/lxc-ruby/compare/323388f47818...000000000000",
5
+ "ref": "refs/heads/refactor-shell",
6
+ "created": false,
7
+ "head_commit": null,
8
+ "pusher": {
9
+ "email": "dan.sosedoff@gmail.com",
10
+ "name": "sosedoff"
11
+ },
12
+ "repository": {
13
+ "id": 4451730,
14
+ "created_at": 1337995024,
15
+ "url": "https://github.com/sosedoff/lxc-ruby",
16
+ "fork": false,
17
+ "master_branch": "master",
18
+ "name": "lxc-ruby",
19
+ "language": "Ruby",
20
+ "private": false,
21
+ "pushed_at": 1362550211,
22
+ "watchers": 45,
23
+ "has_wiki": true,
24
+ "owner": {
25
+ "email": "dan.sosedoff@gmail.com",
26
+ "name": "sosedoff"
27
+ },
28
+ "forks": 8,
29
+ "description": "Ruby wrapper for LXC cli tools",
30
+ "has_downloads": true,
31
+ "open_issues": 0,
32
+ "has_issues": true,
33
+ "stargazers": 45,
34
+ "size": 208
35
+ },
36
+ "commits": [],
37
+ "before": "323388f478183ddf4ddd8adb649b416dcdbd1319",
38
+ "after": "0000000000000000000000000000000000000000"
39
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "pusher": {
3
+ "name": "nysa",
4
+ "email": "nysa@nysavann.com"
5
+ },
6
+ "repository": {
7
+ "master_branch": "master",
8
+ "name": "ruby-opencnam",
9
+ "created_at": "2012-06-20T22:44:25-07:00",
10
+ "has_wiki": true,
11
+ "size": 224,
12
+ "private": false,
13
+ "watchers": 3,
14
+ "language": "Ruby",
15
+ "fork": false,
16
+ "url": "https://github.com/nysa/ruby-opencnam",
17
+ "pushed_at": "2013-03-04T20:17:31-08:00",
18
+ "id": 4735183,
19
+ "has_downloads": true,
20
+ "open_issues": 0,
21
+ "has_issues": true,
22
+ "forks": 0,
23
+ "stargazers": 3,
24
+ "description": "A Ruby wrapper for the OpenCNAM API service.",
25
+ "owner": {
26
+ "name": "nysa",
27
+ "email": "nysa@nysavann.com"
28
+ }
29
+ },
30
+ "forced": true,
31
+ "head_commit": {
32
+ "modified": ["README.md"],
33
+ "added": [],
34
+ "removed": [],
35
+ "author": {
36
+ "name": "Nysa",
37
+ "username": "nysa",
38
+ "email": "nysa@nysavann.com"
39
+ },
40
+ "timestamp": "2013-03-04T20:08:06-08:00",
41
+ "url": "https://github.com/nysa/ruby-opencnam/commit/e7508c4c70d2c5afc1e6c2f3a42ecc098f435103",
42
+ "id": "e7508c4c70d2c5afc1e6c2f3a42ecc098f435103",
43
+ "distinct": true,
44
+ "message": "Update README.md",
45
+ "committer": {
46
+ "name": "Nysa",
47
+ "username": "nysa",
48
+ "email": "nysa@nysavann.com"
49
+ }
50
+ },
51
+ "after": "acef953424e5b7b067277075d6d054a9290eb626",
52
+ "deleted": false,
53
+ "commits": [],
54
+ "ref": "refs/heads/master",
55
+ "compare": "https://github.com/nysa/ruby-opencnam/compare/v1.0.0",
56
+ "before": "0000000000000000000000000000000000000000",
57
+ "created": true
58
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "after": "d9cc46f9e7e6aa65df696d8d1efe86de755b46ae",
3
+ "before": "0000000000000000000000000000000000000000",
4
+ "commits": [{
5
+ "added": ["file"],
6
+ "author": {
7
+ "email": "dan.sosedoff@gmail.com",
8
+ "name": "Dan Sosedoff",
9
+ "username": "sosedoff"
10
+ },
11
+ "committer": {
12
+ "email": "dan.sosedoff@gmail.com",
13
+ "name": "Dan Sosedoff",
14
+ "username": "sosedoff"
15
+ },
16
+ "distinct": true,
17
+ "id": "d9cc46f9e7e6aa65df696d8d1efe86de755b46ae",
18
+ "message": "Test message",
19
+ "modified": [],
20
+ "removed": [],
21
+ "timestamp": "2013-03-24T13:05:06-07:00",
22
+ "url": "https://github.com/sosedoff/sample/commit/d9cc46f9e7e6aa65df696d8d1efe86de755b46ae"
23
+ }
24
+ ],
25
+ "compare": "https://github.com/sosedoff/sample/commit/d9cc46f9e7e6",
26
+ "created": true,
27
+ "deleted": false,
28
+ "forced": true,
29
+ "head_commit": {
30
+ "added": ["file"],
31
+ "author": {
32
+ "email": "dan.sosedoff@gmail.com",
33
+ "name": "Dan Sosedoff",
34
+ "username": "sosedoff"
35
+ },
36
+ "committer": {
37
+ "email": "dan.sosedoff@gmail.com",
38
+ "name": "Dan Sosedoff",
39
+ "username": "sosedoff"
40
+ },
41
+ "distinct": true,
42
+ "id": "d9cc46f9e7e6aa65df696d8d1efe86de755b46ae",
43
+ "message": "Test message",
44
+ "modified": [],
45
+ "removed": [],
46
+ "timestamp": "2013-03-24T13:05:06-07:00",
47
+ "url": "https://github.com/sosedoff/sample/commit/d9cc46f9e7e6aa65df696d8d1efe86de755b46ae"
48
+ },
49
+ "pusher": {
50
+ "email": "dan.sosedoff@gmail.com",
51
+ "name": "sosedoff"
52
+ },
53
+ "ref": "refs/heads/hello",
54
+ "repository": {
55
+ "created_at": 1364155438,
56
+ "description": "",
57
+ "fork": false,
58
+ "forks": 0,
59
+ "has_downloads": true,
60
+ "has_issues": true,
61
+ "has_wiki": true,
62
+ "id": 8992288,
63
+ "master_branch": "master",
64
+ "name": "sample",
65
+ "open_issues": 0,
66
+ "owner": {
67
+ "email": "dan.sosedoff@gmail.com",
68
+ "name": "sosedoff"
69
+ },
70
+ "private": true,
71
+ "pushed_at": 1364155506,
72
+ "size": 152,
73
+ "stargazers": 0,
74
+ "url": "https://github.com/sosedoff/sample",
75
+ "watchers": 0
76
+ }
77
+ }