pluct 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWY1ZjE4NmM3MzdkNzI2YjA3ZmFkZmZjYjUxZGEwZGJmOWI3MTgyZA==
4
+ ODcxNGUzNmVmZmFiNmQ2MmM0MzYyZWM3ZThhZjU1ZmRkY2Y3ZGU4Mw==
5
5
  data.tar.gz: !binary |-
6
- MmFiODg4OTE4YWFlZTJiZWVlZWJhYTM0YzI0N2NjOWFlNTlmYzM4MQ==
6
+ MGEzZGQwNmQ4ODMwN2YzZmZmNzlkZmQ2OThkMmNiN2JjMGQ1MDgwYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDkwMjhhM2U3ZmFkMDE4NmMzMTY2MWRkMzliZDUyOTA0NjJiZGZjMTEyNzcx
10
- MmUwNzI5MmQwNzEwN2MwNDA5ZDIwNTQyMjVkYzZkOTVmM2RkMWY1Nzk1NTlk
11
- YTRmN2ViZTcwODJlMzA3MTFhNzFiOWMyZTQyY2JhNDBkNDBmYmE=
9
+ NmU1ZTVhNTZiMmNmMWVkZTA1Njk4NTJjMTk2ZmM5NDJiY2Y4MDkzNzdjNzQ0
10
+ MDM1MDkzYzI2NTA1ZmI2MWI2ZjMyMDc1ZDBkMWJmZjk1Mjk4MTkyMDc1NTUw
11
+ ODBkMDc2OTg4YWIxM2U2ZjBkZTg2N2VmNWU3NDRmNTZjNTE3NTE=
12
12
  data.tar.gz: !binary |-
13
- NzgxMTU5NTNmYzQ5ZjUxMzdmYjYxZTIxNzhhOTFhYzczZWUzM2U3OTdkYTY2
14
- NDgxYWUxY2JlZGRkMzIzZjZjN2FjNjcwMjg4NGRiNDlhNzZhNDIxZDlhMTVl
15
- NDNlOTlhMGExMTZmOWFjZWM2NDc1ZTAxOGE1NDEwOWI3ODczNTc=
13
+ ZmE0MGZmYWNmNjMxN2JmZDU2M2VkMmY1ODE2OGRhZjY1MzBlZDMxZjgyZjNj
14
+ OTg2MDkwYjZmYjhmNDg4YmQwYmYzNTg5NDI3OWVjZjhmZmVlYzE1YjRjMTQy
15
+ YzViYTE4MzhiYjI5OWNhZGI2YTRkZTA5YjdhZDNjY2I1ZWEwNTA=
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  *.swp
19
+ tags
20
+ .DS_Store
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pluct
2
2
 
3
- TODO: Write a gem description
3
+ WIP
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,8 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
22
-
21
+ ```ruby
22
+ require 'pluct'
23
+ resource = Pluct.get_resource 'http://example.org/posts'
24
+ p resource.schema
25
+ p resource.schema.data
26
+ p resource.data
27
+ ```
23
28
  ## Contributing
24
29
 
25
30
  1. Fork it
data/lib/pluct/errors.rb CHANGED
@@ -8,5 +8,8 @@ module Pluct
8
8
  super
9
9
  end
10
10
  end
11
+
12
+ class UrlNotFound < PluctErrors; end;
13
+ class Unauthorized < PluctErrors; end;
11
14
  end
12
15
  end
@@ -0,0 +1,5 @@
1
+ require 'hashie'
2
+
3
+ class Hash
4
+ include Hashie::Extensions::MethodAccess
5
+ end
@@ -0,0 +1,79 @@
1
+ require 'rest_client'
2
+
3
+ module Pluct
4
+ module Helpers
5
+ module Request
6
+ DEFAULT_HEADERS = {
7
+ 'content-type' => 'application/json'
8
+ }
9
+
10
+ protected
11
+ def get(url, *opts)
12
+ options = Hash[*opts]
13
+ resource = RestClient::Resource.new(url)
14
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
15
+ resource.get(options)
16
+ rescue RestClient::Exception => e
17
+ raise_exception(e)
18
+ end
19
+
20
+ def head(url, *opts)
21
+ options = Hash[*opts]
22
+ resource = RestClient::Resource.new(url)
23
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
24
+ resource.head(options)
25
+ rescue RestClient::Exception => e
26
+ raise_exception(e)
27
+ end
28
+
29
+ def delete(url, *opts)
30
+ options = Hash[*opts]
31
+ resource = RestClient::Resource.new(url)
32
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
33
+ resource.delete(options)
34
+ rescue RestClient::Exception => e
35
+ raise_exception(e)
36
+ end
37
+
38
+ def post(url, *opts)
39
+ data, options = *opts
40
+ options = Hash[*opts] if options
41
+ resource = RestClient::Resource.new(url)
42
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
43
+ resource.post(data.to_json, options)
44
+ rescue RestClient::Exception => e
45
+ raise_exception(e)
46
+ end
47
+
48
+ def put(url, *opts)
49
+ data, options = *opts
50
+ options = Hash[*opts] if options
51
+ resource = RestClient::Resource.new(url)
52
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
53
+ resource.put(data, options)
54
+ rescue RestClient::Exception => e
55
+ raise_exception(e)
56
+ end
57
+
58
+ def patch(url, *opts)
59
+ data, options = *opts
60
+ options = Hash[*opts] if options
61
+ resource = RestClient::Resource.new(url)
62
+ options = DEFAULT_HEADERS.merge(options) || DEFAULT_HEADERS
63
+ resource.patch(data, options)
64
+ rescue RestClient::Exception => e
65
+ raise_exception(e)
66
+ end
67
+
68
+ private
69
+ def raise_exception(exception)
70
+ case exception.http_code
71
+ when 401
72
+ raise Pluct::Errors::Unauthorized, {http_code: 401, error_description: exception.http_body}
73
+ when 404
74
+ raise Pluct::Errors::UrlNotFound, {http_code: 404, error_description: exception.http_body}
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ module Pluct
2
+ module Helpers
3
+ autoload :Request, "pluct/helpers/request"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ module Pluct
2
+ class Resource
3
+ include Pluct::Helpers::Request
4
+
5
+ attr_reader :url, :data, :schema
6
+
7
+ def initialize(url, schema)
8
+ @url = url
9
+ @data = get_data
10
+ @schema = schema
11
+ Resource.create_methods(@schema.links) if @schema
12
+ end
13
+
14
+ #TODO: Authenticate the request if necessary.
15
+ def get_data
16
+ get @url
17
+ end
18
+
19
+ private
20
+ def self.create_methods(links=[])
21
+ links.each do |link|
22
+ define_method link.rel do |*args|
23
+ method = link["method"] || "GET"
24
+ send(method.downcase, link.href, *args)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module Pluct
2
+ class Schema
3
+ include Pluct::Helpers::Request
4
+
5
+ attr_reader :path, :data, :links
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ @data = get_content
10
+ @links = @data.links
11
+ end
12
+
13
+ def to_s
14
+ @path
15
+ end
16
+
17
+ private
18
+ def get_content
19
+ ::MultiJson.decode(get(@path))
20
+ end
21
+ end
22
+ end
data/lib/pluct/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pluct
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/pluct.rb CHANGED
@@ -1,5 +1,32 @@
1
- require "pluct/version"
1
+ require 'pluct/version'
2
+ require 'multi_json'
3
+ require 'pluct/extensions/hash'
2
4
 
3
5
  module Pluct
4
- autoload :Errors, "pluct/errors"
6
+ autoload :Errors, "pluct/errors"
7
+ autoload :Helpers, "pluct/helpers"
8
+ autoload :Resource, "pluct/resource"
9
+ autoload :Schema, "pluct/schema"
10
+
11
+ extend Pluct::Helpers::Request
12
+
13
+ def self.get_resource(path)
14
+ request = get(path)
15
+ schema = schema_from_header(request.headers)
16
+ resource = Resource.new(path, schema)
17
+ end
18
+
19
+ def self.root
20
+ File.expand_path '../..', __FILE__
21
+ end
22
+
23
+ private
24
+ def self.schema_from_header(headers)
25
+ return nil unless headers[:content_type]
26
+
27
+ schema = headers[:content_type].match('.*profile=([^;]+);?')
28
+ return nil unless schema
29
+
30
+ Schema.new(schema[1])
31
+ end
5
32
  end
data/pluct.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["albertonb@gmail.com"]
11
11
  spec.description = %q{json-schema hypermedia client}
12
12
  spec.summary = %q{json-schema hypermedia client}
13
- spec.homepage = "http://github.com/albertoleal/pluct"
13
+ spec.homepage = "http://github.com/globocom/pluct"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -19,7 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "hashie"
23
+ spec.add_development_dependency "multi_json"
22
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rest-client"
23
26
  spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "multi_json"
27
+ spec.add_development_dependency "vcr"
28
+ spec.add_development_dependency "webmock"
29
+
30
+ spec.add_development_dependency "pry"
31
+ spec.add_development_dependency "pry-nav"
25
32
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pluct, :acceptance do
4
+
5
+ it '', :vcr, cassette_name: 'acceptance/pluct_resource' do
6
+ resource = Pluct.get_resource 'http://repos.example.com/interatividade/famosos'
7
+ resource_self = MultiJson.decode(resource.self)
8
+
9
+ expect(resource_self).to have_key("items")
10
+ expect(resource_self.item_count).to eq 2
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ {
2
+ "name" : "Foo",
3
+ "Age": 20
4
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "title" : "Users",
3
+ "properties" : {
4
+ "name" : {
5
+ "type" : "string"
6
+ },
7
+ "age": {
8
+ "type" : "integer"
9
+ }
10
+ },
11
+ "links": [
12
+ {
13
+ "href": "http://example.org/users/{resource_id}",
14
+ "rel": "self"
15
+ },
16
+
17
+ {
18
+ "href": "http://example.org/users/{resource_id}",
19
+ "method": "PATCH",
20
+ "rel": "edit"
21
+ },
22
+
23
+ {
24
+ "href": "http://example.org/users/{resource_id}",
25
+ "method": "PUT",
26
+ "rel": "replace"
27
+ },
28
+
29
+ {
30
+ "href": "http://example.org/users/{resource_id}",
31
+ "method": "DELETE",
32
+ "rel": "delete"
33
+ },
34
+
35
+ {
36
+ "href": "http://example.org/users",
37
+ "method": "POST",
38
+ "rel": "create"
39
+ }
40
+ ]
41
+ }
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ class Client
4
+ include Pluct::Helpers::Request
5
+ end
6
+
7
+ describe Pluct::Helpers::Request do
8
+ let(:client) { Client.new }
9
+
10
+ request = [
11
+ { http_code: 401, body: 'Unauthorized.', url: 'http://www.example.com/unauthorized', exception: Pluct::Errors::Unauthorized },
12
+ { http_code: 404, body: 'Not found.', url: 'http://www.example.com/invalid-url', exception: Pluct::Errors::UrlNotFound},
13
+ ]
14
+
15
+ request.each do |req|
16
+ it "raises an exception #{req[:http_code]}" do
17
+ stub_request(:get, req[:url]).to_return(body: req[:body], status: req[:http_code])
18
+ # expect { client.get req[:url] }.to raise_exception(req[:exception], {http_code: req[:http_code], error_description: req[:body]})
19
+ expect { client.send(:get, req[:url]) }.to raise_exception(req[:exception], {http_code: req[:http_code], error_description: req[:body]})
20
+ end
21
+ end
22
+
23
+ it 'returns 200 for valid request' do
24
+ body = File.read('spec/assets/user.json')
25
+ stub_request(:get, 'http://www.example.com/success').to_return(body: body, status: 200)
26
+ response = client.send(:get, 'http://www.example.com/success')
27
+
28
+ WebMock.should have_requested(:get, "http://www.example.com/success").with(headers: {'Content-Type' => 'application/json'})
29
+ expect(response.code).to eq 200
30
+ expect(response.body).to eq body
31
+ end
32
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pluct::Resource do
4
+ let(:schema) { mock(Pluct::Schema) }
5
+ let(:user) { Pluct::Resource.new 'www.example.com/users/1', schema }
6
+ let(:user_without_content_type) { Pluct::Resource.new 'www.example.com/users/2' }
7
+ let(:user_without_schema) { Pluct::Resource.new 'www.example.com/users/3' }
8
+ let(:user_schema) { MultiJson.decode(File.read('spec/assets/user_schema.json')) }
9
+
10
+ before(:each) do
11
+ stub_request(:get, 'www.example.com/users/1').to_return(body: File.read('spec/assets/user.json'),
12
+ status: 200,
13
+ headers: {'content-type' => 'application/json; charset=utf-8; profile=http://www.example.com/schemas/user'})
14
+
15
+
16
+ stub_request(:get, 'www.example.com/users/2').to_return(body: File.read('spec/assets/user.json'),
17
+ status: 200)
18
+
19
+ stub_request(:get, 'www.example.com/users/3').to_return(body: File.read('spec/assets/user.json'),
20
+ status: 200,
21
+ headers: {'content-type' => 'application/json; charset=utf-8;'})
22
+
23
+ stub_request(:get, 'www.example.com/schemas/user').to_return(body: File.read('spec/assets/user_schema.json'),
24
+ status: 200)
25
+
26
+ schema.stub(:links).and_return(user_schema.links)
27
+ end
28
+
29
+ it 'has resource data' do
30
+ resource_data = File.read('spec/assets/user.json')
31
+ expect(user.data).to eq resource_data
32
+ end
33
+
34
+ it 'adds methods' do
35
+ methods = [:edit, :replace, :self, :delete, :create]
36
+ methods.each do |method|
37
+ expect(user.class.instance_methods(false)).to include(method)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pluct::Schema do
4
+
5
+ let(:schema) { Pluct::Schema.new 'www.example.com/schemas/user' }
6
+
7
+ before (:each) do
8
+ stub_request(:get, 'www.example.com/schemas/user').to_return(body: File.read('spec/assets/user_schema.json'),
9
+ status: 200)
10
+ end
11
+
12
+ it { expect(schema.to_s).to eq 'www.example.com/schemas/user' }
13
+
14
+ it 'has a schema data' do
15
+ jsonschema = MultiJson::decode(File.read('spec/assets/user_schema.json'))
16
+
17
+ expect(schema.data).to be_instance_of Hash
18
+ expect(schema.data).to eq jsonschema
19
+ end
20
+
21
+ it 'has links' do
22
+ expect(schema.links).to have(5).items
23
+ end
24
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,25 @@
1
+ require 'pry'
2
+ require 'pry-nav'
3
+ require 'webmock/rspec'
4
+ require 'vcr'
5
+ require_relative '../lib/pluct'
6
+
7
+ Dir[File.join Pluct.root, "spec/support/**/*.rb"].each {|f| require f}
8
+
1
9
 
