vx-service_connector 0.2.5 → 0.2.6

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: f5667def03eec4ebb4d2333f669d4e44985a10ba
4
- data.tar.gz: 2bf14de48eb28b85331d010cd6fa772f14268845
3
+ metadata.gz: 8f13a6f08f1fbf7e71c49432c692154bc20075db
4
+ data.tar.gz: 36fc26bcb172f80082d90eb232729e7e069fbfff
5
5
  SHA512:
6
- metadata.gz: 710c1e92ba2422a68a8dc041e5042d860ef26bcc6f5727f33b4e1ec6b2c4d8623c55031a86a8e46514e212b5a668c356c916051e8b3e36423e903ef250c871aa
7
- data.tar.gz: c18860b84ef6c4f22d17a9081e47db6d259eecf722bed26efb5d22b83a6808217b8ce3042d29571a719c2857fd00f6913688411bcb5b01b2c4f9de581664cd3f
6
+ metadata.gz: aeed2179b97aa23afb6663a65c2cca27e3407981351618e8f78245c4840e67038da80fd49f2cb8078aa30c5472558f62697ac3c702843a6a9c953dbb3ea8364c
7
+ data.tar.gz: 57c8ffa21d377f09bca5cd5cfe6daeba06c477495a0b710b13027a74aa644387417d40146ccc018883a425d12792dcc091ecd55eb4731e621871ed2783f36ca2
@@ -38,6 +38,10 @@ module Vx
38
38
  Github::Payload.new(session, params).build
39
39
  end
40
40
 
41
+ def commits(repo, options = {})
42
+ Github::Commits.new(session, repo)
43
+ end
44
+
41
45
  private
42
46
 
43
47
  def create_session
@@ -0,0 +1,28 @@
1
+ require 'base64'
2
+
3
+ module Vx
4
+ module ServiceConnector
5
+ class Github
6
+ Commits = Struct.new(:session, :repo) do
7
+ def last(options = {})
8
+ begin
9
+ commit = session.commit(repo.full_name, 'HEAD')
10
+ Model::Payload.from_hash(
11
+ skip: false,
12
+ pull_request?: false,
13
+ branch: 'HEAD',
14
+ branch_label: 'HEAD',
15
+ sha: commit.sha,
16
+ message: commit.commit.message,
17
+ author: commit.commit.author.name,
18
+ author_email: commit.commit.author.email,
19
+ web_url: commit.commit.url
20
+ )
21
+ rescue Octokit::NotFound
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -32,6 +32,10 @@ module Vx
32
32
  self.class::Payload.new(session, repo, params).build
33
33
  end
34
34
 
35
+ def commits(repo)
36
+ self.class::Commits.new(session, repo)
37
+ end
38
+
35
39
  private
36
40
 
37
41
  def create_session
@@ -0,0 +1,29 @@
1
+ module Vx
2
+ module ServiceConnector
3
+ class GitlabV6
4
+ Commits = Struct.new(:session, :repo) do
5
+
6
+ def last(options = {})
7
+ begin
8
+ commit = session.get "/projects/#{repo.id}/repository/commits/HEAD"
9
+ Model::Payload.from_hash(
10
+ skip: false,
11
+ pull_request?: false,
12
+ branch: 'HEAD',
13
+ branch_label: 'HEAD',
14
+ sha: commit.id,
15
+ message: commit.title,
16
+ author: commit.author_name,
17
+ author_email: commit.author_email,
18
+ web_url: "#{repo.html_url}/commits/#{commit.id}"
19
+ )
20
+ rescue RequestError
21
+ nil
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module ServiceConnector
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
@@ -13,6 +13,25 @@ describe Vx::ServiceConnector::Github do
13
13
 
14
14
  it { should be }
15
15
 
16
+ context "(commits)" do
17
+ let(:commits) { github.commits(repo) }
18
+
19
+ it "should return payload for last commit" do
20
+ mock_get_commit repo.full_name, 'HEAD'
21
+ c = commits.last
22
+ expect(c).to be
23
+ expect(c.message).to eq "Fix all the bugs"
24
+ expect(c.skip).to be_false
25
+ expect(c.pull_request?).to be_false
26
+ expect(c.branch).to eq 'HEAD'
27
+ expect(c.branch_label).to eq 'HEAD'
28
+ expect(c.sha).to eq '6dcb09b5b57875f334f61aebed695e2e4193db5e'
29
+ expect(c.author).to eq "Monalisa Octocat"
30
+ expect(c.author_email).to eq "support@github.com"
31
+ expect(c.web_url).to eq "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e"
32
+ end
33
+ end
34
+
16
35
  context "(notices)" do
17
36
  let(:notices) { github.notices(repo) }
18
37
 
@@ -17,6 +17,25 @@ require 'spec_helper'
17
17
 
18
18
  it { should be }
19
19
 
20
+ context "(commits)" do
21
+ let(:commits) { gitlab.commits(repo) }
22
+
23
+ it "should return payload for last commit" do
24
+ mock_get_commit repo.id, 'HEAD'
25
+ c = commits.last
26
+ expect(c).to be
27
+ expect(c.message).to eq "Replace sanitize with escape once"
28
+ expect(c.skip).to be_false
29
+ expect(c.pull_request?).to be_false
30
+ expect(c.branch).to eq 'HEAD'
31
+ expect(c.branch_label).to eq 'HEAD'
32
+ expect(c.sha).to eq '2dd0fdf94c7d0a74921e178b3b5229e60ce5d03e'
33
+ expect(c.author).to eq "Dmitriy Zaporozhets"
34
+ expect(c.author_email).to eq "dzaporozhets@sphereconsultinginc.com"
35
+ expect(c.web_url).to eq "http://example.com/commits/2dd0fdf94c7d0a74921e178b3b5229e60ce5d03e"
36
+ end
37
+ end
38
+
20
39
  context "(notices)" do
21
40
  let(:notices) { gitlab.notices(repo) }
22
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-service_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -126,6 +126,7 @@ files:
126
126
  - lib/vx/service_connector/base.rb
127
127
  - lib/vx/service_connector/error.rb
128
128
  - lib/vx/service_connector/github.rb
129
+ - lib/vx/service_connector/github/commits.rb
129
130
  - lib/vx/service_connector/github/deploy_keys.rb
130
131
  - lib/vx/service_connector/github/files.rb
131
132
  - lib/vx/service_connector/github/hooks.rb
@@ -133,6 +134,7 @@ files:
133
134
  - lib/vx/service_connector/github/payload.rb
134
135
  - lib/vx/service_connector/github/repos.rb
135
136
  - lib/vx/service_connector/gitlab_v6.rb
137
+ - lib/vx/service_connector/gitlab_v6/commits.rb
136
138
  - lib/vx/service_connector/gitlab_v6/deploy_keys.rb
137
139
  - lib/vx/service_connector/gitlab_v6/files.rb
138
140
  - lib/vx/service_connector/gitlab_v6/hooks.rb