Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ice799 committed Dec 8, 2014
0 parents commit 03ea04a
Show file tree
Hide file tree
Showing 24 changed files with 806 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .document
@@ -0,0 +1,3 @@
-
ChangeLog.rdoc
LICENSE.txt
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
Gemfile.lock
doc/
pkg/
vendor/cache/*.gem
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--colour --format documentation
1 change: 1 addition & 0 deletions .yardopts
@@ -0,0 +1 @@
--markup rdoc --title "packagecloud-ruby Documentation" --protected
7 changes: 7 additions & 0 deletions Gemfile
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem 'excon'
gem 'json_pure'
gem 'mime'

gemspec
20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
Copyright (c) 2014 Computology, LLC

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
101 changes: 101 additions & 0 deletions README.md
@@ -0,0 +1,101 @@
## packagecloud-ruby

Ruby library for communicating with the [packagecloud.io](https://packagecloud.io) API.

* [Homepage](https://rubygems.org/gems/packagecloud-ruby)
* [Documentation](http://rubydoc.info/gems/packagecloud-ruby/frames)
* [Email](mailto:support@packagecloud.io)


## Implemented API Endpoints

* [Get Package Contents](https://packagecloud.io/docs/api#resource_packages_method_contents)
* [Upload Package](https://packagecloud.io/docs/api#resource_packages_method_create)
* [List Distributions](https://packagecloud.io/docs/api#resource_distributions_method_index)
* [View Repository](https://packagecloud.io/docs/api#resource_repositories_method_show)
* [View Repositories](https://packagecloud.io/docs/api#resource_repositories_method_index)
* [Create Repository](https://packagecloud.io/docs/api#resource_repositories_method_create)

## Installation

```
gem install packagecloud-ruby
```

## Creating a Client

```ruby
require 'packagecloud'

# Create a client
credentials = Packagecloud::Credentials.new("joedamato", "test_token")
@client = Packagecloud::Client.new(credentials)

```

## Result objects

Every client API method call returns a ```Result``` object, which is simply:

```ruby
module Packagecloud
class Result
attr_accessor :response
attr_accessor :succeeded
end
end
```

If ```.succeeded``` is ```true``` then, ```.response``` is the parsed JSON response
of that endpoint, otherwise ```.response``` is the error text explaining what went wrong.


## Usage

### Distributions

```ruby
# Get all distributions
distros = @client.distributions

# Looking up a distribution id by name
id = @client.find_distribution_id("centos/6") # returns 12
```

### Repositories

```ruby
# Looking up all repositories available for a client
repos = @client.repositories

# Lookup info on a single repo
repo = @client.repository("my_repo")

# Creating a repository
@client.create_repository("my_repo")

```

### Packages

```ruby
# Create Packages (takes IO object for file)
gem_package = Package.new(open("rails-4.0.0.gem"))
rpm_package = Package.new(open("libcurl-0.1.2.rpm"), 12) # 12 being the distribution id for centos/6, for example

# Creating source Packages
source_files = { "jake_1.0.orig.tar.bz2" => open("/path/jake_1.0.orig.tar.bz2"),
"jake_1.0-7.debian.tar.gz" => open("/path/jake_1.0-7.debian.tar.gz") }
dsc_package = Package.new("jake_1.0-7.dsc", 20, source_files)

# Upload Packages
@client.put_package("test_repo", gem_package)
@client.put_package("test_repo", rpm_package)
@client.put_package("test_repo", dsc_package)
```

## Copyright

Copyright (c) 2014 Computology, LLC

See LICENSE.txt for details.
45 changes: 45 additions & 0 deletions Rakefile
@@ -0,0 +1,45 @@
# encoding: utf-8

require 'rubygems'

begin
require 'bundler'
rescue LoadError => e
warn e.message
warn "Run `gem install bundler` to install Bundler."
exit -1
end

begin
Bundler.setup(:development)
rescue Bundler::BundlerError => e
warn e.message
warn "Run `bundle install` to install missing gems."
exit e.status_code
end

require 'rake'

require 'rubygems/tasks'
Gem::Tasks.new

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

task :test => :spec
task :default => :spec

require 'yard'
YARD::Rake::YardocTask.new
task :doc => :yard

require 'rspec/core/rake_task'

desc "Run all specs with rcov"
RSpec::Core::RakeTask.new("spec:coverage") do |t|
t.rcov = true
t.rcov_opts = %w{-Ispec
--exclude gems\/,spec\/,features\/,seeds\/}
t.spec_opts = ["-c"]
end

4 changes: 4 additions & 0 deletions lib/packagecloud.rb
@@ -0,0 +1,4 @@
require 'packagecloud/version'
require 'packagecloud/client'
require 'packagecloud/package'
require 'packagecloud/credentials'

0 comments on commit 03ea04a

Please sign in to comment.