2
10
  RSpec.configure do |config|
3
11
  config.treat_symbols_as_metadata_keys_with_true_values = true
4
12
  config.run_all_when_everything_filtered = true
5
13
  config.filter_run :focus
6
-
14
+ config.mock_with :rspec
7
15
  # Run specs in random order to surface order dependencies. If you find an
8
16
  # order dependency and want to debug it, you can fix the order by providing
9
17
  # the seed, which is printed after each run.
10
18
  # --seed 1234
11
19
  config.order = 'random'
20
+
21
+ #Configuring VCR gem
22
+ config.around(:each, :vcr) do |example|
23
+ VCR.use_cassette(example.metadata[:cassette_name]) { example.call }
24
+ end
12
25
  end
@@ -0,0 +1,200 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://repos.example.com/interatividade/famosos
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Origin:
24
+ - ! '*'
25
+ Content-Type:
26
+ - application/json; charset=UTF-8; profile=http://repos.example.com/interatividade/schemas/famoso-collection
27
+ Date:
28
+ - Tue, 11 Jun 2013 13:20:45 GMT
29
+ Etag:
30
+ - ! '"504bb93b367e8d268b6f4d28ea50c788bd96d60b"'
31
+ Link:
32
+ - <http://repos.example.com/interatividade/schemas/famoso-collection>;
33
+ rel=describedby
34
+ Server:
35
+ - nginx/1.1.19
36
+ Content-Length:
37
+ - '948'
38
+ Connection:
39
+ - keep-alive
40
+ body:
41
+ encoding: US-ASCII
42
+ string: ! '{"items": [{"cadun_id": 1, "name": "Alberto", "resource_id":
43
+ "4c7829d7ff4f4e428f6f1571f7a3f760"}, {"cadun_id": 2, "name": "Nathalia", "resource_id":
44
+ "afa8bad7b7734cabb63d720b6470afcf"}], "links": [{"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
45
+ "rel": "item"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
46
+ "method": "PATCH", "rel": "edit"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
47
+ "method": "PUT", "rel": "replace"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
48
+ "method": "DELETE", "rel": "delete"}, {"href": "http://repos.example.com/interatividade/famosos",
49
+ "rel": "self"}, {"href": "http://repos.example.com/interatividade/famosos",
50
+ "method": "POST", "rel": "create", "schema": {"$ref": "http://repos.example.com/interatividade/schemas/famoso"}}],
51
+ "item_count": 2}'
52
+ http_version:
53
+ recorded_at: Tue, 11 Jun 2013 13:20:03 GMT
54
+ - request:
55
+ method: get
56
+ uri: http://repos.example.com/interatividade/schemas/famoso-collection
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ Accept:
62
+ - ! '*/*; q=0.5, application/xml'
63
+ Accept-Encoding:
64
+ - gzip, deflate
65
+ Content-Type:
66
+ - application/json
67
+ User-Agent:
68
+ - Ruby
69
+ response:
70
+ status:
71
+ code: 200
72
+ message: OK
73
+ headers:
74
+ Access-Control-Allow-Origin:
75
+ - ! '*'
76
+ Content-Type:
77
+ - application/json; charset=UTF-8
78
+ Date:
79
+ - Tue, 11 Jun 2013 13:20:46 GMT
80
+ Etag:
81
+ - ! '"255aaff177c521d6807d015ce8021c92f20a67ec"'
82
+ Server:
83
+ - nginx/1.1.19
84
+ Content-Length:
85
+ - '487'
86
+ Connection:
87
+ - keep-alive
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ! '{"links": [{"href": "http://repos.example.com/interatividade/famosos",
91
+ "rel": "self"}, {"href": "http://repos.example.com/interatividade/famosos",
92
+ "method": "POST", "rel": "create", "schema": {"$ref": "http://repos.example.com/interatividade/schemas/famoso"}},
93
+ {"href": "http://repos.example.com/interatividade/famosos?page={prev_page}",
94
+ "rel": "prev"}, {"href": "http://repos.example.com/interatividade/famosos?page={next_page}",
95
+ "rel": "next"}]}'
96
+ http_version:
97
+ recorded_at: Tue, 11 Jun 2013 13:20:03 GMT
98
+ - request:
99
+ method: get
100
+ uri: http://repos.example.com/interatividade/famosos
101
+ body:
102
+ encoding: US-ASCII
103
+ string: ''
104
+ headers:
105
+ Accept:
106
+ - ! '*/*; q=0.5, application/xml'
107
+ Accept-Encoding:
108
+ - gzip, deflate
109
+ Content-Type:
110
+ - application/json
111
+ User-Agent:
112
+ - Ruby
113
+ response:
114
+ status:
115
+ code: 200
116
+ message: OK
117
+ headers:
118
+ Access-Control-Allow-Origin:
119
+ - ! '*'
120
+ Content-Type:
121
+ - application/json; charset=UTF-8; profile=http://repos.example.com/interatividade/schemas/famoso-collection
122
+ Date:
123
+ - Tue, 11 Jun 2013 13:20:46 GMT
124
+ Etag:
125
+ - ! '"504bb93b367e8d268b6f4d28ea50c788bd96d60b"'
126
+ Link:
127
+ - <http://repos.example.com/interatividade/schemas/famoso-collection>;
128
+ rel=describedby
129
+ Server:
130
+ - nginx/1.1.19
131
+ Content-Length:
132
+ - '948'
133
+ Connection:
134
+ - keep-alive
135
+ body:
136
+ encoding: US-ASCII
137
+ string: ! '{"items": [{"cadun_id": 1, "name": "Alberto", "resource_id":
138
+ "4c7829d7ff4f4e428f6f1571f7a3f760"}, {"cadun_id": 2, "name": "Nathalia", "resource_id":
139
+ "afa8bad7b7734cabb63d720b6470afcf"}], "links": [{"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
140
+ "rel": "item"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
141
+ "method": "PATCH", "rel": "edit"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
142
+ "method": "PUT", "rel": "replace"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
143
+ "method": "DELETE", "rel": "delete"}, {"href": "http://repos.example.com/interatividade/famosos",
144
+ "rel": "self"}, {"href": "http://repos.example.com/interatividade/famosos",
145
+ "method": "POST", "rel": "create", "schema": {"$ref": "http://repos.example.com/interatividade/schemas/famoso"}}],
146
+ "item_count": 2}'
147
+ http_version:
148
+ recorded_at: Tue, 11 Jun 2013 13:20:03 GMT
149
+ - request:
150
+ method: get
151
+ uri: http://repos.example.com/interatividade/famosos
152
+ body:
153
+ encoding: US-ASCII
154
+ string: ''
155
+ headers:
156
+ Accept:
157
+ - ! '*/*; q=0.5, application/xml'
158
+ Accept-Encoding:
159
+ - gzip, deflate
160
+ Content-Type:
161
+ - application/json
162
+ User-Agent:
163
+ - Ruby
164
+ response:
165
+ status:
166
+ code: 200
167
+ message: OK
168
+ headers:
169
+ Access-Control-Allow-Origin:
170
+ - ! '*'
171
+ Content-Type:
172
+ - application/json; charset=UTF-8; profile=http://repos.example.com/interatividade/schemas/famoso-collection
173
+ Date:
174
+ - Tue, 11 Jun 2013 13:20:46 GMT
175
+ Etag:
176
+ - ! '"504bb93b367e8d268b6f4d28ea50c788bd96d60b"'
177
+ Link:
178
+ - <http://repos.example.com/interatividade/schemas/famoso-collection>;
179
+ rel=describedby
180
+ Server:
181
+ - nginx/1.1.19
182
+ Content-Length:
183
+ - '948'
184
+ Connection:
185
+ - keep-alive
186
+ body:
187
+ encoding: US-ASCII
188
+ string: ! '{"items": [{"cadun_id": 1, "name": "Alberto", "resource_id":
189
+ "4c7829d7ff4f4e428f6f1571f7a3f760"}, {"cadun_id": 2, "name": "Nathalia", "resource_id":
190
+ "afa8bad7b7734cabb63d720b6470afcf"}], "links": [{"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
191
+ "rel": "item"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
192
+ "method": "PATCH", "rel": "edit"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
193
+ "method": "PUT", "rel": "replace"}, {"href": "http://repos.example.com/interatividade/famosos/{resource_id}",
194
+ "method": "DELETE", "rel": "delete"}, {"href": "http://repos.example.com/interatividade/famosos",
195
+ "rel": "self"}, {"href": "http://repos.example.com/interatividade/famosos",
196
+ "method": "POST", "rel": "create", "schema": {"$ref": "http://repos.example.com/interatividade/schemas/famoso"}}],
197
+ "item_count": 2}'
198
+ http_version:
199
+ recorded_at: Tue, 11 Jun 2013 13:20:03 GMT
200
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,5 @@
1
+ VCR.configure do |c|
2
+ c.cassette_library_dir = File.join Pluct.root, "spec", "support", "vcr"
3
+ c.hook_into :webmock
4
+ c.allow_http_connections_when_no_cassette = true
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alberto Leal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-09 00:00:00.000000000 Z
11
+ date: 2013-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +66,20 @@ dependencies:
38
66
  - - ! '>='
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: rspec
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +95,49 @@ dependencies:
53
95
  - !ruby/object:Gem::Version
