lib/githubrepo.rb in githubrepo-0.2.2 vs lib/githubrepo.rb in githubrepo-0.3.0

- old
+ new

@@ -32,21 +32,27 @@ 'name' => attributes[:repository], 'description' => attributes[:description] }.to_json ) - Githubrepo.parse_response_from(post) + Githubrepo.parse_response_from( post.merge(attributes) ) + + # for testing purposes only -- rspec + if attributes[:rspec] + return post + end end # DRY this by moving to a Parse.response_from(post) def self.parse_response_from(post) attributes = post - clone_url = - if attributes['clone_url'] != nil - attributes['clone_url'] - end + if attributes[:wants_ssh] + repo_url = attributes['ssh_url'] + else + repo_url = attributes['clone_url'] + end message = if attributes['message'] != nil attributes['message'] end @@ -55,31 +61,36 @@ if attributes['errors'] != nil attributes['errors'].first['message'] end # messages to console - if clone_url + if repo_url if OS.mac? - puts "#{clone_url} --- COPIED TO CLIPBOARD" - Clipboard.copy clone_url + puts "#{repo_url} --- COPIED TO CLIPBOARD" + Clipboard.copy repo_url elsif OS.linux? - puts clone_url - Clipboard.copy clone_url - puts "If xclip is installed, repository URL has been added to your clipboard." - puts "debian/ubuntu: apt-get install xclip" - - # Add windows support in the future - # elsif OS.windows? - # Clipboard.copy clone_url - # # Will Clipboard output clone_url to console if ffi is not installed? - # # Below is what it looks like when Clipboard requirements are met - # # https://github.com/user/*.git --- COPIED TO CLIPBOARD - # puts "If ffi is installed, repository URL has been added to your clipboard." - # puts "for installation: gem install ffi" + print repo_url + unless `which xclip`.empty? + print " --- COPIED TO CLIPBOARD\n" + Clipboard.copy repo_url + else + puts "\nInstall xclip if you want to auto-copy repository URL to your clipboard." + puts "debian/ubuntu: apt-get install xclip" + end + elsif OS.windows? + print repo_url + if Gem::Specification::find_all_by_name('ffi').any? + print " --- COPIED TO CLIPBOARD\n" + Clipboard.copy repo_url + else + puts "\nInstall ruby gem 'ffi' to auto-copy repository to your clipboard." + puts "gem install ffi" + end else - puts clone_url + puts repo_url end end + puts message.capitalize if message puts error_message.capitalize if error_message end end