alvid 0.2.1 → 0.2.2

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: 29a80f608e986656c802ce56e9ead67fb4a1b674
4
- data.tar.gz: eb5bc05f8c7308d05e0380d5cb7d36f814cfdb7d
3
+ metadata.gz: 5e356b5b51beda79782d42e969bc61e7bf35d99f
4
+ data.tar.gz: f3727bb5e738003625c4600e2a531e38419bdbd1
5
5
  SHA512:
6
- metadata.gz: 64ab8800ff8cc94e8fc5ca847caabb9e4158f62455bb6af65d192cd184d627c0111d0240d1e88061660f642efda32233f8f154b17939a0bcb5d0408a5fd70310
7
- data.tar.gz: 83b38bbd9d4f3e4c203199c76de40943b12ee0a810e400f667c48c4347d419c11ed82a9125f08bc9b77e7761cc8972f2682fba4e8f547ec1da0af188f277e736
6
+ metadata.gz: 22275b17ac0a0f48c235ba6f6eaf33fdddc43ce0b424d823981bad06753e89ecc52307e9e0a5c92c967b76513cdda7a931486a7a41badaf87a4ecf141063cb72
7
+ data.tar.gz: 516a0a59d3ffa4d893db31f03d10413f2de73c247e655ceeef2a0abaf8a412aa7ad81639d032ac4302c8c8d4e444115ca6b55ce0f273206b30bf87826421bee1
@@ -0,0 +1,6 @@
1
+ Alvid::Github.new('https://github.com/api/v3/', '4cb81a0fbc5c85dcff0', 'cb6e1a55fc3e43f416b3f28c82bb0f661e7728bd')
2
+ 2 examples, 1 failure
3
+ Alvid::Github.new('https://github.com/api/v3/', '
4
+ Alivd.new
5
+ a.client
6
+ a
@@ -23,8 +23,11 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'rack'
24
24
  s.add_development_dependency 'thin', '>= 1.2.0'
25
25
  s.add_development_dependency "rspec"
26
+ s.add_development_dependency "byebug"
26
27
  s.add_development_dependency "factory_girl"
27
28
  s.add_dependency "dm-sqlite-adapter"
28
29
  s.add_dependency "dm-mysql-adapter"
29
30
  s.add_dependency "data_mapper"
31
+ s.add_dependency "octokit"
32
+ s.add_dependency "sshkey"
30
33
  end
@@ -24,3 +24,4 @@ Alvid.init
24
24
 
25
25
  require "alvid/version"
26
26
  require "alvid/retro"
27
+ require "alvid/github"
@@ -0,0 +1,22 @@
1
+ require 'octokit'
2
+ require 'alvid/keypair'
3
+
4
+ class Alvid::Github
5
+ attr_reader :client
6
+
7
+ def initialize(api_endpoint, access_token)
8
+ Octokit.configure do |c|
9
+ c.api_endpoint = api_endpoint
10
+ end
11
+
12
+ @client = Octokit::Client.new(access_token: access_token)
13
+ end
14
+
15
+
16
+ def create_repository(repo_name, organization)
17
+ @client.create_repository(repo_name, {:organization=>organization})
18
+ keypair = Alvid::Keypair.new
19
+ @client.add_deploy_key(repo_name, "#{repo_name}-dk", keypair.pub)
20
+ keypair.pri
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ require 'sshkey'
2
+
3
+ module Alvid
4
+ class Keypair
5
+ def initialize
6
+ @keypair = SSHKey.generate
7
+ end
8
+
9
+ def pub
10
+ @keypair.public_key
11
+ end
12
+ def pri
13
+ @keypair.private_key
14
+ end
15
+ end
16
+
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Alvid
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'byebug'
3
+
4
+ describe Alvid::Github do
5
+ let(:access_token){ 'bar' }
6
+ let(:organization){ 'compozed' }
7
+ let(:repo_name){ 'banana' }
8
+ let(:keypair){ double('keypair', pub: 'public-key', pri: 'private-key') }
9
+ let(:api_endpoint){ 'https://myenterprise.github.com/api/v3/' }
10
+ let(:github){ Alvid::Github.new(api_endpoint, access_token)}
11
+
12
+ describe 'new' do
13
+ it 'should login application' do
14
+ expect(Octokit::Client).to receive(:new).with(access_token: access_token)
15
+ github
16
+ end
17
+
18
+ it 'should set api_endpoint' do
19
+ expect(github.client.api_endpoint).to eq(api_endpoint)
20
+ end
21
+ end
22
+
23
+ describe 'create_repository' do
24
+ before do
25
+ allow(Alvid::Keypair).to receive(:new).and_return(keypair)
26
+ allow_any_instance_of(Octokit::Client).to receive(:create_repository)
27
+ allow_any_instance_of(Octokit::Client).to receive(:add_deploy_key)
28
+ end
29
+
30
+ it 'should create a github' do
31
+ expect_any_instance_of(Octokit::Client).to receive(:create_repository).with(repo_name, organization: organization)
32
+ github.create_repository(repo_name, organization)
33
+ end
34
+
35
+ it 'should upload public key' do
36
+ expect_any_instance_of(Octokit::Client).to receive(:add_deploy_key).with(repo_name, "#{repo_name}-dk", keypair.pub )
37
+ github.create_repository(repo_name, organization)
38
+ end
39
+
40
+ it 'should return private key' do
41
+ expect(github.create_repository(repo_name, organization)).to eq(keypair.pri)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ require 'octokit'
2
+ require 'alvid/keypair'
3
+
4
+ describe Alvid::Keypair do
5
+ let(:keypair) { described_class.new }
6
+
7
+ describe 'new' do
8
+ it 'should generate new sshkey' do
9
+ expect(SSHKey).to receive(:generate)
10
+ keypair
11
+ end
12
+ end
13
+
14
+ describe 'pri' do
15
+ it 'should return private key' do
16
+ expect_any_instance_of(SSHKey).to receive(:private_key)
17
+ keypair.pri
18
+ end
19
+ end
20
+
21
+ describe 'pub' do
22
+ it 'should return public key' do
23
+ expect_any_instance_of(SSHKey).to receive(:public_key)
24
+ keypair.pub
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alvid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Moran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-11-29 00:00:00.000000000 Z
12
+ date: 2016-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: byebug
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: factory_girl
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +151,34 @@ dependencies:
137
151
  - - ">="
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: octokit
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: sshkey
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
140
182
  description:
141
183
  email:
142
184
  - bonzofenix@gmail.com
@@ -145,6 +187,7 @@ executables: []
145
187
  extensions: []
146
188
  extra_rdoc_files: []
147
189
  files:
190
+ - ".byebug_history"
148
191
  - ".gitignore"
149
192
  - ".rspec"
150
193
  - ".travis.yml"
@@ -156,10 +199,14 @@ files:
156
199
  - bin/console
157
200
  - bin/setup
158
201
  - lib/alvid.rb
202
+ - lib/alvid/github.rb
203
+ - lib/alvid/keypair.rb
159
204
  - lib/alvid/retro.rb
160
205
  - lib/alvid/version.rb
161
206
  - spec/alvid_spec.rb
162
207
  - spec/factories.rb
208
+ - spec/github_spec.rb
209
+ - spec/keypair_spec.rb
163
210
  - spec/retro_spec.rb
164
211
  - spec/spec_helper.rb
165
212
  homepage: http://bonzofenix.github.io/alvid