hypermedia 1.0.6 → 1.0.7

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.
Files changed (3) hide show
  1. data/lib/api/api.rb +1 -0
  2. data/lib/api/document.rb +6 -2
  3. metadata +2 -2
data/lib/api/api.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  module HypermediaAPI
4
4
  BadURI = Class.new(Exception)
5
5
  MissingForm = Class.new(Exception)
6
+ MissingLink = Class.new(Exception)
6
7
 
7
8
  def HypermediaAPI.connection (uri)
8
9
  connection = Net::HTTP.new(uri.host, uri.port)
data/lib/api/document.rb CHANGED
@@ -8,13 +8,17 @@ class HypermediaAPI::Document
8
8
  klass.new_from_fields(article_element.element_children.filter('code'))
9
9
  end
10
10
 
11
+ def entity_with_attribute (klass, kv_pairs)
12
+ article_element = @document.at_css("article.#{klass.name.underscore}")
13
+ end
14
+
11
15
  def entities (klass)
12
16
  article_elements = @document.css("article.#{klass.name.underscore}")
13
17
  article_elements.map {|article_element| klass.new_from_fields(article_element.element_children.filter('code')) }
14
18
  end
15
19
 
16
20
  def form (css_selector)
17
- if form_element = @document.css(css_selector).first
21
+ if form_element = @document.at_css(css_selector)
18
22
  action_uri = form_element['action']
19
23
  http_method = form_element['method'].downcase
20
24
 
@@ -43,7 +47,7 @@ class HypermediaAPI::Document
43
47
  href_uri = a_element['href']
44
48
  Link.new(action_uri, http_method)
45
49
  else
46
- raise MissingForm, "The API does not have a link matching '#{css_selector}'."
50
+ raise MissingLink, "The API does not have a link matching '#{css_selector}'."
47
51
  end
48
52
  end
49
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypermedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport