githubrepo 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d7f66425e7be09b5a8e92824eb2fec9034530ad
4
- data.tar.gz: f3f3f33a704005cd393c3595aa1f4c358a3ace8b
3
+ metadata.gz: ffbb30f5e9ef2973b4451eac004cb94bdb774fa7
4
+ data.tar.gz: dc180defa75d1104d23314ca217d69d2152d62de
5
5
  SHA512:
6
- metadata.gz: 9ff23a45ee84e6408bd231ef71f3f517d0d1286c3eb16599d49fa01af365d98685451832037aa80f2cb008c2188e01d23ae7b7a6ee74fb00b087905b269a44e2
7
- data.tar.gz: d7c4c6b313958868d9a508775a9f312003850d422870c17291e3f22f4c691fdea916cf9ba73439de63aa140fbd27c0dd89eaf4b4188216ea4144166ce766eae3
6
+ metadata.gz: 54b90bd42382a91c3439a270dffd651174c71bd133b9103e07171d6b07060dbe55efc8502992b209854c3cdda422f90f235fe04c76ceae5ac4b134c5306b2314
7
+ data.tar.gz: 87f53af872c82d5842282ec1fb74974dc720aa773b0f00cf0172a6d586bf9f3bfdf889ac115de005e351edc836435d73c095baeb7f3a38bcdc81df5913288653
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Githubrepo
2
- This gem is a Command Line Interface to do only thing... create GitHub repositories.
2
+ This gem is a Command Line Interface to do only one thing... create GitHub repositories.
3
3
 
4
4
  ## Installation
5
5
 
@@ -10,9 +10,14 @@ Download this gem:
10
10
 
11
11
  ## Usage
12
12
 
13
- $ githubrepo create REPOSITORY_NAME
14
- $ githubrepo REPOSITORY_NAME
15
-
13
+ $ githubrepo create REPO_NAME
14
+ $ githubrepo REPO_NAME
15
+ $ githubrepo REPO_NAME -d "short description"
16
+
17
+ # To get back the SSH URL instead of HTTP, add the -s or --ssh flag:
18
+ $ githubrepo REPOSITORY_NAME -s
19
+
20
+
16
21
 
17
22
  The default operation on githubrepo is to create, so you can skip the create action.
18
23
  For more details use help flag:
@@ -21,11 +26,21 @@ For more details use help flag:
21
26
 
22
27
 
23
28
  ## Development
29
+ To see available rake tasks for development
30
+
31
+ $ rake -T
32
+
24
33
  To run the app in IRB for debugging run
25
34
 
26
35
  $ rake console
27
- $ Githubrepo.create(attributes)
28
-
36
+ $ Githubrepo.create ({ :repository => 'test_repo',
37
+ :description => 'description',
38
+ :wants_ssh => false,
39
+ :username => 'username',
40
+ :password => 'password',
41
+ :rspec => true # returns response hash instead of nil
42
+ })
43
+
29
44
 
30
45
  ## Contributing
31
46
 
@@ -33,4 +48,4 @@ To run the app in IRB for debugging run
33
48
  2. Create your feature branch (`git checkout -b my-new-feature`)
34
49
  3. Commit your changes (`git commit -am 'Add some feature'`)
35
50
  4. Push to the branch (`git push origin my-new-feature`)
36
- 5. Create new Pull Request
51
+ 5. Create new Pull Request to Dev
data/Rakefile CHANGED
@@ -1,5 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.rspec_opts = ['--color', '--format', 'documentation']
6
+ end
7
+
8
+ desc 'Run in IRB for debugging'
3
9
  task :console do
4
10
  require 'irb'
5
11
  require 'irb/completion'
@@ -2,9 +2,10 @@
2
2
 
3
3
  require File.expand_path '../lib/githubrepo', File.dirname(__FILE__)
4
4
  require 'commander/import'
5
+ require 'githubrepo/version'
5
6
 
6
7
  program :name, 'githubrepo'
7
- program :version, '0.2.2'
8
+ program :version, '0.3.0'
8
9
  program :description, 'Create GitHub repositories from the command line.
9
10
 
10
11
  OSX: repository URL is automatically copied to clipboard.
@@ -16,17 +17,20 @@ program :help, 'Author', 'Elikem Adadevoh <elikem@gmail.com>'
16
17
  command :create do |c|
17
18
  c.syntax = 'githubrepo create [options]'
18
19
 
19
- c.description = 'githubrepo create REPO_NAME -d REPO_DESCRIPTION'
20
+ c.description = 'githubrepo create REPO_NAME -d REPO_DESCRIPTION --ssh [optional, will give you the SSH link instead of HTTP]'
20
21
 
21
22
  c.example 'usage', 'githubrepo create REPO_NAME'
22
- c.example 'usage', 'githubrepo REPO_NAME'
23
+ c.example 'shorthand', 'githubrepo REPO_NAME'
23
24
  c.example 'description', 'githubrepo create REPO_NAME -d "short description"'
25
+ c.example 'SSH URL', 'githubrepo REPO_NAME -s'
24
26
 
