hypermedia 1.0.5 → 1.0.6
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/lib/api/document.rb +15 -8
- metadata +2 -2
data/lib/api/document.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
class HypermediaAPI::Document
|
4
4
|
def entity (klass)
|
5
|
-
|
6
|
-
return nil unless
|
5
|
+
article_element = @document.at_css("article.#{klass.name.underscore}")
|
6
|
+
return nil unless article_element
|
7
7
|
|
8
|
-
klass.new_from_fields(
|
8
|
+
klass.new_from_fields(article_element.element_children.filter('code'))
|
9
9
|
end
|
10
10
|
|
11
11
|
def entities (klass)
|
12
|
-
|
13
|
-
|
12
|
+
article_elements = @document.css("article.#{klass.name.underscore}")
|
13
|
+
article_elements.map {|article_element| klass.new_from_fields(article_element.element_children.filter('code')) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def form (css_selector)
|
@@ -39,11 +39,18 @@ class HypermediaAPI::Document
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def link (css_selector)
|
42
|
-
if a_element = @document.
|
43
|
-
href_uri =
|
42
|
+
if a_element = @document.at_css(css_selector)
|
43
|
+
href_uri = a_element['href']
|
44
44
|
Link.new(action_uri, http_method)
|
45
45
|
else
|
46
|
-
raise MissingForm, "The API does not have a
|
46
|
+
raise MissingForm, "The API does not have a link matching '#{css_selector}'."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def links (css_selector)
|
51
|
+
@document.css(css_selector).map do |a_element|
|
52
|
+
href_uri = a_element['href']
|
53
|
+
Link.new(action_uri, http_method)
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
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.
|
4
|
+
version: 1.0.6
|
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-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|