xommelier 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/lib/xommelier/atom/history.rb +2 -0
- data/lib/xommelier/atom/threading.rb +2 -0
- data/lib/xommelier/atom.rb +2 -0
- data/lib/xommelier/open_search.rb +103 -0
- data/lib/xommelier/version.rb +1 -1
- data/lib/xommelier/xml/class_methods.rb +1 -0
- data/lib/xommelier/xml/element/structure.rb +1 -0
- data/lib/xommelier/xml/namespace.rb +2 -0
- data/lib/xommelier/xml.rb +0 -3
- data/lib/xommelier.rb +3 -3
- data/spec/lib/xommelier_spec.rb +1 -1
- metadata +9 -8
data/README.md
CHANGED
@@ -173,6 +173,12 @@ will output
|
|
173
173
|
</feed>
|
174
174
|
```
|
175
175
|
|
176
|
+
## Built in XML namespaces:
|
177
|
+
|
178
|
+
1. {Xommelier::Atom} - http://www.w3.org/2005/Atom
|
179
|
+
2. {Xommelier::Atom::Threading} - http://purl.org/syndication/thread/1.0
|
180
|
+
3. {Xommelier::Atom::History} - http://purl.org/syndication/history/1.0
|
181
|
+
4. {Xommelier::OpenSearch} - http://a9.com/-/spec/opensearch/1.1/
|
176
182
|
|
177
183
|
## TODO
|
178
184
|
|
data/lib/xommelier/atom.rb
CHANGED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'xommelier'
|
2
|
+
|
3
|
+
module Xommelier
|
4
|
+
# Implements http://www.opensearch.org/Specifications/OpenSearch/1.1#Url_rel_values
|
5
|
+
module OpenSearch
|
6
|
+
MIME_TYPE = 'application/opensearchdescription+xml'
|
7
|
+
|
8
|
+
include Xml
|
9
|
+
|
10
|
+
xmlns 'http://a9.com/-/spec/opensearch/1.1/', as: :opensearch
|
11
|
+
|
12
|
+
class Url < Xml::Element
|
13
|
+
element_name :Url
|
14
|
+
|
15
|
+
attribute :template
|
16
|
+
attribute :type
|
17
|
+
|
18
|
+
may do
|
19
|
+
attribute :rel, default: 'results' # may be results, suggestions, self, collection
|
20
|
+
attribute :index_offset, type: Integer, default: 1
|
21
|
+
attribute :page_offset, type: Integer, default: 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Image < Xml::Element
|
26
|
+
element_name :Image
|
27
|
+
|
28
|
+
may do
|
29
|
+
attribute :height, type: Integer
|
30
|
+
attribute :width, type: Integer
|
31
|
+
attribute :type
|
32
|
+
end
|
33
|
+
|
34
|
+
text type: Uri
|
35
|
+
end
|
36
|
+
|
37
|
+
class Query < Xml::Element
|
38
|
+
element_name :Query
|
39
|
+
|
40
|
+
element :role#, type: Enum[:request, :example, :related, :correction, :subset, :superset]
|
41
|
+
|
42
|
+
may do
|
43
|
+
element :title
|
44
|
+
element :total_results, type: Integer, as: 'totalResults'
|
45
|
+
element :search_terms, as: 'searchTerms', default: 'Xommelier'
|
46
|
+
element :count, type: Integer
|
47
|
+
element :start_index, type: Boolean, as: 'startIndex'
|
48
|
+
element :start_page, type: Boolean, as: 'startPage'
|
49
|
+
element :language
|
50
|
+
element :input_encoding, as: 'inputEncoding'
|
51
|
+
element :output_encoding, as: 'outputEncoding'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Description < Xml::Element
|
56
|
+
element_name :OpenSearchDescription
|
57
|
+
|
58
|
+
element :short_name, as: :ShortName
|
59
|
+
element :description, as: :Description
|
60
|
+
|
61
|
+
many do
|
62
|
+
element :url, type: Url, as: Url.element_name
|
63
|
+
end
|
64
|
+
|
65
|
+
may do
|
66
|
+
element :tags, as: :Tags
|
67
|
+
element :contacts, as: :Contacts
|
68
|
+
element :long_name, as: :LongName
|
69
|
+
element :developer, as: :Developer
|
70
|
+
element :attribution, as: :Attribution
|
71
|
+
element :syndication_right, type: Symbol, as: :SyndicatioeRight, default: :open #, type: Enum[:open, :limited, :private, :closed]
|
72
|
+
element :adult_content, type: Boolean, as: :AdultContent
|
73
|
+
element :language, as: :Language, default: '*'
|
74
|
+
element :input_encoding, as: :InputEncoding, default: 'UTF-8'
|
75
|
+
element :output_encoding, as: :OutputEncoding, default: 'UTF-8'
|
76
|
+
end
|
77
|
+
|
78
|
+
any do
|
79
|
+
element :image, type: Image, as: Image.element_name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if defined?(Atom)
|
85
|
+
module Atom
|
86
|
+
class Feed
|
87
|
+
may do
|
88
|
+
element :totalResults, type: Integer, ns: OpenSearch.xmlns
|
89
|
+
element :startIndex, type: Integer, ns: OpenSearch.xmlns
|
90
|
+
element :itemsPerPage, type: Integer, ns: OpenSearch.xmlns
|
91
|
+
end
|
92
|
+
|
93
|
+
any do
|
94
|
+
element :query, type: OpenSearch::Query, as: OpenSearch::Query.element_name
|
95
|
+
end
|
96
|
+
|
97
|
+
def search_url
|
98
|
+
links.find { |link| link.rel == 'search' && link.type == MIME_TYPE }.try(:href)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/xommelier/version.rb
CHANGED
data/lib/xommelier/xml.rb
CHANGED
data/lib/xommelier.rb
CHANGED
@@ -2,8 +2,8 @@ require 'xommelier/version'
|
|
2
2
|
require 'xommelier/core_ext'
|
3
3
|
|
4
4
|
module Xommelier
|
5
|
-
autoload :Collection, 'xommelier/collection'
|
6
|
-
|
7
|
-
autoload :Xml, 'xommelier/xml'
|
8
5
|
autoload :Atom, 'xommelier/atom'
|
6
|
+
autoload :OpenSearch, 'xommelier/open_search'
|
9
7
|
end
|
8
|
+
|
9
|
+
require 'xommelier/xml'
|
data/spec/lib/xommelier_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xommelier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70191338259060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.5.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70191338259060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70191338258000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.2.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70191338258000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activemodel
|
38
|
-
requirement: &
|
38
|
+
requirement: &70191338257020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 3.2.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70191338257020
|
47
47
|
description: XML-Object Mapper with many built-in XML formats supported
|
48
48
|
email:
|
49
49
|
- al@semyonov.us
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/xommelier/core_ext/symbol.rb
|
87
87
|
- lib/xommelier/core_ext/time.rb
|
88
88
|
- lib/xommelier/core_ext/uri.rb
|
89
|
+
- lib/xommelier/open_search.rb
|
89
90
|
- lib/xommelier/version.rb
|
90
91
|
- lib/xommelier/xml.rb
|
91
92
|
- lib/xommelier/xml/class_methods.rb
|