hyperclient 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.9.2-p180-patched@hyperclient --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hyperclient.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Mike Subelsky
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Hyperclient
2
+
3
+ This gem aims to explore and demonstrate how to write a client for [hypermedia APIs](http://blog.steveklabnik.com/posts/2012-02-23-rest-is-over), formerly
4
+ known as REST interfaces that respect the [HATEOAS constraint](http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven).
5
+
6
+ Many people have demonstrated how the server should respond. I'm investigating how the client should behave when interacting with a true hypermedia server.
7
+
8
+ The gem is being developed against the [Hypertext Application Language](http://stateless.co/hal_specification.html) and [Atompub](http://bitworking.org/projects/atom/rfc5023.html) specifications.
9
+
10
+ Contributors welcome!
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'hyperclient'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install hyperclient
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'hyperclient'
30
+
31
+ # NOTE this is the only URI you ever need to specify yourself. The server will provide all future links.
32
+ resource = Hyperclient::Resource.new("http://api.example.com")
33
+
34
+ resource.links.each { |l| puts(l.relation => l.uri) }
35
+ # {:self => "https://api.example.com"}
36
+ # {:orders => "https://api.example.com/orders"}
37
+ # {:customers => "https://api.example.com/customers"}
38
+
39
+ # since we're at the root level of this API we haven't drilled into any objects yet
40
+ pp resource.objects
41
+ # []
42
+
43
+ orders_resource = resource[:orders].get
44
+ pp orders_resource.links
45
+ # {:self => "https://api.example.com/orders",
46
+ # :next => "https://api.example.com/orders/page/2"}
47
+
48
+ # some servers may return embedded objects
49
+ orders_resource.objects.each { |l| puts l.class => l.attributes }
50
+ # [Hyperclient::Resource => {:id => 50, :item_name => "R2 Motivator", :created_at => "2012-02-03 12:15:02 -0400"},
51
+ # Hyperclient::Resource => {:id => 51, :item_name => "Hydrospanner", :created_at => "2012-02-04 13:18:12 -0500"}]
52
+
53
+ order_resource = orders_resource.post({ item_name: "Droid Coolant" })
54
+ pp order_resource.location
55
+ # "https://api.example.com/orders/52"
56
+
57
+ pp order_resource.attributes
58
+ # {:id => 52, :item_name => "Droid Coolant", :created_at => "2012-03-05 21:31:04 -0500"}
59
+ ```
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
68
+
69
+ ## Questions?
70
+
71
+ Contact me on [Twitter](https://twitter/subelsky) or [email](mike@subelsky.com).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/hyperclient/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mike Subelsky"]
6
+ gem.email = ["mike@subelsky.com"]
7
+ gem.description = %q{Proof of concept for interacting with a hypermedia API}
8
+ gem.summary = %q{This client is capable of interacting with hypermedia APIs as described in http://www.subbu.org/blog/2008/09/on-linking-part-1 and elsewhere}
9
+ gem.homepage = "https://github.com/subelsky/hyperclient"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "hyperclient"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Hyperclient::VERSION
17
+ end
@@ -0,0 +1,3 @@
1
+ module Hyperclient
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "hyperclient/version"
2
+
3
+ module Hyperclient
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyperclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mike Subelsky
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-06 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Proof of concept for interacting with a hypermedia API
15
+ email:
16
+ - mike@subelsky.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .rvmrc
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - hyperclient.gemspec
27
+ - lib/hyperclient.rb
28
+ - lib/hyperclient/version.rb
29
+ homepage: https://github.com/subelsky/hyperclient
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.15
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: This client is capable of interacting with hypermedia APIs as described in
53
+ http://www.subbu.org/blog/2008/09/on-linking-part-1 and elsewhere
54
+ test_files: []