Class: BobTheBuilder::GitHubUploader
- Inherits:
-
Object
- Object
- BobTheBuilder::GitHubUploader
- Defined in:
- lib/bob_the_builder/git_hub_uploader.rb
Instance Method Summary collapse
- #create(filename, file, description) ⇒ Object
-
#initialize(username, password, repository) ⇒ GitHubUploader
constructor
A new instance of GitHubUploader.
Constructor Details
#initialize(username, password, repository) ⇒ GitHubUploader
Returns a new instance of GitHubUploader.
3 4 5 6 7 |
# File 'lib/bob_the_builder/git_hub_uploader.rb', line 3 def initialize(username, password, repository) @username = CGI.escape(username) @password = CGI.escape(password) @repository = repository end |
Instance Method Details
#create(filename, file, description) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bob_the_builder/git_hub_uploader.rb', line 9 def create(filename, file, description) url = "https://%s:%[email protected]/repos/%s/downloads" % [@username, @password, @repository] params = { 'name' => File.basename(filename), 'size' => File.size(file.path), 'description' => description } response = RestClient.post(url, params.to_json) upload_to_s3(JSON.parse(response.body), file) rescue puts $!.inspect raise end |