halibut 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +23 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Guardfile +30 -0
- data/LICENSE +22 -0
- data/README.md +74 -0
- data/Rakefile +10 -0
- data/halibut.gemspec +35 -0
- data/lib/halibut.rb +9 -0
- data/lib/halibut/link.rb +46 -0
- data/lib/halibut/relation_map.rb +35 -0
- data/lib/halibut/resource.rb +54 -0
- data/lib/halibut/version.rb +4 -0
- data/spec/fixtures/example.json +30 -0
- data/spec/fixtures/example.xml +18 -0
- data/spec/fixtures/minimal.json +1 -0
- data/spec/fixtures/simple.json +4 -0
- data/spec/link_spec.rb +53 -0
- data/spec/relation_map_spec.rb +27 -0
- data/spec/resource_spec.rb +68 -0
- data/spec/spec_helper.rb +16 -0
- metadata +267 -0
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
|
15
|
+
Gemfile.lock
|
16
|
+
|
17
|
+
# YARD artifacts
|
18
|
+
.yardoc
|
19
|
+
_yardoc
|
20
|
+
doc/
|
21
|
+
|
22
|
+
# OS X artifacts
|
23
|
+
.DS_Store
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create default@halibut
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'bundler' do
|
5
|
+
watch('Gemfile')
|
6
|
+
# Uncomment next line if Gemfile contain `gemspec' command
|
7
|
+
watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'minitest' do
|
11
|
+
# with Minitest::Unit
|
12
|
+
# watch(%r|^test/(.*)\/?test_(.*)\.rb|)
|
13
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
14
|
+
# watch(%r|^test/test_helper\.rb|) { "test" }
|
15
|
+
|
16
|
+
# with Minitest::Spec
|
17
|
+
watch(%r|^spec/(.*)_spec\.rb|)
|
18
|
+
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
19
|
+
watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
20
|
+
|
21
|
+
# Rails 3.2
|
22
|
+
# watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
|
23
|
+
# watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
|
24
|
+
# watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
|
25
|
+
|
26
|
+
# Rails
|
27
|
+
# watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
|
28
|
+
# watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
|
29
|
+
# watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
|
30
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ricardo Mendes
|
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,74 @@
|
|
1
|
+
# Halibut
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'halibut'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install halibut
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## RDD
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# Namespaces
|
27
|
+
Halibut::JSON
|
28
|
+
Halibut::XML
|
29
|
+
Halibut::HAL
|
30
|
+
|
31
|
+
Halibut::JSON::Document
|
32
|
+
Halibut::JSON::Builder
|
33
|
+
|
34
|
+
Halibut::XML::Document
|
35
|
+
Halibut::XML::Builder
|
36
|
+
|
37
|
+
Halibut::HAL::Document
|
38
|
+
Halibut::HAL::Document::LinkSet
|
39
|
+
Halibut::HAL::Document::ResourceSet
|
40
|
+
Halibut::HAL::Document::AttributeSet (?)
|
41
|
+
Halibut::HAL::Link
|
42
|
+
Halibut::HAL::Resource
|
43
|
+
|
44
|
+
hal = Halibut::XML::Builder.new "/api/news" do |it|
|
45
|
+
it.attr "some_attribute", "The Value of the Attribute"
|
46
|
+
it.attr "another_attribute", "The Value of Another Attribute"
|
47
|
+
|
48
|
+
it.link "search", "/api/news{?search}", :templated => true
|
49
|
+
|
50
|
+
it.resource "relation", "/href/etc" do |r|
|
51
|
+
r.attr "again", "this"
|
52
|
+
r.attr "this", "again"
|
53
|
+
|
54
|
+
r.link "search", "/href/etc?search={term}", :templated => true, :title => "Embedded Resource"
|
55
|
+
end
|
56
|
+
it.resource "relation", "/href/more" do |r|
|
57
|
+
r.attr "again", "this"
|
58
|
+
r.attr "this", "again"
|
59
|
+
|
60
|
+
r.link "search", "/href/more?search={term}", :templated => true, :title => "Embedded Resource"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
hal.to_xml
|
64
|
+
|
65
|
+
news = Halibut::HAL::Link.new "index", "/api/news"
|
66
|
+
```
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/halibut.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/halibut/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ricardo Mendes"]
|
6
|
+
gem.email = ["rokusu@gmail.com"]
|
7
|
+
gem.description = %q{Toolkit to work with HAL}
|
8
|
+
gem.summary = %q{A HAL parser and builder for use in Hypermedia APIs}
|
9
|
+
gem.homepage = "http://locks.github.com/halibut"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "halibut"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Halibut::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "multi_json"
|
19
|
+
gem.add_dependency "nokogiri"
|
20
|
+
gem.add_dependency "uri_template"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
|
24
|
+
gem.add_development_dependency "pry"
|
25
|
+
gem.add_development_dependency "pry-full"
|
26
|
+
gem.add_development_dependency "pry-coolline"
|
27
|
+
#gem.add_development_dependency "pry-debundle"
|
28
|
+
|
29
|
+
gem.add_development_dependency "minitest"
|
30
|
+
gem.add_development_dependency "guard"
|
31
|
+
gem.add_development_dependency "guard-bundler"
|
32
|
+
gem.add_development_dependency "guard-minitest"
|
33
|
+
|
34
|
+
gem.add_development_dependency "terminal-notifier-guard"
|
35
|
+
end
|
data/lib/halibut.rb
ADDED
data/lib/halibut/link.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Halibut
|
2
|
+
|
3
|
+
class Link
|
4
|
+
attr_reader :href, :templated, :type, :name,
|
5
|
+
:profile, :title, :hreflang
|
6
|
+
|
7
|
+
def initialize(href, templated=nil, opts={})
|
8
|
+
@href = href
|
9
|
+
@templated = templated
|
10
|
+
|
11
|
+
set_options opts
|
12
|
+
end
|
13
|
+
|
14
|
+
def templated?
|
15
|
+
@templated || false
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
# hash = { 'href' => @href }
|
20
|
+
# hash['templated'] = @templated unless @templated.nil?
|
21
|
+
a = instance_variables.each_with_object({}) do |name, output|
|
22
|
+
next if (ivar = instance_variable_get(name)).nil?
|
23
|
+
|
24
|
+
output[name[1..-1]] = ivar
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
a
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@href.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
def set_options(opts)
|
38
|
+
@type = opts[:type]
|
39
|
+
@name = opts[:name]
|
40
|
+
@profile = opts[:profile]
|
41
|
+
@title = opts[:title]
|
42
|
+
@hreflang = opts[:hreflang]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Halibut
|
2
|
+
|
3
|
+
class RelationMap
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@relations = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def add(relation, item)
|
10
|
+
@relations[relation] = [] unless @relations.has_key? relation
|
11
|
+
|
12
|
+
@relations[relation] << item
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](relation)
|
16
|
+
@relations[relation]
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?
|
20
|
+
@relations.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
a = @relations.each_with_object({}) do |pair, obj|
|
25
|
+
key, *value = pair.flatten
|
26
|
+
|
27
|
+
obj[key] = value.map &:to_hash
|
28
|
+
obj[key].length == 1 and obj[key] = obj[key].first
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'halibut/relation_map'
|
3
|
+
|
4
|
+
module Halibut
|
5
|
+
|
6
|
+
class Resource
|
7
|
+
attr_reader :properties, :links
|
8
|
+
|
9
|
+
def initialize(href=nil)
|
10
|
+
@links = RelationMap.new
|
11
|
+
@resources = RelationMap.new
|
12
|
+
@properties = {}
|
13
|
+
|
14
|
+
add_link('self', href) if href
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_property property, value
|
18
|
+
@properties[property] = value
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_property property
|
22
|
+
@properties[property]
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_link(relation, href, templated=nil, opts={})
|
26
|
+
@links.add relation, Halibut::Link.new(href, templated)
|
27
|
+
end
|
28
|
+
|
29
|
+
def embed_resource(relation, resource)
|
30
|
+
@resources.add relation, resource
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def embedded
|
35
|
+
@resources
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def as_json
|
40
|
+
json = {}
|
41
|
+
json = json.merge @properties
|
42
|
+
json['_links'] = {}.merge @links unless @links.empty?
|
43
|
+
json['_resources'] = {}.merge @resources unless @resources.empty?
|
44
|
+
|
45
|
+
json
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_json
|
49
|
+
JSON.dump as_json
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{ "_links": {
|
2
|
+
"self": { "href": "/orders" },
|
3
|
+
"next": { "href": "/orders?page=2" },
|
4
|
+
"find": { "href": "/orders{?id}", "templated": true }
|
5
|
+
},
|
6
|
+
"_embedded": {
|
7
|
+
"orders": [
|
8
|
+
{
|
9
|
+
"_links": {
|
10
|
+
"self": { "href": "/orders/123" },
|
11
|
+
"basket": { "href": "/baskets/98712" },
|
12
|
+
"customer": { "href": "/customers/7809" }
|
13
|
+
},
|
14
|
+
"total": 30.00,
|
15
|
+
"currency": "USD",
|
16
|
+
"status": "shipped"
|
17
|
+
},{
|
18
|
+
"_links": {
|
19
|
+
"self": { "href": "/orders/124" },
|
20
|
+
"basket": { "href": "/baskets/97213" },
|
21
|
+
"customer": { "href": "/customers/12369" }
|
22
|
+
},
|
23
|
+
"total": 20.00,
|
24
|
+
"currency": "USD",
|
25
|
+
"status": "processing"
|
26
|
+
}]
|
27
|
+
},
|
28
|
+
"currentlyProcessing": 14,
|
29
|
+
"shippedToday": 20
|
30
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<resource href="/orders">
|
2
|
+
<link rel="next" href="/orders?page=2" />
|
3
|
+
<link rel="find" href="/orders{?id}" templated="true" />
|
4
|
+
<resource rel="order" href="/orders/123">
|
5
|
+
<link rel="customer" href="/customers/7809" />
|
6
|
+
<link rel="basket" href="/baskets/98712">
|
7
|
+
<total>30.00</total>
|
8
|
+
<currency>USD</currency>
|
9
|
+
<status>shipped</status>
|
10
|
+
</resource>
|
11
|
+
<resource rel="order" href="/orders/124">
|
12
|
+
<link rel="customer" href="/customer/12369" />
|
13
|
+
<link rel="basket" href="/baskets/97213">
|
14
|
+
<total>20.00</total>
|
15
|
+
<currency>USD</currency>
|
16
|
+
<status>processing</status>
|
17
|
+
</resource>
|
18
|
+
</resource>
|
@@ -0,0 +1 @@
|
|
1
|
+
{ }
|
data/spec/link_spec.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Halibut::Link do
|
4
|
+
let(:normal_uri) { 'http://example.com' }
|
5
|
+
let(:tmpl_uri) { 'http://example.com/{id}' }
|
6
|
+
|
7
|
+
describe "href" do
|
8
|
+
it "accepts non-templated uri" do
|
9
|
+
link = Halibut::Link.new normal_uri
|
10
|
+
|
11
|
+
link.templated?.must_equal false
|
12
|
+
link.href.must_equal normal_uri
|
13
|
+
end
|
14
|
+
|
15
|
+
it "accepts templated uri" do
|
16
|
+
link = Halibut::Link.new tmpl_uri, true
|
17
|
+
|
18
|
+
link.templated?.must_equal true
|
19
|
+
link.href.must_equal tmpl_uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "optionals" do
|
24
|
+
it "are set correctly" do
|
25
|
+
link1 = Halibut::Link.new normal_uri, false, {
|
26
|
+
:type => 'type',
|
27
|
+
:name => 'name',
|
28
|
+
:profile => 'profile',
|
29
|
+
:title => 'title',
|
30
|
+
:hreflang => 'hreflang'
|
31
|
+
}
|
32
|
+
link2 = Halibut::Link.new normal_uri, false, {
|
33
|
+
:type => 'type',
|
34
|
+
:name => 'name',
|
35
|
+
:profile => 'profile',
|
36
|
+
:title => 'title',
|
37
|
+
:hreflang => 'hreflang'
|
38
|
+
}
|
39
|
+
|
40
|
+
link1.type.must_equal "type"
|
41
|
+
link1.name.must_equal "name"
|
42
|
+
link1.profile.must_equal "profile"
|
43
|
+
link1.title.must_equal "title"
|
44
|
+
link1.hreflang.must_equal "hreflang"
|
45
|
+
|
46
|
+
link2.type.must_equal "type"
|
47
|
+
link2.name.must_equal "name"
|
48
|
+
link2.profile.must_equal "profile"
|
49
|
+
link2.title.must_equal "title"
|
50
|
+
link2.hreflang.must_equal "hreflang"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Halibut::RelationMap do
|
4
|
+
subject { Halibut::RelationMap.new }
|
5
|
+
|
6
|
+
it "is empty" do
|
7
|
+
subject.must_be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has a single item per relation" do
|
11
|
+
subject.add 'first' , 'first'
|
12
|
+
subject.add 'second', 'second'
|
13
|
+
|
14
|
+
subject['first'].first.must_equal 'first'
|
15
|
+
subject['second'].first.must_equal 'second'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has various items per relation" do
|
19
|
+
subject.add 'first', 'first'
|
20
|
+
subject.add 'first', 'second'
|
21
|
+
|
22
|
+
subject['first'].length.must_equal 2
|
23
|
+
subject['first'].first.must_equal 'first'
|
24
|
+
subject['first'].last.must_equal 'second'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Halibut::Resource do
|
4
|
+
let(:templated_uri) { "http://example.com/{path}{?query}" }
|
5
|
+
let(:normal_uri) { "http://example.com" }
|
6
|
+
|
7
|
+
describe "Properties" do
|
8
|
+
subject { Halibut::Resource.new }
|
9
|
+
|
10
|
+
it "set property" do
|
11
|
+
subject.set_property "property", "value"
|
12
|
+
|
13
|
+
subject.properties['property'].must_equal "value"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "read property" do
|
17
|
+
subject.set_property "property", "value"
|
18
|
+
|
19
|
+
subject.get_property('property').must_equal "value"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Links" do
|
24
|
+
|
25
|
+
describe "self link" do
|
26
|
+
it "no default" do
|
27
|
+
resource = Halibut::Resource.new
|
28
|
+
resource.links.must_be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
it "default" do
|
32
|
+
resource = Halibut::Resource.new normal_uri
|
33
|
+
|
34
|
+
resource.links.wont_be_empty
|
35
|
+
resource.links['self'].first.href.must_equal normal_uri
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "Embedded resources" do
|
42
|
+
subject { Halibut::Resource.new }
|
43
|
+
let(:res1) { Halibut::Resource.new "http://first-resource.com" }
|
44
|
+
let(:res2) { Halibut::Resource.new "http://secnd-resource.com" }
|
45
|
+
|
46
|
+
it "no embedded resource" do
|
47
|
+
subject.embedded.must_be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has embedded resource" do
|
51
|
+
subject.embed_resource 'users', res1
|
52
|
+
subject.embed_resource 'users', res2
|
53
|
+
|
54
|
+
subject.embedded['users'].first.must_equal res1
|
55
|
+
subject.embedded['users'].last.must_equal res2
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "Serialize" do
|
60
|
+
subject { Halibut::Resource.new("http://example.com").to_json }
|
61
|
+
|
62
|
+
it "serializes to JSON" do
|
63
|
+
json = load_json "simple"
|
64
|
+
|
65
|
+
JSON.load(subject).must_equal JSON.load(json)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'pry'
|
6
|
+
require 'halibut'
|
7
|
+
|
8
|
+
# Testing helper to load JSON files. Returns a string containing JSON.
|
9
|
+
def load_json(filename)
|
10
|
+
File.read(File.dirname(__FILE__)+"/fixtures/#{filename}.json")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Testing Helper to load XML files. Returns a string containing XML.
|
14
|
+
def load_xml(filename)
|
15
|
+
File.read(File.dirname(__FILE__)+"/fixtures/xml/#{filename}.xml")
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: halibut
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ricardo Mendes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: uri_template
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pry
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: pry-full
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry-coolline
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
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
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: minitest
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: guard
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: guard-bundler
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: guard-minitest
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: terminal-notifier-guard
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
description: Toolkit to work with HAL
|
207
|
+
email:
|
208
|
+
- rokusu@gmail.com
|
209
|
+
executables: []
|
210
|
+
extensions: []
|
211
|
+
extra_rdoc_files: []
|
212
|
+
files:
|
213
|
+
- .gitignore
|
214
|
+
- .rvmrc
|
215
|
+
- Gemfile
|
216
|
+
- Guardfile
|
217
|
+
- LICENSE
|
218
|
+
- README.md
|
219
|
+
- Rakefile
|
220
|
+
- halibut.gemspec
|
221
|
+
- lib/halibut.rb
|
222
|
+
- lib/halibut/link.rb
|
223
|
+
- lib/halibut/relation_map.rb
|
224
|
+
- lib/halibut/resource.rb
|
225
|
+
- lib/halibut/version.rb
|
226
|
+
- spec/fixtures/example.json
|
227
|
+
- spec/fixtures/example.xml
|
228
|
+
- spec/fixtures/minimal.json
|
229
|
+
- spec/fixtures/simple.json
|
230
|
+
- spec/link_spec.rb
|
231
|
+
- spec/relation_map_spec.rb
|
232
|
+
- spec/resource_spec.rb
|
233
|
+
- spec/spec_helper.rb
|
234
|
+
homepage: http://locks.github.com/halibut
|
235
|
+
licenses: []
|
236
|
+
post_install_message:
|
237
|
+
rdoc_options: []
|
238
|
+
require_paths:
|
239
|
+
- lib
|
240
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ! '>='
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
246
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
|
+
none: false
|
248
|
+
requirements:
|
249
|
+
- - ! '>='
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
requirements: []
|
253
|
+
rubyforge_project:
|
254
|
+
rubygems_version: 1.8.24
|
255
|
+
signing_key:
|
256
|
+
specification_version: 3
|
257
|
+
summary: A HAL parser and builder for use in Hypermedia APIs
|
258
|
+
test_files:
|
259
|
+
- spec/fixtures/example.json
|
260
|
+
- spec/fixtures/example.xml
|
261
|
+
- spec/fixtures/minimal.json
|
262
|
+
- spec/fixtures/simple.json
|
263
|
+
- spec/link_spec.rb
|
264
|
+
- spec/relation_map_spec.rb
|
265
|
+
- spec/resource_spec.rb
|
266
|
+
- spec/spec_helper.rb
|
267
|
+
has_rdoc:
|