25
27
  c.option '--description STRING', String, 'A short description of the repository'
28
+ c.option '--ssh', 'Gives the link back as SSH instead of HTTP'
26
29
 
27
30
  c.action do |args, options|
28
31
  repository = args.shift
29
32
  description = options.description
33
+ wants_ssh = options.ssh
30
34
 
31
35
  # check for repository argument
32
36
  if repository.nil?
@@ -46,10 +50,24 @@ command :create do |c|
46
50
  password = ask('Password: ') { |char| char.echo = false }
47
51
 
48
52
  # package attributes for http api payload
49
- cli({ :repository => repository, :description => description, :username => username, :password => password })
53
+ cli({ :repository => repository, :description => description, :wants_ssh => wants_ssh, :username => username, :password => password })
50
54
  end
51
55
  end
52
56
 
57
+ command :version do |v|
58
+ v.syntax = 'githubrepo version [options]'
59
+ v.description = 'githubrepo version'
60
+
61
+ v.example 'usage', 'githubrepo version'
62
+
63
+ v.action do |args, options|
64
+ version = args.shift
65
+ end
66
+
67
+ # outputs version number
68
+ puts "Githubrepo #{Githubrepo::VERSION}"
69
+ end
70
+
53
71
  # set default action for gem
54
72
  default_command :create
55
73
 
@@ -21,6 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = '>= 2.0'
22
22
  spec.add_development_dependency 'bundler', '~> 1.3'
23
23
  spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'vcr'
26
+ spec.add_development_dependency 'webmock'
24
27
 
25
28
  spec.add_runtime_dependency 'commander', '~> 4.1.6'
26
29
  spec.add_runtime_dependency 'httparty', '~> 0.13.0'
@@ -34,17 +34,23 @@ module Githubrepo
34
34
  }.to_json
35
35
  )
36
36
 
37
- Githubrepo.parse_response_from(post)
37
+ Githubrepo.parse_response_from( post.merge(attributes) )
38
+
39
+ # for testing purposes only -- rspec
40
+ if attributes[:rspec]
41
+ return post
42
+ end
38
43
  end
39
44
 
40
45
  # DRY this by moving to a Parse.response_from(post)
41
46
  def self.parse_response_from(post)
42
47
  attributes = post
43
48
 
44
- clone_url =
45
- if attributes['clone_url'] != nil
46
- attributes['clone_url']
47
- end
49
+ if attributes[:wants_ssh]
50
+ repo_url = attributes['ssh_url']
51
+ else
52
+ repo_url = attributes['clone_url']
53
+ end
48
54
 
49
55
  message =
50
56
  if attributes['message'] != nil
@@ -57,28 +63,33 @@ module Githubrepo
57
63
  end
58
64
 
59
65
  # messages to console
60
- if clone_url
66
+ if repo_url
61
67
  if OS.mac?
62
- puts "#{clone_url} --- COPIED TO CLIPBOARD"
63
- Clipboard.copy clone_url
68
+ puts "#{repo_url} --- COPIED TO CLIPBOARD"
69
+ Clipboard.copy repo_url
64
70
  elsif OS.linux?
65
- puts clone_url
66
- Clipboard.copy clone_url
67
- puts "If xclip is installed, repository URL has been added to your clipboard."
68
- puts "debian/ubuntu: apt-get install xclip"
69
-
70
- # Add windows support in the future
71
- # elsif OS.windows?
72
- # Clipboard.copy clone_url
73
- # # Will Clipboard output clone_url to console if ffi is not installed?
74
- # # Below is what it looks like when Clipboard requirements are met
75
- # # https://github.com/user/*.git --- COPIED TO CLIPBOARD
76
- # puts "If ffi is installed, repository URL has been added to your clipboard."
77
- # puts "for installation: gem install ffi"
71
+ print repo_url
72
+ unless `which xclip`.empty?
73
+ print " --- COPIED TO CLIPBOARD\n"
74
+ Clipboard.copy repo_url
75
+ else
76
+ puts "\nInstall xclip if you want to auto-copy repository URL to your clipboard."
77
+ puts "debian/ubuntu: apt-get install xclip"
78
+ end
79
+ elsif OS.windows?
80
+ print repo_url
81
+ if Gem::Specification::find_all_by_name('ffi').any?
82
+ print " --- COPIED TO CLIPBOARD\n"
83
+ Clipboard.copy repo_url
84
+ else
85
+ puts "\nInstall ruby gem 'ffi' to auto-copy repository to your clipboard."
86
+ puts "gem install ffi"
87
+ end
78
88
  else
79
- puts clone_url
89
+ puts repo_url
80
90
  end
81
91
  end
92
+
82
93
  puts message.capitalize if message
83
94
  puts error_message.capitalize if error_message
84
95
  end