54
96
  version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
- name: multi_json
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-nav
57
141
  requirement: !ruby/object:Gem::Requirement
58
142
  requirements:
59
143
  - - ! '>='
@@ -81,10 +165,23 @@ files:
81
165
  - Rakefile
82
166
  - lib/pluct.rb
83
167
  - lib/pluct/errors.rb
168
+ - lib/pluct/extensions/hash.rb
169
+ - lib/pluct/helpers.rb
170
+ - lib/pluct/helpers/request.rb
171
+ - lib/pluct/resource.rb
172
+ - lib/pluct/schema.rb
84
173
  - lib/pluct/version.rb
85
174
  - pluct.gemspec
175
+ - spec/acceptance/pluct_spec.rb
176
+ - spec/assets/user.json
177
+ - spec/assets/user_schema.json
178
+ - spec/pluct/helpers/request_spec.rb
179
+ - spec/pluct/resource_spec.rb
180
+ - spec/pluct/schema_spec.rb
86
181
  - spec/spec_helper.rb
87
- homepage: http://github.com/albertoleal/pluct
182
+ - spec/support/vcr.rb
183
+ - spec/support/vcr/acceptance/pluct_resource.yml
184
+ homepage: http://github.com/globocom/pluct
88
185
  licenses:
89
186
  - MIT
90
187
  metadata: {}
@@ -109,5 +206,13 @@ signing_key:
109
206
  specification_version: 4
110
207
  summary: json-schema hypermedia client
111
208
  test_files:
209
+ - spec/acceptance/pluct_spec.rb
210
+ - spec/assets/user.json
211
+ - spec/assets/user_schema.json
212
+ - spec/pluct/helpers/request_spec.rb
213
+ - spec/pluct/resource_spec.rb
214
+ - spec/pluct/schema_spec.rb
112
215
  - spec/spec_helper.rb
216
+ - spec/support/vcr.rb
217
+ - spec/support/vcr/acceptance/pluct_resource.yml
113
218
  has_rdoc: