Coder Social home page Coder Social logo

packagecloud-ruby's Introduction

packagecloud-ruby

Build Status

Ruby library for communicating with the packagecloud.io API.

Goals

This library aims to have widest amount of compatibility possible between Ruby versions and implementations. All dependencies are pure Ruby and kept to a minimum to ensure this.

Tested Rubies

  • Ruby 1.8.x, 1.9x, and 2.x

Implemented API Endpoints

Installation

gem install packagecloud-ruby

Getting your API token

Login to packagecloud.io and go to your Account Settings to see your API token.

Creating a Client

Note that you should not use the email address associated with your packagecloud.io account when accessing the API. Please use your username on the site.

require 'packagecloud'

# Create a client using your username and API token
credentials = Packagecloud::Credentials.new("joedamato", "my_api_token")
@client = Packagecloud::Client.new(credentials)

Result objects

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

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

This is the list of currently supported distributions.

# Get all distributions
distros = @client.distributions

# Looking up a distribution id by name
id = @client.find_distribution_id("el/6") # returns 27

Repositories

# 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")

When specifying your repository name, you should use just the name and not the fully qualified name (fqname).

For example:

# INCORRECT: this should just be "my_repo"
repo = @client.repository("user/my_repo")

Packages

# Create RPM Packages (can take File, IO, or path argument)
rpm_package = Packagecloud::Package.new(:file => "libcurl-0.1.2.rpm")

# Creating gem Packages using IO (needs :filename passed in)
gem_package = Packagecloud::Package.new(:file => io_object, :filename => "rails-4.0.0.gem")

# 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 = Packagecloud::Package.new(:file => "jake_1.0-7.dsc", :source_files => source_files)

# Upload Packages
@client.put_package("test_repo", gem_package)
@client.put_package("test_repo", rpm_package, "el/6")
@client.put_package("test_repo", dsc_package, "ubuntu/trusty")
@client.put_package("test_repo", node_package, "node")

Copyright

Copyright (c) 2014-2018 Computology, LLC

See LICENSE.txt for details.

packagecloud-ruby's People

Contributors

capotej avatar ice799 avatar mjuarez avatar thattimc avatar armandocanals avatar jules2689 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.