@@ -1,3 +1,3 @@
1
1
  module Githubrepo
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://elikem:password@api.github.com/user/repos
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"test_repo","description":"description"}'
9
+ headers:
10
+ User-Agent:
11
+ - Githubrepo
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 422
19
+ message: Unprocessable Entity
20
+ headers:
21
+ Server:
22
+ - GitHub.com
23
+ Date:
24
+ - Sun, 14 Sep 2014 16:09:37 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Status:
28
+ - 422 Unprocessable Entity
29
+ X-Ratelimit-Limit:
30
+ - '5000'
31
+ X-Ratelimit-Remaining:
32
+ - '4997'
33
+ X-Ratelimit-Reset:
34
+ - '1410714252'
35
+ X-Github-Media-Type:
36
+ - github.v3
37
+ X-Xss-Protection:
38
+ - 1; mode=block
39
+ X-Frame-Options:
40
+ - deny
41
+ Content-Security-Policy:
42
+ - default-src 'none'
43
+ Content-Length:
44
+ - '215'
45
+ Access-Control-Allow-Credentials:
46
+ - 'true'
47
+ Access-Control-Expose-Headers:
48
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
49
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
50
+ Access-Control-Allow-Origin:
51
+ - "*"
52
+ X-Github-Request-Id:
53
+ - 6372ADE0:3B40:D856EA:5415BDC1
54
+ Strict-Transport-Security:
55
+ - max-age=31536000; includeSubdomains; preload
56
+ X-Content-Type-Options:
57
+ - nosniff
58
+ body:
59
+ encoding: UTF-8
60
+ string: '{"message":"Validation Failed","documentation_url":"https://developer.github.com/v3/repos/#create","errors":[{"resource":"Repository","code":"custom","field":"name","message":"name
61
+ already exists on this account"}]}'
62
+ http_version:
63
+ recorded_at: Sun, 14 Sep 2014 16:09:37 GMT
64
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://elikem:password@api.github.com/user/repos
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"test_repo","description":"description"}'
9
+ headers:
10
+ User-Agent:
11
+ - Githubrepo
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - GitHub.com
23
+ Date:
24
+ - Sun, 14 Sep 2014 16:09:37 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Status:
28
+ - 201 Created
29
+ X-Ratelimit-Limit:
30
+ - '5000'
31
+ X-Ratelimit-Remaining:
32
+ - '4998'
33
+ X-Ratelimit-Reset:
34
+ - '1410714252'
35
+ Cache-Control:
36
+ - private, max-age=60, s-maxage=60
37
+ Etag:
38
+ - '"a9b887e12047de482060afad9324ba22"'
39
+ Location:
40
+ - https://api.github.com/repos/elikem/test_repo
41
+ Vary:
42
+ - Accept, Authorization, Cookie, X-GitHub-OTP
43
+ X-Github-Media-Type:
44
+ - github.v3
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ X-Frame-Options:
48
+ - deny
49
+ Content-Security-Policy:
50
+ - default-src 'none'
51
+ Content-Length:
52
+ - '4521'
53
+ Access-Control-Allow-Credentials:
54
+ - 'true'
55
+ Access-Control-Expose-Headers:
56
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
57
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
58
+ Access-Control-Allow-Origin:
59
+ - "*"
60
+ X-Github-Request-Id:
61
+ - 6372ADE0:3B44:575E865:5415BDC0
62
+ Strict-Transport-Security:
63
+ - max-age=31536000; includeSubdomains; preload
64
+ X-Content-Type-Options:
65
+ - nosniff
66
+ body:
67
+ encoding: UTF-8
68
+ string: '{"id":24026493,"name":"test_repo","full_name":"elikem/test_repo","owner":{"login":"elikem","id":1282871,"avatar_url":"https://avatars.githubusercontent.com/u/1282871?v=2","gravatar_id":"90eb0e692f7f2767b506510b648bd52c","url":"https://api.github.com/users/elikem","html_url":"https://github.com/elikem","followers_url":"https://api.github.com/users/elikem/followers","following_url":"https://api.github.com/users/elikem/following{/other_user}","gists_url":"https://api.github.com/users/elikem/gists{/gist_id}","starred_url":"https://api.github.com/users/elikem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elikem/subscriptions","organizations_url":"https://api.github.com/users/elikem/orgs","repos_url":"https://api.github.com/users/elikem/repos","events_url":"https://api.github.com/users/elikem/events{/privacy}","received_events_url":"https://api.github.com/users/elikem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/elikem/test_repo","description":"description","fork":false,"url":"https://api.github.com/repos/elikem/test_repo","forks_url":"https://api.github.com/repos/elikem/test_repo/forks","keys_url":"https://api.github.com/repos/elikem/test_repo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elikem/test_repo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elikem/test_repo/teams","hooks_url":"https://api.github.com/repos/elikem/test_repo/hooks","issue_events_url":"https://api.github.com/repos/elikem/test_repo/issues/events{/number}","events_url":"https://api.github.com/repos/elikem/test_repo/events","assignees_url":"https://api.github.com/repos/elikem/test_repo/assignees{/user}","branches_url":"https://api.github.com/repos/elikem/test_repo/branches{/branch}","tags_url":"https://api.github.com/repos/elikem/test_repo/tags","blobs_url":"https://api.github.com/repos/elikem/test_repo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elikem/test_repo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elikem/test_repo/git/refs{/sha}","trees_url":"https://api.github.com/repos/elikem/test_repo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elikem/test_repo/statuses/{sha}","languages_url":"https://api.github.com/repos/elikem/test_repo/languages","stargazers_url":"https://api.github.com/repos/elikem/test_repo/stargazers","contributors_url":"https://api.github.com/repos/elikem/test_repo/contributors","subscribers_url":"https://api.github.com/repos/elikem/test_repo/subscribers","subscription_url":"https://api.github.com/repos/elikem/test_repo/subscription","commits_url":"https://api.github.com/repos/elikem/test_repo/commits{/sha}","git_commits_url":"https://api.github.com/repos/elikem/test_repo/git/commits{/sha}","comments_url":"https://api.github.com/repos/elikem/test_repo/comments{/number}","issue_comment_url":"https://api.github.com/repos/elikem/test_repo/issues/comments/{number}","contents_url":"https://api.github.com/repos/elikem/test_repo/contents/{+path}","compare_url":"https://api.github.com/repos/elikem/test_repo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elikem/test_repo/merges","archive_url":"https://api.github.com/repos/elikem/test_repo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elikem/test_repo/downloads","issues_url":"https://api.github.com/repos/elikem/test_repo/issues{/number}","pulls_url":"https://api.github.com/repos/elikem/test_repo/pulls{/number}","milestones_url":"https://api.github.com/repos/elikem/test_repo/milestones{/number}","notifications_url":"https://api.github.com/repos/elikem/test_repo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elikem/test_repo/labels{/name}","releases_url":"https://api.github.com/repos/elikem/test_repo/releases{/id}","created_at":"2014-09-14T16:09:37Z","updated_at":"2014-09-14T16:09:37Z","pushed_at":"2014-09-14T16:09:37Z","git_url":"git://github.com/elikem/test_repo.git","ssh_url":"git@github.com:elikem/test_repo.git","clone_url":"https://github.com/elikem/test_repo.git","svn_url":"https://github.com/elikem/test_repo","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"network_count":0,"subscribers_count":1}'
69
+ http_version:
70
+ recorded_at: Sun, 14 Sep 2014 16:09:37 GMT
71
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://fake_username:wrong_password@api.github.com/user/repos
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"test_repo","description":"description"}'
9
+ headers:
10
+ User-Agent:
11
+ - Githubrepo
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ Server:
22
+ - GitHub.com
23
+ Date:
24
+ - Sun, 14 Sep 2014 16:09:37 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Status:
28
+ - 401 Unauthorized
29
+ X-Github-Media-Type:
30
+ - github.v3
31
+ X-Ratelimit-Limit:
32
+ - '60'
33
+ X-Ratelimit-Remaining:
34
+ - '54'
35
+ X-Ratelimit-Reset:
36
+ - '1410712588'
37
+ X-Xss-Protection:
38
+ - 1; mode=block
39
+ X-Frame-Options:
40
+ - deny
41
+ Content-Security-Policy:
42
+ - default-src 'none'
43
+ Content-Length:
44
+ - '83'
45
+ Access-Control-Allow-Credentials:
46
+ - 'true'
47
+ Access-Control-Expose-Headers:
48
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
49
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
50
+ Access-Control-Allow-Origin:
51
+ - "*"
52
+ X-Github-Request-Id:
53
+ - 6372ADE0:3B43:3F528BF:5415BDC1
54
+ Strict-Transport-Security:
55
+ - max-age=31536000; includeSubdomains; preload
56
+ X-Content-Type-Options:
57
+ - nosniff
58
+ body:
59
+ encoding: UTF-8
60
+ string: '{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}'
61
+ http_version:
62
+ recorded_at: Sun, 14 Sep 2014 16:09:37 GMT
63
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+ require 'vcr'
3
+ require 'webmock'
4
+
5
+ VCR.configure do |c|
6
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
7
+ c.hook_into :webmock
8
+ end
9
+
10
+ describe 'Githubrepo' do
11
+ it 'creates a GitHub repo with ssh' do
12
+ VCR.use_cassette('create a repository', :record => :once) do
13
+ attributes = ({ :repository => 'test_repo',
14
+ :description => 'description',
15
+ :wants_ssh => true,
16
+ :username => 'elikem',
17
+ :password => 'password',
18
+ :rspec => true
19
+ })
20
+
21
+ response = Githubrepo.create(attributes)
22
+ expect(response['ssh_url']).to eq('git@github.com:elikem/test_repo.git')
23
+ end
24
+ end
25
+
26
+ it 'requests to create a Github repo without wants_ssh' do
27
+ VCR.use_cassette('create a repository', :record => :once) do
28
+ attributes = ({ :repository => 'test_repo',
29
+ :description => 'description',
30
+ :wants_ssh => false,
31
+ :username => 'elikem',
32
+ :password => 'password',
33
+ :rspec => true
34
+ })
35
+
36
+ response = Githubrepo.create(attributes)
37
+ expect(response['clone_url']).to eq('https://github.com/elikem/test_repo.git')
38
+ end
39
+ end
40
+
41
+ it 'should fail with the wrong credentials' do
42
+ VCR.use_cassette('create a repository with bad password', :record => :once) do
43
+ attributes = ({ :repository => 'test_repo',
44
+ :description => 'description',
45
+ :wants_ssh => false,
46
+ :username => 'fake_username',
47
+ :password => 'wrong_password',
48
+ :rspec => true
49
+ })
50
+
51
+ response = Githubrepo.create(attributes)
52
+ expect(response['message']).to eq('Bad credentials')
53
+ end
54
+ end
55
+
56
+ it 'should return message if repository exists', focus: true do
57
+ VCR.use_cassette('create a existing repository', :record => :once) do
58
+ attributes = ({ :repository => 'test_repo',
59
+ :description => 'description',
60
+ :wants_ssh => false,
61
+ :username => 'elikem',
62
+ :password => 'password',
63
+ :rspec => true
64
+ })
65
+
66
+ response = Githubrepo.create(attributes)
67
+ expect(response['errors'].first['message']).to eq('name already exists on this account')
68
+ end
69
+ end
70
+ end
@@ -0,0 +1 @@
1
+ require 'githubrepo'
@@ -0,0 +1,15 @@
1
+ irb(main):001:0> Githubrepo.create( { :repository => 'test_repo', :description => 'description', :wants_ssh => false, :username => 'elikem', :password => 'password' } )
2
+
3
+ => #<HTTParty::Response:0x7fdab4c49780 parsed_response={"id"=>24024659, "name"=>"test_repo", "full_name"=>"elikem/test_repo", "owner"=>{"login"=>"elikem", "id"=>1282871, "avatar_url"=>"https://avatars.githubusercontent.com/u/1282871?v=2", "gravatar_id"=>"90eb0e692f7f2767b506510b648bd52c", "url"=>"https://api.github.com/users/elikem", "html_url"=>"https://github.com/elikem", "followers_url"=>"https://api.github.com/users/elikem/followers", "following_url"=>"https://api.github.com/users/elikem/following{/other_user}", "gists_url"=>"https://api.github.com/users/elikem/gists{/gist_id}", "starred_url"=>"https://api.github.com/users/elikem/starred{/owner}{/repo}", "subscriptions_url"=>"https://api.github.com/users/elikem/subscriptions", "organizations_url"=>"https://api.github.com/users/elikem/orgs", "repos_url"=>"https://api.github.com/users/elikem/repos", "events_url"=>"https://api.github.com/users/elikem/events{/privacy}", "received_events_url"=>"https://api.github.com/users/elikem/received_events", "type"=>"User", "site_admin"=>false}, "private"=>false, "html_url"=>"https://github.com/elikem/test_repo", "description"=>"description", "fork"=>false, "url"=>"https://api.github.com/repos/elikem/test_repo", "forks_url"=>"https://api.github.com/repos/elikem/test_repo/forks", "keys_url"=>"https://api.github.com/repos/elikem/test_repo/keys{/key_id}", "collaborators_url"=>"https://api.github.com/repos/elikem/test_repo/collaborators{/collaborator}", "teams_url"=>"https://api.github.com/repos/elikem/test_repo/teams", "hooks_url"=>"https://api.github.com/repos/elikem/test_repo/hooks", "issue_events_url"=>"https://api.github.com/repos/elikem/test_repo/issues/events{/number}", "events_url"=>"https://api.github.com/repos/elikem/test_repo/events", "assignees_url"=>"https://api.github.com/repos/elikem/test_repo/assignees{/user}", "branches_url"=>"https://api.github.com/repos/elikem/test_repo/branches{/branch}", "tags_url"=>"https://api.github.com/repos/elikem/test_repo/tags", "blobs_url"=>"https://api.github.com/repos/elikem/test_repo/git/blobs{/sha}", "git_tags_url"=>"https://api.github.com/repos/elikem/test_repo/git/tags{/sha}", "git_refs_url"=>"https://api.github.com/repos/elikem/test_repo/git/refs{/sha}", "trees_url"=>"https://api.github.com/repos/elikem/test_repo/git/trees{/sha}", "statuses_url"=>"https://api.github.com/repos/elikem/test_repo/statuses/{sha}", "languages_url"=>"https://api.github.com/repos/elikem/test_repo/languages", "stargazers_url"=>"https://api.github.com/repos/elikem/test_repo/stargazers", "contributors_url"=>"https://api.github.com/repos/elikem/test_repo/contributors", "subscribers_url"=>"https://api.github.com/repos/elikem/test_repo/subscribers", "subscription_url"=>"https://api.github.com/repos/elikem/test_repo/subscription", "commits_url"=>"https://api.github.com/repos/elikem/test_repo/commits{/sha}", "git_commits_url"=>"https://api.github.com/repos/elikem/test_repo/git/commits{/sha}", "comments_url"=>"https://api.github.com/repos/elikem/test_repo/comments{/number}", "issue_comment_url"=>"https://api.github.com/repos/elikem/test_repo/issues/comments/{number}", "contents_url"=>"https://api.github.com/repos/elikem/test_repo/contents/{+path}", "compare_url"=>"https://api.github.com/repos/elikem/test_repo/compare/{base}...{head}", "merges_url"=>"https://api.github.com/repos/elikem/test_repo/merges", "archive_url"=>"https://api.github.com/repos/elikem/test_repo/{archive_format}{/ref}", "downloads_url"=>"https://api.github.com/repos/elikem/test_repo/downloads", "issues_url"=>"https://api.github.com/repos/elikem/test_repo/issues{/number}", "pulls_url"=>"https://api.github.com/repos/elikem/test_repo/pulls{/number}", "milestones_url"=>"https://api.github.com/repos/elikem/test_repo/milestones{/number}", "notifications_url"=>"https://api.github.com/repos/elikem/test_repo/notifications{?since,all,participating}", "labels_url"=>"https://api.github.com/repos/elikem/test_repo/labels{/name}", "releases_url"=>"https://api.github.com/repos/elikem/test_repo/releases{/id}", "created_at"=>"2014-09-14T14:56:29Z", "updated_at"=>"2014-09-14T14:56:29Z", "pushed_at"=>"2014-09-14T14:56:29Z", "git_url"=>"git://github.com/elikem/test_repo.git", "ssh_url"=>"git@github.com:elikem/test_repo.git", "clone_url"=>"https://github.com/elikem/test_repo.git", "svn_url"=>"https://github.com/elikem/test_repo", "homepage"=>nil, "size"=>0, "stargazers_count"=>0, "watchers_count"=>0, "language"=>nil, "has_issues"=>true, "has_downloads"=>true, "has_wiki"=>true, "forks_count"=>0, "mirror_url"=>nil, "open_issues_count"=>0, "forks"=>0, "open_issues"=>0, "watchers"=>0, "default_branch"=>"master", "permissions"=>{"admin"=>true, "push"=>true, "pull"=>true}, "network_count"=>0, "subscribers_count"=>1}, @response=#<Net::HTTPCreated 201 Created readbody=true>, @headers={"server"=>["GitHub.com"], "date"=>["Sun, 14 Sep 2014 14:56:29 GMT"], "content-type"=>["application/json; charset=utf-8"], "connection"=>["close"], "status"=>["201 Created"], "x-ratelimit-limit"=>["5000"], "x-ratelimit-remaining"=>["4995"], "x-ratelimit-reset"=>["1410706876"], "cache-control"=>["private, max-age=60, s-maxage=60"], "etag"=>["\"6e6b4a351fc02fd29abde5d40f270457\""], "location"=>["https://api.github.com/repos/elikem/test_repo"], "vary"=>["Accept, Authorization, Cookie, X-GitHub-OTP"], "x-github-media-type"=>["github.v3"], "x-xss-protection"=>["1; mode=block"], "x-frame-options"=>["deny"], "content-security-policy"=>["default-src 'none'"], "content-length"=>["4521"], "access-control-allow-credentials"=>["true"], "access-control-expose-headers"=>["ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "access-control-allow-origin"=>["*"], "x-github-request-id"=>["6372ADE0:76FA:4B1F6BC:5415AC9D"], "strict-transport-security"=>["max-age=31536000; includeSubdomains; preload"], "x-content-type-options"=>["nosniff"]}>
4
+
5
+ stdout
6
+ https://github.com/elikem/test_repo.git --- COPIED TO CLIPBOARD
7
+
8
+ message
9
+ nil
10
+
11
+ error message
12
+ nil
13
+
14
+ attributes
15
+ {"id"=>24024659, "name"=>"test_repo", "full_name"=>"elikem/test_repo", "owner"=>{"login"=>"elikem", "id"=>1282871, "avatar_url"=>"https://avatars.githubusercontent.com/u/1282871?v=2", "gravatar_id"=>"90eb0e692f7f2767b506510b648bd52c", "url"=>"https://api.github.com/users/elikem", "html_url"=>"https://github.com/elikem", "followers_url"=>"https://api.github.com/users/elikem/followers", "following_url"=>"https://api.github.com/users/elikem/following{/other_user}", "gists_url"=>"https://api.github.com/users/elikem/gists{/gist_id}", "starred_url"=>"https://api.github.com/users/elikem/starred{/owner}{/repo}", "subscriptions_url"=>"https://api.github.com/users/elikem/subscriptions", "organizations_url"=>"https://api.github.com/users/elikem/orgs", "repos_url"=>"https://api.github.com/users/elikem/repos", "events_url"=>"https://api.github.com/users/elikem/events{/privacy}", "received_events_url"=>"https://api.github.com/users/elikem/received_events", "type"=>"User", "site_admin"=>false}, "private"=>false, "html_url"=>"https://github.com/elikem/test_repo", "description"=>"description", "fork"=>false, "url"=>"https://api.github.com/repos/elikem/test_repo", "forks_url"=>"https://api.github.com/repos/elikem/test_repo/forks", "keys_url"=>"https://api.github.com/repos/elikem/test_repo/keys{/key_id}", "collaborators_url"=>"https://api.github.com/repos/elikem/test_repo/collaborators{/collaborator}", "teams_url"=>"https://api.github.com/repos/elikem/test_repo/teams", "hooks_url"=>"https://api.github.com/repos/elikem/test_repo/hooks", "issue_events_url"=>"https://api.github.com/repos/elikem/test_repo/issues/events{/number}", "events_url"=>"https://api.github.com/repos/elikem/test_repo/events", "assignees_url"=>"https://api.github.com/repos/elikem/test_repo/assignees{/user}", "branches_url"=>"https://api.github.com/repos/elikem/test_repo/branches{/branch}", "tags_url"=>"https://api.github.com/repos/elikem/test_repo/tags", "blobs_url"=>"https://api.github.com/repos/elikem/test_repo/git/blobs{/sha}", "git_tags_url"=>"https://api.github.com/repos/elikem/test_repo/git/tags{/sha}", "git_refs_url"=>"https://api.github.com/repos/elikem/test_repo/git/refs{/sha}", "trees_url"=>"https://api.github.com/repos/elikem/test_repo/git/trees{/sha}", "statuses_url"=>"https://api.github.com/repos/elikem/test_repo/statuses/{sha}", "languages_url"=>"https://api.github.com/repos/elikem/test_repo/languages", "stargazers_url"=>"https://api.github.com/repos/elikem/test_repo/stargazers", "contributors_url"=>"https://api.github.com/repos/elikem/test_repo/contributors", "subscribers_url"=>"https://api.github.com/repos/elikem/test_repo/subscribers", "subscription_url"=>"https://api.github.com/repos/elikem/test_repo/subscription", "commits_url"=>"https://api.github.com/repos/elikem/test_repo/commits{/sha}", "git_commits_url"=>"https://api.github.com/repos/elikem/test_repo/git/commits{/sha}", "comments_url"=>"https://api.github.com/repos/elikem/test_repo/comments{/number}", "issue_comment_url"=>"https://api.github.com/repos/elikem/test_repo/issues/comments/{number}", "contents_url"=>"https://api.github.com/repos/elikem/test_repo/contents/{+path}", "compare_url"=>"https://api.github.com/repos/elikem/test_repo/compare/{base}...{head}", "merges_url"=>"https://api.github.com/repos/elikem/test_repo/merges", "archive_url"=>"https://api.github.com/repos/elikem/test_repo/{archive_format}{/ref}", "downloads_url"=>"https://api.github.com/repos/elikem/test_repo/downloads", "issues_url"=>"https://api.github.com/repos/elikem/test_repo/issues{/number}", "pulls_url"=>"https://api.github.com/repos/elikem/test_repo/pulls{/number}", "milestones_url"=>"https://api.github.com/repos/elikem/test_repo/milestones{/number}", "notifications_url"=>"https://api.github.com/repos/elikem/test_repo/notifications{?since,all,participating}", "labels_url"=>"https://api.github.com/repos/elikem/test_repo/labels{/name}", "releases_url"=>"https://api.github.com/repos/elikem/test_repo/releases{/id}", "created_at"=>"2014-09-14T14:56:29Z", "updated_at"=>"2014-09-14T14:56:29Z", "pushed_at"=>"2014-09-14T14:56:29Z", "git_url"=>"git://github.com/elikem/test_repo.git", "ssh_url"=>"git@github.com:elikem/test_repo.git", "clone_url"=>"https://github.com/elikem/test_repo.git", "svn_url"=>"https://github.com/elikem/test_repo", "homepage"=>nil, "size"=>0, "stargazers_count"=>0, "watchers_count"=>0, "language"=>nil, "has_issues"=>true, "has_downloads"=>true, "has_wiki"=>true, "forks_count"=>0, "mirror_url"=>nil, "open_issues_count"=>0, "forks"=>0, "open_issues"=>0, "watchers"=>0, "default_branch"=>"master", "permissions"=>{"admin"=>true, "push"=>true, "pull"=>true}, "network_count"=>0, "subscribers_count"=>1, :repository=>"test_repo", :description=>"description", :wants_ssh=>false, :username=>"elikem", :password=>"password"}
@@ -0,0 +1,12 @@
1
+ irb(main):001:0> Githubrepo.create( { :repository => 'test_repo', :description => 'description', :wants_ssh => false, :username => 'username', :password => 'wrong_password' } )
2
+
3
+ => #<HTTParty::Response:0x7fac9b0302d8 parsed_response={"message"=>"Bad credentials", "documentation_url"=>"https://developer.github.com/v3"}, @response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>, @headers={"server"=>["GitHub.com"], "date"=>["Sun, 14 Sep 2014 14:51:36 GMT"], "content-type"=>["application/json; charset=utf-8"], "connection"=>["close"], "status"=>["401 Unauthorized"], "x-github-media-type"=>["github.v3"], "x-ratelimit-limit"=>["60"], "x-ratelimit-remaining"=>["52"], "x-ratelimit-reset"=>["1410708955"], "x-xss-protection"=>["1; mode=block"], "x-frame-options"=>["deny"], "content-security-policy"=>["default-src 'none'"], "content-length"=>["83"], "access-control-allow-credentials"=>["true"], "access-control-expose-headers"=>["ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "access-control-allow-origin"=>["*"], "x-github-request-id"=>["6372ADE0:13B0:62C5FE6:5415AB77"], "strict-transport-security"=>["max-age=31536000; includeSubdomains; preload"], "x-content-type-options"=>["nosniff"]}>
4
+
5
+ message
6
+ Bad credentials
7
+
8
+ error message
9
+ nil
10
+
11
+ attributes
12
+ {"message"=>"Bad credentials", "documentation_url"=>"https://developer.github.com/v3", :repository=>"test_repo", :description=>"description", :wants_ssh=>false, :username=>"username", :password=>"wrong_password"}
@@ -0,0 +1,12 @@
1
+ irb(main):002:0> Githubrepo.create( { :repository => 'test_repo', :description => 'description', :wants_ssh => false, :username => 'elikem', :password => 'password' } )
2
+
3
+ => #<HTTParty::Response:0x7fdab4bf9d98 parsed_response={"message"=>"Validation Failed", "documentation_url"=>"https://developer.github.com/v3/repos/#create", "errors"=>[{"resource"=>"Repository", "code"=>"custom", "field"=>"name", "message"=>"name already exists on this account"}]}, @response=#<Net::HTTPUnprocessableEntity 422 Unprocessable Entity readbody=true>, @headers={"server"=>["GitHub.com"], "date"=>["Sun, 14 Sep 2014 15:03:15 GMT"], "content-type"=>["application/json; charset=utf-8"], "connection"=>["close"], "status"=>["422 Unprocessable Entity"], "x-ratelimit-limit"=>["5000"], "x-ratelimit-remaining"=>["4999"], "x-ratelimit-reset"=>["1410710595"], "x-github-media-type"=>["github.v3"], "x-xss-protection"=>["1; mode=block"], "x-frame-options"=>["deny"], "content-security-policy"=>["default-src 'none'"], "content-length"=>["215"], "access-control-allow-credentials"=>["true"], "access-control-expose-headers"=>["ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "access-control-allow-origin"=>["*"], "x-github-request-id"=>["6372ADE0:13B0:631282E:5415AE32"], "strict-transport-security"=>["max-age=31536000; includeSubdomains; preload"], "x-content-type-options"=>["nosniff"]}>
4
+
5
+ message
6
+ Validation failed
7
+
8
+ error message
9
+ Name already exists on this account
10
+
11
+ attributes
12
+ {"message"=>"Validation Failed", "documentation_url"=>"https://developer.github.com/v3/repos/#create", "errors"=>[{"resource"=>"Repository", "code"=>"custom", "field"=>"name", "message"=>"name already exists on this account"}], :repository=>"test_repo", :description=>"description", :wants_ssh=>false, :username=>"elikem", :password=>"password"}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elikem Adadevoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,48 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: vcr
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
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: commander
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +175,7 @@ files:
133
175
  - ".gitignore"
