File: README.md

package info (click to toggle)
ruby-sawyer 0.9.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 280 kB
  • sloc: ruby: 1,224; sh: 17; makefile: 4
file content (62 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Sawyer

Sawyer is an experimental hypermedia agent for Ruby built on top of [Faraday][faraday].

[faraday]: https://github.com/lostisland/faraday

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'sawyer'
```

And then execute:

```sh
bundle
```

Or install it yourself as:

```sh
gem install sawyer
```

## Usage

```ruby
require "sawyer"

# Create a Sawyer agent
agent = Sawyer::Agent.new("https://api.github.com",
  links_parser: Sawyer::LinkParsers::Simple.new)

# Fetch the root of the API
root = agent.root.data

# Access a resource directly
contributors = agent.call(:get, "repos/lostisland/sawyer/contributors").data

# Load a hypermedia relation
top_contributor = contributors.first
followers = top_contributor.rels[:followers].get.data
```

For more information, check out the [documentation](http://www.rubydoc.info/gems/sawyer/).

## Development

After checking out the repo, run `script/test` to bootstrap the project and run the tests.
You can also run `script/console` for an interactive prompt that will allow you to experiment.

To package the gem, run `script/package`. To release a new version, update the version number in [`lib/sawyer.rb`](lib/sawyer.rb), and then run `script/release`, which will create a git tag for the version, push git commits and tags, and push the .gem file to [rubygems.org](https://rubygems.org).

## Contributing

Check out the [contributing guide](CONTRIBUTING.md) for more information on contributing.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).