RUBYAPI.md 1.93 KB
Newer Older
Antonio Terceiro's avatar
Antonio Terceiro committed
1 2 3 4 5 6 7 8 9 10 11 12 13
# The debci Ruby API

The main entry point of the API is the {Debci::Repository} class. It will allow
you to find objects representing specific packages, and from there to test run
results.

## Accessing packages

```
require 'debci'
repository = Debci::Repository.new
```

14
With a repository object, you can obtain {Debci::Package} objects:
Antonio Terceiro's avatar
Antonio Terceiro committed
15 16 17 18 19

```
package = repository.find_package('rails-3.2')
```

20
## Obtaining data for a given package
Antonio Terceiro's avatar
Antonio Terceiro committed
21

22
With a Debci::Package object, you can obtain the current status with the
Antonio Terceiro's avatar
Antonio Terceiro committed
23 24 25 26 27 28
`status` method. This method will return a table with architectures on rows,
suites on columns, and a status object in each cell.

```
status_table = package.status
```
29 30 31 32 33 34 35 36 37
### Obtaining package suites and architectures

A Debci::Package object will give the suites and architectures it is currently
available on through the `suites` and `architectures` methods.

```
puts package.suites
puts package.architectures
```
Antonio Terceiro's avatar
Antonio Terceiro committed
38

39 40
### Getting package news

Antonio Terceiro's avatar
Antonio Terceiro committed
41 42 43 44 45
The `news` method will return a news feed for that package, listing test runs
where the package status changed from `pass` to `fail` or the other way around.

```
news = package.news
46

Antonio Terceiro's avatar
Antonio Terceiro committed
47 48 49 50 51
news.each do |item|
  puts item.headline
end
```

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
### Finding package failures (Overall Status)

The `failures` method returns an array of suite/architectures that the package
is failing. If there are no failures, nothing is returned.

```
failures = package.failures

if failures
  puts failures
else
  puts 'Passing everywhere'
end
```

### Getting test history

The `history` method obtains a package`s test history on a specific
suite and architecture. This method will return an array of {Debci::Status}
objects where each object represents one test entry.

```
history = package.history('unstable', 'amd64')

puts package.name

history.each do |entry|
  puts 'Version: ' + entry.version
  puts 'Date: ' + entry.date
  puts 'Status: ' + entry.status
end
```
Antonio Terceiro's avatar
Antonio Terceiro committed
84
See the documentation for the {Debci::Package} class for more information.