134
176
  - ".idea/codeStyleSettings.xml"
135
177
  - ".idea/runConfigurations/githubrepo.xml"
178
+ - ".rspec"
136
179
  - Gemfile
137
180
  - Gemfile.lock
138
181
  - LICENSE.txt
@@ -142,6 +185,14 @@ files:
142
185
  - githubrepo.gemspec
143
186
  - lib/githubrepo.rb
144
187
  - lib/githubrepo/version.rb
188
+ - spec/fixtures/vcr_cassettes/create_a_existing_repository.yml
189
+ - spec/fixtures/vcr_cassettes/create_a_repository.yml
190
+ - spec/fixtures/vcr_cassettes/create_a_repository_with_bad_password.yml
191
+ - spec/githubrepo_spec.rb
192
+ - spec/spec_helper.rb
193
+ - stdout/response.txt
194
+ - stdout/response_with_bad_credentials.txt
195
+ - stdout/response_with_existing_repository.txt
145
196
  homepage: https://github.com/elikem/githubrepo
146
197
  licenses:
147
198
  - MIT
@@ -166,5 +217,9 @@ rubygems_version: 2.2.2
166
217
  signing_key:
167
218
  specification_version: 4
168
219
  summary: CLI to create repositories
169
- test_files: []
170
- has_rdoc:
220
+ test_files:
221
+ - spec/fixtures/vcr_cassettes/create_a_existing_repository.yml
222
+ - spec/fixtures/vcr_cassettes/create_a_repository.yml
223
+ - spec/fixtures/vcr_cassettes/create_a_repository_with_bad_password.yml
224
+ - spec/githubrepo_spec.rb
225
+ - spec/spec_helper.rb