octogate 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 9d8aa41425c8878a5c93d417a2860bee799fd838
4
- data.tar.gz: 42f4002ab39a5520b20993556bdefc6c6a4b9a2a
3
+ metadata.gz: 5a994b0eb25ab164f28db0c36d88f4a2b68c3e2d
4
+ data.tar.gz: 5496fb198cde84dfa126910127951d1aed2169f1
5
5
  SHA512:
6
- metadata.gz: 6efc13bf5526eb0605be1b4034a577bfb6a7845d65d82746b7bd60fddc127b459ccc816185d51d331df2bc6bb87ddfebe62ba9bb93b028456102b95d74bf8544
7
- data.tar.gz: 1d2ce3e644677d8499b683e676b7a67eef6d0411eb96a67bd7f2e2754da53ada822fba704642ba589d8df82ba7b732a9c125bf06c9ea53758ace7bcecde632f7
6
+ metadata.gz: ebba77b1218442605f45bf6de1bcb2ff44f2f0ead226c54e8983920b038f86a891d7306f7447085aa8115813442db886ee6f24c599120a86a5f3077f6cef19cd
7
+ data.tar.gz: c934a0a9a3125cbf9beca2dfcf25d6ddc4badfaff28c7a89c3d62d32ac1e11d32522204972aca3db77789aaadef509f00981dedb41ce0d5f3cd3dde69c7f54e1
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Octogate
2
+ [![Gem Version](https://badge.fury.io/rb/octogate.png)](http://badge.fury.io/rb/octogate)
2
3
  [![Build Status](https://travis-ci.org/joker1007/octogate.png?branch=master)](https://travis-ci.org/joker1007/octogate)
3
4
  [![Code Climate](https://codeclimate.com/github/joker1007/octogate.png)](https://codeclimate.com/github/joker1007/octogate)
4
5
 
@@ -20,6 +21,10 @@ Or install it yourself as:
20
21
 
21
22
  $ gem install octogate
22
23
 
24
+ ## Requirements
25
+
26
+ - Ruby-2.0.0 or later
27
+
23
28
  ## Usage
24
29
 
25
30
  Write config.rb.
@@ -29,31 +34,33 @@ token "token_string"
29
34
 
30
35
  target "jenkins" do
31
36
  hook_type [:push, :pull_request]
32
- url "http://targethost.dev/job/CommitStage"
33
- http_method :get
37
+ url "http://targethost.dev/job/JobName"
38
+ http_method :post
34
39
 
35
40
  parameter_type :query
36
41
  params key1: "value1", key2: "value2"
37
42
 
38
- match -> {
39
- hook.ref =~ /master/
43
+ match ->(event) {
44
+ event.ref =~ /master/
40
45
  }
41
46
  end
42
47
 
43
- target "jenkins2" do
48
+ target "json_params" do
44
49
  hook_type [:push, :pull_request]
45
- url "http://targethost2.dev/job/CommitStage"
46
- http_method :get
50
+ url "http://targethost.dev/job/JobName"
51
+ http_method :post
47
52
 
48
53
  parameter_type :json
49
54
  params key1: "value1", key2: "value2"
50
55
 
51
- match -> {
52
- !(hook.ref =~ /master/)
56
+ match ->(event) {
57
+ event.ref =~ /json_params/
53
58
  }
54
59
  end
55
60
  ```
56
61
 
62
+ More sample is [hear](https://github.com/joker1007/octogate/blob/master/spec/config_sample.rb)
63
+
57
64
  And launch server.
58
65
 
59
66
  ```sh
@@ -67,6 +74,11 @@ Usage: octogate [options]
67
74
  # => Endpoint is http://hostname:4567/token_string
68
75
  ```
69
76
 
77
+ ## Event Capability
78
+
79
+ - Push Event
80
+ - PullRequest Event
81
+
70
82
  ## Contributing
71
83
 
72
84
  1. Fork it ( https://github.com/joker1007/octogate/fork )
@@ -3,6 +3,7 @@ require "octogate/version"
3
3
  require "active_support/core_ext/hash"
4
4
  require "active_support/core_ext/object"
5
5
  require "oj"
6
+ require "hashie"
6
7
 
7
8
  require "octogate/configuration"
8
9
 
@@ -11,6 +12,10 @@ module Octogate
11
12
  def config
12
13
  @config ||= Configuration.instance
13
14
  end
15
+
16
+ def find_target(key)
17
+ @config.targets.fetch(key)
18
+ end
14
19
  end
15
20
  end
16
21
 
@@ -1,5 +1,7 @@
1
1
  require "faraday"
2
2
  require "uri"
3
+ require "active_support/core_ext/object"
4
+ require "octogate/transfer_request"
3
5
 
4
6
  class Octogate::Client
5
7
  attr_reader :event
@@ -9,17 +11,8 @@ class Octogate::Client
9
11
  end
10
12
 
11
13
  def request_to_targets
12
- Octogate.config.targets.each do |t|
13
- condition = event.default_condition
14
- case t.match
15
- when Proc
16
- condition = condition && instance_exec(event, &t.match)
17
- when nil
18
- else
19
- condition = condition && !!t.match
20
- end
21
-
22
- if condition
14
+ Octogate.config.targets.each do |target_name, t|
15
+ if match_target?(t)
23
16
  request(t)
24
17
  end
25
18
  end
@@ -37,26 +30,28 @@ class Octogate::Client
37
30
 
38
31
  case t.http_method
39
32
  when :get
40
- conn.get do |req|
41
- req.url uri.path
42
- params.each do |k, v|
43
- req.params[k] = v
44
- end
45
- end
33
+ Octogate::TransferRequest::GET.new(conn)
34
+ .do_request(url: uri.path, params: params)
46
35
  when :post
47
- if t.parameter_type == :json
48
- conn.post uri.path do |req|
49
- req.headers['Content-Type'] = 'application/json'
50
- req.body = Oj.dump(params)
51
- end
52
- else
53
- conn.post uri.path, params
54
- end
36
+ Octogate::TransferRequest::POST.new(conn)
37
+ .do_request(url: uri.path, params: params, parameter_type: t.parameter_type)
55
38
  end
56
39
  end
57
40
 
58
41
  private
59
42
 
43
+ def match_target?(target)
44
+ condition = event.default_condition && target.include_event?(event)
45
+ case target.match
46
+ when Proc
47
+ condition && instance_exec(event, &target.match)
48
+ when nil
49
+ condition
50
+ else
51
+ condition && !!target.match
52
+ end
53
+ end
54
+
60
55
  def build_connection(options, username = nil, password = nil)
61
56
  conn = Faraday.new(options) do |faraday|
62
57
  faraday.request :url_encoded
@@ -75,3 +70,4 @@ class Octogate::Client
75
70
  end
76
71
  end
77
72
  end
73
+
@@ -6,8 +6,8 @@ module Octogate
6
6
  instance.instance_eval(File.read(config_file), config_file)
7
7
  instance.instance_eval do
8
8
  @_target_builders.each do |tb|
9
- Octogate.config.targets ||= []
10
- Octogate.config.targets << tb.__to_target__
9
+ Octogate.config.targets ||= {}
10
+ Octogate.config.targets[tb.name] = tb.__to_target__
11
11
  end
12
12
  end
13
13
  end
@@ -22,7 +22,7 @@ module Octogate
22
22
  end
23
23
 
24
24
  def target(name, &block)
25
- builder = TargetBuilder.new
25
+ builder = TargetBuilder.new(name)
26
26
  builder.instance_eval(&block)
27
27
  @_target_builders << builder
28
28
  end
@@ -6,7 +6,7 @@ module Octogate
6
6
  attr_accessor :targets, :token, :ca_file, :ssl_verify
7
7
 
8
8
  def initialize
9
- @targets ||= []
9
+ @targets ||= {}
10
10
  @ssl_verify = true
11
11
  end
12
12
  end
@@ -1,7 +1,22 @@
1
+ require "active_support/core_ext/hash"
1
2
  module Octogate
2
3
  module Event
4
+ autoload :Push , "octogate/events/push"
5
+ autoload :PullRequest , "octogate/events/pull_request"
6
+
7
+ class << self
8
+ def register_event(name, klass)
9
+ @events ||= {}.with_indifferent_access
10
+ @events[name] = klass
11
+ end
12
+
13
+ def get(name)
14
+ @events.fetch(name) do
15
+ raise NotRegisteredEvent.new(name)
16
+ end
17
+ end
18
+ end
3
19
  end
4
- end
5
20
 
6
- require "octogate/events/base"
7
- require "octogate/events/push"
21
+ class NotRegisteredEvent < StandardError; end
22
+ end
@@ -1,6 +1,10 @@
1
1
  module Octogate
2
- class Event::Base
3
- include Octogate::Model
2
+ class Event::Base < Octogate::Model
3
+ class << self
4
+ def register_event(name, klass)
5
+ Octogate::Event.register_event(name, klass)
6
+ end
7
+ end
4
8
 
5
9
  def default_condition
6
10
  true
@@ -0,0 +1,24 @@
1
+ require "octogate/events/base"
2
+ require "octogate/gh"
3
+
4
+ module Octogate
5
+ class Event::PullRequest < Event::Base
6
+ register_event :pull_request, self
7
+
8
+ coerce_key :pull_request, GH::PullRequest
9
+ coerce_key :repository, GH::Repository
10
+ coerce_key :sender, GH::User
11
+
12
+ class << self
13
+ def parse(json)
14
+ payload = Oj.load(json).deep_symbolize_keys
15
+
16
+ new(payload)
17
+ end
18
+ end
19
+
20
+ def default_condition
21
+ action != "closed"
22
+ end
23
+ end
24
+ end
@@ -1,30 +1,24 @@
1
+ require "octogate/events/base"
2
+ require "octogate/gh"
3
+
1
4
  module Octogate
2
5
  class Event::Push < Event::Base
3
- attr_reader :ref, :after, :before, :created, :deleted, :forced, :compare, :commits, :head_commit, :repository, :pusher
6
+ register_event :push, self
7
+
8
+ coerce_key :head_commit, GH::Commit
9
+ coerce_key :repository, GH::Repository
10
+
4
11
  class << self
5
12
  def parse(json)
6
13
  payload = Oj.load(json).deep_symbolize_keys
7
14
 
8
- commits = payload[:commits].map do |c|
15
+ commits = payload[:commits].nil? ? [] : payload.delete(:commits).map do |c|
9
16
  GH::Commit.new(c.symbolize_keys)
10
17
  end
11
18
 
12
- head_commit = payload[:head_commit] ? GH::Commit.new(payload[:head_commit]) : nil
13
-
14
- repository = GH::Repository.new(payload[:repository])
19
+ attrs = payload.merge(commits: commits)
15
20
 
16
- new(
17
- ref: payload[:ref],
18
- after: payload[:after],
19
- before: payload[:before],
20
- created: payload[:created],
21
- deleted: payload[:deleted],
22
- forced: payload[:forced],
23
- compare: payload[:compare],
24
- commits: commits,
25
- head_commit: head_commit,
26
- repository: repository,
27
- )
21
+ new(attrs)
28
22
  end
29
23
  end
30
24
 
@@ -1,8 +1,8 @@
1
1
  module Octogate
2
2
  module GH
3
+ autoload :Commit , "octogate/gh/commit"
4
+ autoload :Repository , "octogate/gh/repository"
5
+ autoload :User , "octogate/gh/user"
6
+ autoload :PullRequest , "octogate/gh/pull_request"
3
7
  end
4
8
  end
5
-
6
- require "octogate/gh/commit"
7
- require "octogate/gh/repository"
8
- require "octogate/gh/user"
@@ -1,14 +1,11 @@
1
- module Octogate
2
- class GH::Commit
3
- include Model
4
-
5
- attr_reader :id, :distinct, :message, :timestamp, :url, :author, :commiter, :added, :removed, :modified
1
+ require "octogate/gh/user"
2
+ require "octogate/gh/repository"
6
3
 
7
- def initialize(**args)
8
- new_args = args.deep_symbolize_keys
9
- new_args[:author] = GH::User.new(new_args[:author]) if new_args[:author]
10
- new_args[:committer] = GH::User.new(new_args[:committer]) if new_args[:committer]
11
- super(new_args)
12
- end
4
+ module Octogate
5
+ class GH::Commit < Model
6
+ coerce_key :user, GH::User
7
+ coerce_key :repo, GH::Repository
8
+ coerce_key :author, GH::User
9
+ coerce_key :committer, GH::User
13
10
  end
14
11
  end
@@ -0,0 +1,9 @@
1
+ require "octogate/gh/user"
2
+
3
+ module Octogate
4
+ class GH::PullRequest < Model
5
+ coerce_key :user, GH::User
6
+ coerce_key :head, GH::Commit
7
+ coerce_key :base, GH::Commit
8
+ end
9
+ end
@@ -1,13 +1,7 @@
1
- module Octogate
2
- class GH::Repository
3
- include Model
4
-
5
- attr_reader :id, :name, :description, :homepage, :watchers, :stargazers, :forks, :fork, :size, :owner, :private, :open_issues, :has_issues, :has_downloads, :has_wiki, :language, :created_at, :pushed_at, :master_branch, :pusher
1
+ require "octogate/gh/user"
6
2
 
7
- def initialize(**args)
8
- new_args = args.deep_symbolize_keys
9
- new_args[:owner] = GH::User.new(new_args[:owner]) if new_args[:owner]
10
- super(new_args)
11
- end
3
+ module Octogate
4
+ class GH::Repository < Model
5
+ coerce_key :owner, GH::User
12
6
  end
13
7
  end
@@ -1,7 +1,4 @@
1
1
  module Octogate
2
- class GH::User
3
- include Model
4
-
5
- attr_reader :name, :email, :username
2
+ class GH::User < Model
6
3
  end
7
4
  end
@@ -1,7 +1,3 @@
1
- module Octogate::Model
2
- def initialize(**args)
3
- args.each do |k, v|
4
- send("instance_variable_set", "@#{k}", v)
5
- end
6
- end
1
+ class Octogate::Model < Hashie::Mash
2
+ include Hashie::Extensions::Coercion
7
3
  end
@@ -13,11 +13,9 @@ class Octogate::Server < Sinatra::Base
13
13
  end
14
14
 
15
15
  event_name = request.env["HTTP_X_GITHUB_EVENT"]
16
- case event_name
17
- when "push"
18
- event = Octogate::Event::Push.parse(params[:payload])
19
- Octogate::Client.new(event).request_to_targets
20
- end
16
+ event_klass = Octogate::Event.get(event_name)
17
+ event = event_klass.parse(params[:payload])
18
+ Octogate::Client.new(event).request_to_targets
21
19
 
22
20
  return
23
21
  end
@@ -1,7 +1,11 @@
1
1
  module Octogate
2
- class Target
3
- include Model
2
+ class Target < Model
3
+ def include_event?(event)
4
+ event_klasses = hook_type.nil? ? [] : hook_type.map do |name|
5
+ Octogate::Event.get(name)
6
+ end
4
7
 
5
- attr_reader :url, :username, :password, :hook_type, :http_method, :parameter_type, :params, :match
8
+ event_klasses.include?(event.is_a?(Octogate::Event::Base) ? event.class : event)
9
+ end
6
10
  end
7
11
  end
@@ -1,6 +1,9 @@
1
1
  module Octogate
2
2
  class TargetBuilder
3
- def initialize
3
+ attr_reader :name
4
+
5
+ def initialize(name)
6
+ @name = name
4
7
  @url = nil
5
8
  @username = nil
6
9
  @password = nil
@@ -0,0 +1,40 @@
1
+ module Octogate
2
+ module TransferRequest
3
+ class Base
4
+ attr_reader :conn
5
+
6
+ def initialize(conn)
7
+ @conn = conn
8
+ end
9
+
10
+ def do_request(**options)
11
+ raise NotImplementedError
12
+ end
13
+ end
14
+
15
+ class GET < Base
16
+ def do_request(**options)
17
+ conn.get do |req|
18
+ req.url options[:url]
19
+ options[:params].each do |k, v|
20
+ req.params[k] = v
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+
27
+ class POST < Base
28
+ def do_request(**options)
29
+ if options[:parameter_type] == :json && options[:params]
30
+ conn.post options[:url] do |req|
31
+ req.headers['Content-Type'] = 'application/json'
32
+ req.body = Oj.dump(options[:params])
33
+ end
34
+ else
35
+ conn.post options[:url], options[:params]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Octogate
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "activesupport", ">= 4"
23
23
  spec.add_runtime_dependency "oj"
24
24
  spec.add_runtime_dependency "faraday"
25
+ spec.add_runtime_dependency "hashie"
25
26
 
26
27
  spec.add_development_dependency "bundler", ">= 1.5"
27
28
  spec.add_development_dependency "rake"
@@ -1,7 +1,8 @@
1
1
  token "token"
2
+ # ssl_verify false
2
3
 
3
4
  target "jenkins" do
4
- hook_type [:push, :pull_request]
5
+ hook_type [:push]
5
6
  url "http://targethost.dev/job/JobName"
6
7
  http_method :post
7
8
 
@@ -13,7 +14,7 @@ target "jenkins" do
13
14
  }
14
15
  end
15
16
 
16
- target "jenkins2" do
17
+ target "json_params" do
17
18
  hook_type [:push, :pull_request]
18
19
  url "http://targethost.dev/job/JobName"
19
20
  http_method :post
@@ -22,7 +23,12 @@ target "jenkins2" do
22
23
  params key1: "value1", key2: "value2"
23
24
 
24
25
  match ->(event) {
25
- event.ref =~ /json_params/
26
+ case event
27
+ when Octogate::Event::PullRequest
28
+ event.try(:pull_request).try(:head).try(:ref) =~ /json_params/
29
+ when Octogate::Event::Push
30
+ event.ref =~ /json_params/
31
+ end
26
32
  }
27
33
  end
28
34
 
@@ -64,6 +70,13 @@ target "always" do
64
70
  params always: "true"
65
71
  end
66
72
 
73
+ target "always_push_only" do
74
+ url "http://targethost.dev/job/JobName"
75
+ http_method :post
76
+
77
+ params always: "push_only"
78
+ end
79
+
67
80
  target "never" do
68
81
  hook_type [:push, :pull_request]
69
82
  url "http://targethost.dev/job/JobName"
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Octogate::Client do
4
4
  describe "#request_to_targets" do
5
- let(:event) { Octogate::Event::Push.parse(push_payload) }
5
+ let(:event) { Octogate::Event::Push.parse(read_payload(:push)) }
6
6
 
7
7
  before do
8
8
  stub_request(:post, "http://targethost.dev/job/JobName")
@@ -18,6 +18,41 @@ describe Octogate::Client do
18
18
  client.request_to_targets
19
19
  expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {key1: "value1", key2: "value2"})
20
20
  expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {always: "true"})
21
+ expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {always: "push_only"})
22
+ expect(WebMock).not_to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {never: "true"})
23
+ end
24
+
25
+ describe "matching rule" do
26
+ it "request only targets that match rule" do
27
+ event = Octogate::Event::Push.new(ref: "json_params")
28
+ client = Octogate::Client.new(event)
29
+ expect(client).to receive(:request).with(Octogate.find_target("json_params"))
30
+ expect(client).to receive(:request).with(Octogate.find_target("always"))
31
+ expect(client).to receive(:request).with(Octogate.find_target("always_push_only"))
32
+ client.request_to_targets
33
+ end
34
+ end
35
+
36
+ describe "matching hook_type" do
37
+ it "request only targets that match hook_type" do
38
+ event = Octogate::Event::PullRequest.new(action: "opened", pull_request: {head: {ref: "json_params"}})
39
+ client = Octogate::Client.new(event)
40
+ expect(client).to receive(:request).with(Octogate.find_target("json_params"))
41
+ expect(client).to receive(:request).with(Octogate.find_target("always"))
42
+ expect(client).not_to receive(:request).with(Octogate.find_target("always_push_only"))
43
+ client.request_to_targets
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "#request" do
49
+ before do
50
+ stub_request(:post, "http://targethost.dev/job/JobName")
51
+ .to_return(:status => 200, :body => "", :headers => {})
52
+ end
53
+
54
+ after do
55
+ WebMock.reset!
21
56
  end
22
57
 
23
58
  it "can use event attributes on request parameter" do
@@ -27,7 +62,7 @@ describe Octogate::Client do
27
62
  )
28
63
 
29
64
  client = Octogate::Client.new(event)
30
- client.request_to_targets
65
+ client.request(Octogate.find_target("block params"))
31
66
  expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {ref: event.ref, head_commit_id: event.head_commit.id})
32
67
  end
33
68
 
@@ -37,28 +72,18 @@ describe Octogate::Client do
37
72
  )
38
73
 
39
74
  client = Octogate::Client.new(event)
40
- client.request_to_targets
75
+ client.request(Octogate.find_target("always"))
41
76
  expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {always: "true"})
42
77
  end
43
78
 
44
- it "never request to target that have false match rule" do
45
- event = Octogate::Event::Push.new(
46
- ref: "refs/heads/master",
47
- )
48
-
49
- client = Octogate::Client.new(event)
50
- client.request_to_targets
51
- expect(WebMock).not_to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {never: "true"})
52
- end
53
-
54
79
  it "can request with json parameters" do
55
80
  event = Octogate::Event::Push.new(
56
81
  ref: "refs/heads/json_params",
57
82
  )
58
83
 
59
84
  client = Octogate::Client.new(event)
60
- client.request_to_targets
61
- expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: Oj.dump({key1: "value1", key2: "value2"}), headers: {'Content-Type' => 'application/json'})
85
+ client.request(Octogate.find_target("json_params"))
86
+ expect(WebMock).to have_requested(:post, "http://targethost.dev/job/JobName").with(body: {key1: "value1", key2: "value2"}, headers: {'Content-Type' => 'application/json'})
62
87
  end
63
88
 
64
89
  it "can use basic authentication" do
@@ -70,7 +95,7 @@ describe Octogate::Client do
70
95
  )
71
96
 
72
97
  client = Octogate::Client.new(event)
73
- client.request_to_targets
98
+ client.request(Octogate.find_target("basic auth"))
74
99
  expect(WebMock).to have_requested(:post, "http://username_sample:password_sample@targethost.dev/job/JobName").with(body: {key1: "value1", key2: "value2"})
75
100
  end
76
101
  end
@@ -4,7 +4,7 @@ describe Octogate::ConfigLoader do
4
4
  describe ".load_config" do
5
5
  before do
6
6
  Octogate.config.token = nil
7
- Octogate.config.targets = []
7
+ Octogate.config.targets = {}
8
8
  end
9
9
 
10
10
  subject { Octogate::ConfigLoader.load_config(config_file) }
@@ -14,13 +14,13 @@ describe Octogate::ConfigLoader do
14
14
  from_targets = Octogate.config.targets
15
15
 
16
16
  expect(from_token).to be_nil
17
- expect(from_targets).to eq([])
17
+ expect(from_targets).to eq({})
18
18
 
19
19
  subject
20
20
 
21
21
  expect(Octogate.config.token).to eq("token")
22
- expect(Octogate.config.targets).to have(6).item
23
- expect(Octogate.config.targets.first).to be_a Octogate::Target
22
+ expect(Octogate.config.targets).to have(7).item
23
+ expect(Octogate.config.targets["jenkins"]).to be_a Octogate::Target
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octogate::Event::PullRequest do
4
+ describe ".parse" do
5
+ subject { described_class.parse(read_payload(:pull_request)) }
6
+ it { should be_a described_class }
7
+
8
+ it { expect(subject.action).to eq "opened" }
9
+ it { expect(subject.number).to eq 2 }
10
+ it { expect(subject.pull_request).to be_a Octogate::GH::PullRequest }
11
+ it { expect(subject.pull_request.base).to be_a Octogate::GH::Commit }
12
+ it { expect(subject.pull_request.head).to be_a Octogate::GH::Commit }
13
+ end
14
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Octogate::Event::Push do
4
4
  describe ".parse" do
5
- subject { described_class.parse(push_payload) }
5
+ subject { described_class.parse(read_payload(:push)) }
6
6
  it { should be_a described_class }
7
7
 
8
8
  it { expect(subject.ref).to eq "refs/heads/master" }
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octogate::Event do
4
+ describe ".get" do
5
+ it "returns registerd event class" do
6
+ expect(Octogate::Event.get(:push)).to eq Octogate::Event::Push
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octogate::Target do
4
+ describe "#include_event?" do
5
+ let(:target) { described_class.new(hook_type: [:push]) }
6
+
7
+ context "hook_type include Given Event" do
8
+ subject { target.include_event?(Octogate::Event::Push) }
9
+
10
+ it { should be_true }
11
+ end
12
+
13
+ context "hook_type not include Given Event" do
14
+ subject { target.include_event?(Octogate::Event::PullRequest) }
15
+
16
+ it { should be_false }
17
+ end
18
+
19
+ context "Given event instance" do
20
+ subject { target.include_event?(Octogate::Event::Push.new()) }
21
+
22
+ it { should be_true }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,411 @@
1
+ {
2
+ "action": "opened",
3
+ "number": 2,
4
+ "pull_request": {
5
+ "url": "https://api.github.com/repos/joker1007/octogate/pulls/2",
6
+ "id": 13092314,
7
+ "html_url": "https://github.com/joker1007/octogate/pull/2",
8
+ "diff_url": "https://github.com/joker1007/octogate/pull/2.diff",
9
+ "patch_url": "https://github.com/joker1007/octogate/pull/2.patch",
10
+ "issue_url": "https://api.github.com/repos/joker1007/octogate/issues/2",
11
+ "number": 2,
12
+ "state": "open",
13
+ "title": "PullRequest Eventのフックに対応する",
14
+ "user": {
15
+ "login": "joker1007",
16
+ "id": 116996,
17
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
18
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
19
+ "url": "https://api.github.com/users/joker1007",
20
+ "html_url": "https://github.com/joker1007",
21
+ "followers_url": "https://api.github.com/users/joker1007/followers",
22
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
23
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
24
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
25
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
26
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
27
+ "repos_url": "https://api.github.com/users/joker1007/repos",
28
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
29
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
30
+ "type": "User",
31
+ "site_admin": false
32
+ },
33
+ "body": null,
34
+ "created_at": "2014-03-02T14:09:01Z",
35
+ "updated_at": "2014-03-02T14:09:01Z",
36
+ "closed_at": null,
37
+ "merged_at": null,
38
+ "merge_commit_sha": null,
39
+ "assignee": null,
40
+ "milestone": null,
41
+ "commits_url": "https://api.github.com/repos/joker1007/octogate/pulls/2/commits",
42
+ "review_comments_url": "https://api.github.com/repos/joker1007/octogate/pulls/2/comments",
43
+ "review_comment_url": "https://api.github.com/repos/joker1007/octogate/pulls/comments/{number}",
44
+ "comments_url": "https://api.github.com/repos/joker1007/octogate/issues/2/comments",
45
+ "statuses_url": "https://api.github.com/repos/joker1007/octogate/statuses/2e4c627e285b3c09993f5ef50fbe8de5481f48a3",
46
+ "head": {
47
+ "label": "joker1007:add_pull_request_event",
48
+ "ref": "add_pull_request_event",
49
+ "sha": "2e4c627e285b3c09993f5ef50fbe8de5481f48a3",
50
+ "user": {
51
+ "login": "joker1007",
52
+ "id": 116996,
53
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
54
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
55
+ "url": "https://api.github.com/users/joker1007",
56
+ "html_url": "https://github.com/joker1007",
57
+ "followers_url": "https://api.github.com/users/joker1007/followers",
58
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
59
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
60
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
61
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
62
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
63
+ "repos_url": "https://api.github.com/users/joker1007/repos",
64
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
65
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
66
+ "type": "User",
67
+ "site_admin": false
68
+ },
69
+ "repo": {
70
+ "id": 17311500,
71
+ "name": "octogate",
72
+ "full_name": "joker1007/octogate",
73
+ "owner": {
74
+ "login": "joker1007",
75
+ "id": 116996,
76
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
77
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
78
+ "url": "https://api.github.com/users/joker1007",
79
+ "html_url": "https://github.com/joker1007",
80
+ "followers_url": "https://api.github.com/users/joker1007/followers",
81
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
82
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
83
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
84
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
85
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
86
+ "repos_url": "https://api.github.com/users/joker1007/repos",
87
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
88
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
89
+ "type": "User",
90
+ "site_admin": false
91
+ },
92
+ "private": false,
93
+ "html_url": "https://github.com/joker1007/octogate",
94
+ "description": "Github hook proxy server",
95
+ "fork": false,
96
+ "url": "https://api.github.com/repos/joker1007/octogate",
97
+ "forks_url": "https://api.github.com/repos/joker1007/octogate/forks",
98
+ "keys_url": "https://api.github.com/repos/joker1007/octogate/keys{/key_id}",
99
+ "collaborators_url": "https://api.github.com/repos/joker1007/octogate/collaborators{/collaborator}",
100
+ "teams_url": "https://api.github.com/repos/joker1007/octogate/teams",
101
+ "hooks_url": "https://api.github.com/repos/joker1007/octogate/hooks",
102
+ "issue_events_url": "https://api.github.com/repos/joker1007/octogate/issues/events{/number}",
103
+ "events_url": "https://api.github.com/repos/joker1007/octogate/events",
104
+ "assignees_url": "https://api.github.com/repos/joker1007/octogate/assignees{/user}",
105
+ "branches_url": "https://api.github.com/repos/joker1007/octogate/branches{/branch}",
106
+ "tags_url": "https://api.github.com/repos/joker1007/octogate/tags",
107
+ "blobs_url": "https://api.github.com/repos/joker1007/octogate/git/blobs{/sha}",
108
+ "git_tags_url": "https://api.github.com/repos/joker1007/octogate/git/tags{/sha}",
109
+ "git_refs_url": "https://api.github.com/repos/joker1007/octogate/git/refs{/sha}",
110
+ "trees_url": "https://api.github.com/repos/joker1007/octogate/git/trees{/sha}",
111
+ "statuses_url": "https://api.github.com/repos/joker1007/octogate/statuses/{sha}",
112
+ "languages_url": "https://api.github.com/repos/joker1007/octogate/languages",
113
+ "stargazers_url": "https://api.github.com/repos/joker1007/octogate/stargazers",
114
+ "contributors_url": "https://api.github.com/repos/joker1007/octogate/contributors",
115
+ "subscribers_url": "https://api.github.com/repos/joker1007/octogate/subscribers",
116
+ "subscription_url": "https://api.github.com/repos/joker1007/octogate/subscription",
117
+ "commits_url": "https://api.github.com/repos/joker1007/octogate/commits{/sha}",
118
+ "git_commits_url": "https://api.github.com/repos/joker1007/octogate/git/commits{/sha}",
119
+ "comments_url": "https://api.github.com/repos/joker1007/octogate/comments{/number}",
120
+ "issue_comment_url": "https://api.github.com/repos/joker1007/octogate/issues/comments/{number}",
121
+ "contents_url": "https://api.github.com/repos/joker1007/octogate/contents/{+path}",
122
+ "compare_url": "https://api.github.com/repos/joker1007/octogate/compare/{base}...{head}",
123
+ "merges_url": "https://api.github.com/repos/joker1007/octogate/merges",
124
+ "archive_url": "https://api.github.com/repos/joker1007/octogate/{archive_format}{/ref}",
125
+ "downloads_url": "https://api.github.com/repos/joker1007/octogate/downloads",
126
+ "issues_url": "https://api.github.com/repos/joker1007/octogate/issues{/number}",
127
+ "pulls_url": "https://api.github.com/repos/joker1007/octogate/pulls{/number}",
128
+ "milestones_url": "https://api.github.com/repos/joker1007/octogate/milestones{/number}",
129
+ "notifications_url": "https://api.github.com/repos/joker1007/octogate/notifications{?since,all,participating}",
130
+ "labels_url": "https://api.github.com/repos/joker1007/octogate/labels{/name}",
131
+ "releases_url": "https://api.github.com/repos/joker1007/octogate/releases{/id}",
132
+ "created_at": "2014-03-01T09:02:12Z",
133
+ "updated_at": "2014-03-02T14:09:02Z",
134
+ "pushed_at": "2014-03-02T14:06:51Z",
135
+ "git_url": "git://github.com/joker1007/octogate.git",
136
+ "ssh_url": "git@github.com:joker1007/octogate.git",
137
+ "clone_url": "https://github.com/joker1007/octogate.git",
138
+ "svn_url": "https://github.com/joker1007/octogate",
139
+ "homepage": "",
140
+ "size": 0,
141
+ "stargazers_count": 0,
142
+ "watchers_count": 0,
143
+ "language": "Ruby",
144
+ "has_issues": true,
145
+ "has_downloads": true,
146
+ "has_wiki": true,
147
+ "forks_count": 0,
148
+ "mirror_url": null,
149
+ "open_issues_count": 1,
150
+ "forks": 0,
151
+ "open_issues": 1,
152
+ "watchers": 0,
153
+ "default_branch": "master",
154
+ "master_branch": "master"
155
+ }
156
+ },
157
+ "base": {
158
+ "label": "joker1007:master",
159
+ "ref": "master",
160
+ "sha": "e0d504451c33d160f67e6dad83f95e4c6e1c2886",
161
+ "user": {
162
+ "login": "joker1007",
163
+ "id": 116996,
164
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
165
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
166
+ "url": "https://api.github.com/users/joker1007",
167
+ "html_url": "https://github.com/joker1007",
168
+ "followers_url": "https://api.github.com/users/joker1007/followers",
169
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
170
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
171
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
172
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
173
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
174
+ "repos_url": "https://api.github.com/users/joker1007/repos",
175
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
176
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
177
+ "type": "User",
178
+ "site_admin": false
179
+ },
180
+ "repo": {
181
+ "id": 17311500,
182
+ "name": "octogate",
183
+ "full_name": "joker1007/octogate",
184
+ "owner": {
185
+ "login": "joker1007",
186
+ "id": 116996,
187
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
188
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
189
+ "url": "https://api.github.com/users/joker1007",
190
+ "html_url": "https://github.com/joker1007",
191
+ "followers_url": "https://api.github.com/users/joker1007/followers",
192
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
193
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
194
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
195
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
196
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
197
+ "repos_url": "https://api.github.com/users/joker1007/repos",
198
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
199
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
200
+ "type": "User",
201
+ "site_admin": false
202
+ },
203
+ "private": false,
204
+ "html_url": "https://github.com/joker1007/octogate",
205
+ "description": "Github hook proxy server",
206
+ "fork": false,
207
+ "url": "https://api.github.com/repos/joker1007/octogate",
208
+ "forks_url": "https://api.github.com/repos/joker1007/octogate/forks",
209
+ "keys_url": "https://api.github.com/repos/joker1007/octogate/keys{/key_id}",
210
+ "collaborators_url": "https://api.github.com/repos/joker1007/octogate/collaborators{/collaborator}",
211
+ "teams_url": "https://api.github.com/repos/joker1007/octogate/teams",
212
+ "hooks_url": "https://api.github.com/repos/joker1007/octogate/hooks",
213
+ "issue_events_url": "https://api.github.com/repos/joker1007/octogate/issues/events{/number}",
214
+ "events_url": "https://api.github.com/repos/joker1007/octogate/events",
215
+ "assignees_url": "https://api.github.com/repos/joker1007/octogate/assignees{/user}",
216
+ "branches_url": "https://api.github.com/repos/joker1007/octogate/branches{/branch}",
217
+ "tags_url": "https://api.github.com/repos/joker1007/octogate/tags",
218
+ "blobs_url": "https://api.github.com/repos/joker1007/octogate/git/blobs{/sha}",
219
+ "git_tags_url": "https://api.github.com/repos/joker1007/octogate/git/tags{/sha}",
220
+ "git_refs_url": "https://api.github.com/repos/joker1007/octogate/git/refs{/sha}",
221
+ "trees_url": "https://api.github.com/repos/joker1007/octogate/git/trees{/sha}",
222
+ "statuses_url": "https://api.github.com/repos/joker1007/octogate/statuses/{sha}",
223
+ "languages_url": "https://api.github.com/repos/joker1007/octogate/languages",
224
+ "stargazers_url": "https://api.github.com/repos/joker1007/octogate/stargazers",
225
+ "contributors_url": "https://api.github.com/repos/joker1007/octogate/contributors",
226
+ "subscribers_url": "https://api.github.com/repos/joker1007/octogate/subscribers",
227
+ "subscription_url": "https://api.github.com/repos/joker1007/octogate/subscription",
228
+ "commits_url": "https://api.github.com/repos/joker1007/octogate/commits{/sha}",
229
+ "git_commits_url": "https://api.github.com/repos/joker1007/octogate/git/commits{/sha}",
230
+ "comments_url": "https://api.github.com/repos/joker1007/octogate/comments{/number}",
231
+ "issue_comment_url": "https://api.github.com/repos/joker1007/octogate/issues/comments/{number}",
232
+ "contents_url": "https://api.github.com/repos/joker1007/octogate/contents/{+path}",
233
+ "compare_url": "https://api.github.com/repos/joker1007/octogate/compare/{base}...{head}",
234
+ "merges_url": "https://api.github.com/repos/joker1007/octogate/merges",
235
+ "archive_url": "https://api.github.com/repos/joker1007/octogate/{archive_format}{/ref}",
236
+ "downloads_url": "https://api.github.com/repos/joker1007/octogate/downloads",
237
+ "issues_url": "https://api.github.com/repos/joker1007/octogate/issues{/number}",
238
+ "pulls_url": "https://api.github.com/repos/joker1007/octogate/pulls{/number}",
239
+ "milestones_url": "https://api.github.com/repos/joker1007/octogate/milestones{/number}",
240
+ "notifications_url": "https://api.github.com/repos/joker1007/octogate/notifications{?since,all,participating}",
241
+ "labels_url": "https://api.github.com/repos/joker1007/octogate/labels{/name}",
242
+ "releases_url": "https://api.github.com/repos/joker1007/octogate/releases{/id}",
243
+ "created_at": "2014-03-01T09:02:12Z",
244
+ "updated_at": "2014-03-02T14:09:02Z",
245
+ "pushed_at": "2014-03-02T14:06:51Z",
246
+ "git_url": "git://github.com/joker1007/octogate.git",
247
+ "ssh_url": "git@github.com:joker1007/octogate.git",
248
+ "clone_url": "https://github.com/joker1007/octogate.git",
249
+ "svn_url": "https://github.com/joker1007/octogate",
250
+ "homepage": "",
251
+ "size": 0,
252
+ "stargazers_count": 0,
253
+ "watchers_count": 0,
254
+ "language": "Ruby",
255
+ "has_issues": true,
256
+ "has_downloads": true,
257
+ "has_wiki": true,
258
+ "forks_count": 0,
259
+ "mirror_url": null,
260
+ "open_issues_count": 1,
261
+ "forks": 0,
262
+ "open_issues": 1,
263
+ "watchers": 0,
264
+ "default_branch": "master",
265
+ "master_branch": "master"
266
+ }
267
+ },
268
+ "_links": {
269
+ "self": {
270
+ "href": "https://api.github.com/repos/joker1007/octogate/pulls/2"
271
+ },
272
+ "html": {
273
+ "href": "https://github.com/joker1007/octogate/pull/2"
274
+ },
275
+ "issue": {
276
+ "href": "https://api.github.com/repos/joker1007/octogate/issues/2"
277
+ },
278
+ "comments": {
279
+ "href": "https://api.github.com/repos/joker1007/octogate/issues/2/comments"
280
+ },
281
+ "review_comments": {
282
+ "href": "https://api.github.com/repos/joker1007/octogate/pulls/2/comments"
283
+ },
284
+ "review_comment": {
285
+ "href": "https://api.github.com/repos/joker1007/octogate/pulls/comments/{number}"
286
+ },
287
+ "commits": {
288
+ "href": "https://api.github.com/repos/joker1007/octogate/pulls/2/commits"
289
+ },
290
+ "statuses": {
291
+ "href": "https://api.github.com/repos/joker1007/octogate/statuses/2e4c627e285b3c09993f5ef50fbe8de5481f48a3"
292
+ }
293
+ },
294
+ "merged": false,
295
+ "mergeable": null,
296
+ "mergeable_state": "unknown",
297
+ "merged_by": null,
298
+ "comments": 0,
299
+ "review_comments": 0,
300
+ "commits": 1,
301
+ "additions": 68,
302
+ "deletions": 1,
303
+ "changed_files": 7
304
+ },
305
+ "repository": {
306
+ "id": 17311500,
307
+ "name": "octogate",
308
+ "full_name": "joker1007/octogate",
309
+ "owner": {
310
+ "login": "joker1007",
311
+ "id": 116996,
312
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
313
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
314
+ "url": "https://api.github.com/users/joker1007",
315
+ "html_url": "https://github.com/joker1007",
316
+ "followers_url": "https://api.github.com/users/joker1007/followers",
317
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
318
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
319
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
320
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
321
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
322
+ "repos_url": "https://api.github.com/users/joker1007/repos",
323
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
324
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
325
+ "type": "User",
326
+ "site_admin": false
327
+ },
328
+ "private": false,
329
+ "html_url": "https://github.com/joker1007/octogate",
330
+ "description": "Github hook proxy server",
331
+ "fork": false,
332
+ "url": "https://api.github.com/repos/joker1007/octogate",
333
+ "forks_url": "https://api.github.com/repos/joker1007/octogate/forks",
334
+ "keys_url": "https://api.github.com/repos/joker1007/octogate/keys{/key_id}",
335
+ "collaborators_url": "https://api.github.com/repos/joker1007/octogate/collaborators{/collaborator}",
336
+ "teams_url": "https://api.github.com/repos/joker1007/octogate/teams",
337
+ "hooks_url": "https://api.github.com/repos/joker1007/octogate/hooks",
338
+ "issue_events_url": "https://api.github.com/repos/joker1007/octogate/issues/events{/number}",
339
+ "events_url": "https://api.github.com/repos/joker1007/octogate/events",
340
+ "assignees_url": "https://api.github.com/repos/joker1007/octogate/assignees{/user}",
341
+ "branches_url": "https://api.github.com/repos/joker1007/octogate/branches{/branch}",
342
+ "tags_url": "https://api.github.com/repos/joker1007/octogate/tags",
343
+ "blobs_url": "https://api.github.com/repos/joker1007/octogate/git/blobs{/sha}",
344
+ "git_tags_url": "https://api.github.com/repos/joker1007/octogate/git/tags{/sha}",
345
+ "git_refs_url": "https://api.github.com/repos/joker1007/octogate/git/refs{/sha}",
346
+ "trees_url": "https://api.github.com/repos/joker1007/octogate/git/trees{/sha}",
347
+ "statuses_url": "https://api.github.com/repos/joker1007/octogate/statuses/{sha}",
348
+ "languages_url": "https://api.github.com/repos/joker1007/octogate/languages",
349
+ "stargazers_url": "https://api.github.com/repos/joker1007/octogate/stargazers",
350
+ "contributors_url": "https://api.github.com/repos/joker1007/octogate/contributors",
351
+ "subscribers_url": "https://api.github.com/repos/joker1007/octogate/subscribers",
352
+ "subscription_url": "https://api.github.com/repos/joker1007/octogate/subscription",
353
+ "commits_url": "https://api.github.com/repos/joker1007/octogate/commits{/sha}",
354
+ "git_commits_url": "https://api.github.com/repos/joker1007/octogate/git/commits{/sha}",
355
+ "comments_url": "https://api.github.com/repos/joker1007/octogate/comments{/number}",
356
+ "issue_comment_url": "https://api.github.com/repos/joker1007/octogate/issues/comments/{number}",
357
+ "contents_url": "https://api.github.com/repos/joker1007/octogate/contents/{+path}",
358
+ "compare_url": "https://api.github.com/repos/joker1007/octogate/compare/{base}...{head}",
359
+ "merges_url": "https://api.github.com/repos/joker1007/octogate/merges",
360
+ "archive_url": "https://api.github.com/repos/joker1007/octogate/{archive_format}{/ref}",
361
+ "downloads_url": "https://api.github.com/repos/joker1007/octogate/downloads",
362
+ "issues_url": "https://api.github.com/repos/joker1007/octogate/issues{/number}",
363
+ "pulls_url": "https://api.github.com/repos/joker1007/octogate/pulls{/number}",
364
+ "milestones_url": "https://api.github.com/repos/joker1007/octogate/milestones{/number}",
365
+ "notifications_url": "https://api.github.com/repos/joker1007/octogate/notifications{?since,all,participating}",
366
+ "labels_url": "https://api.github.com/repos/joker1007/octogate/labels{/name}",
367
+ "releases_url": "https://api.github.com/repos/joker1007/octogate/releases{/id}",
368
+ "created_at": "2014-03-01T09:02:12Z",
369
+ "updated_at": "2014-03-02T14:09:02Z",
370
+ "pushed_at": "2014-03-02T14:06:51Z",
371
+ "git_url": "git://github.com/joker1007/octogate.git",
372
+ "ssh_url": "git@github.com:joker1007/octogate.git",
373
+ "clone_url": "https://github.com/joker1007/octogate.git",
374
+ "svn_url": "https://github.com/joker1007/octogate",
375
+ "homepage": "",
376
+ "size": 0,
377
+ "stargazers_count": 0,
378
+ "watchers_count": 0,
379
+ "language": "Ruby",
380
+ "has_issues": true,
381
+ "has_downloads": true,
382
+ "has_wiki": true,
383
+ "forks_count": 0,
384
+ "mirror_url": null,
385
+ "open_issues_count": 1,
386
+ "forks": 0,
387
+ "open_issues": 1,
388
+ "watchers": 0,
389
+ "default_branch": "master",
390
+ "master_branch": "master"
391
+ },
392
+ "sender": {
393
+ "login": "joker1007",
394
+ "id": 116996,
395
+ "avatar_url": "https://avatars.githubusercontent.com/u/116996",
396
+ "gravatar_id": "a5e5ee2fb9e4ce3c728ed9e3ef6e916f",
397
+ "url": "https://api.github.com/users/joker1007",
398
+ "html_url": "https://github.com/joker1007",
399
+ "followers_url": "https://api.github.com/users/joker1007/followers",
400
+ "following_url": "https://api.github.com/users/joker1007/following{/other_user}",
401
+ "gists_url": "https://api.github.com/users/joker1007/gists{/gist_id}",
402
+ "starred_url": "https://api.github.com/users/joker1007/starred{/owner}{/repo}",
403
+ "subscriptions_url": "https://api.github.com/users/joker1007/subscriptions",
404
+ "organizations_url": "https://api.github.com/users/joker1007/orgs",
405
+ "repos_url": "https://api.github.com/users/joker1007/repos",
406
+ "events_url": "https://api.github.com/users/joker1007/events{/privacy}",
407
+ "received_events_url": "https://api.github.com/users/joker1007/received_events",
408
+ "type": "User",
409
+ "site_admin": false
410
+ }
411
+ }
@@ -3,6 +3,11 @@ require 'octogate'
3
3
  require 'tapp'
4
4
  require 'webmock/rspec'
5
5
 
6
+ Tapp.configure do |config|
7
+ config.default_printer = :awesome_print
8
+ config.report_caller = true
9
+ end
10
+
6
11
  WebMock.disable_net_connect!
7
12
 
8
13
  RSpec.configure do |config|
@@ -17,8 +22,8 @@ RSpec.configure do |config|
17
22
  end
18
23
  end
19
24
 
20
- def push_payload
21
- File.read(File.join(File.dirname(File.expand_path(__FILE__)), 'push_payload.json'))
25
+ def read_payload(name)
26
+ File.read(File.join(File.dirname(File.expand_path(__FILE__)), "#{name}_payload.json"))
22
27
  end
23
28
 
24
29
  def config_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octogate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -187,21 +201,28 @@ files:
187
201
  - lib/octogate/configuration.rb
188
202
  - lib/octogate/events.rb
189
203
  - lib/octogate/events/base.rb
204
+ - lib/octogate/events/pull_request.rb
190
205
  - lib/octogate/events/push.rb
191
206
  - lib/octogate/gh.rb
192
207
  - lib/octogate/gh/commit.rb
208
+ - lib/octogate/gh/pull_request.rb
193
209
  - lib/octogate/gh/repository.rb
194
210
  - lib/octogate/gh/user.rb
195
211
  - lib/octogate/model.rb
196
212
  - lib/octogate/server.rb
197
213
  - lib/octogate/target.rb
198
214
  - lib/octogate/target_builder.rb
215
+ - lib/octogate/transfer_request.rb
199
216
  - lib/octogate/version.rb
200
217
  - octogate.gemspec
201
218
  - spec/config_sample.rb
202
219
  - spec/lib/octogate/client_spec.rb
203
220
  - spec/lib/octogate/config_loader_spec.rb
221
+ - spec/lib/octogate/events/pull_request_spec.rb
204
222
  - spec/lib/octogate/events/push_spec.rb
223
+ - spec/lib/octogate/events_spec.rb
224
+ - spec/lib/octogate/target_spec.rb
225
+ - spec/pull_request_payload.json
205
226
  - spec/push_payload.json
206
227
  - spec/spec_helper.rb
207
228
  homepage: https://github.com/joker1007/octogate
@@ -232,6 +253,10 @@ test_files:
232
253
  - spec/config_sample.rb
233
254
  - spec/lib/octogate/client_spec.rb
234
255
  - spec/lib/octogate/config_loader_spec.rb
256
+ - spec/lib/octogate/events/pull_request_spec.rb
235
257
  - spec/lib/octogate/events/push_spec.rb
258
+ - spec/lib/octogate/events_spec.rb
259
+ - spec/lib/octogate/target_spec.rb
260
+ - spec/pull_request_payload.json
236
261
  - spec/push_payload.json
237
262
  - spec/spec_helper.rb