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 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
 
@@ -2,6 +2,8 @@ require 'xommelier/atom'
2
2
 
3
3
  module Xommelier
4
4
  module Atom
5
+ # Implements Feed Paging and Archiving
6
+ # See RFC 5005 {http://tools.ietf.org/html/rfc5005.html}
5
7
  module History
6
8
  include Xommelier::Xml
7
9
 
@@ -2,6 +2,8 @@ require 'xommelier/atom'
2
2
 
3
3
  module Xommelier
4
4
  module Atom
5
+ # Implments Atom Threading Extensions
6
+ # See RFC 4685 {http://tools.ietf.org/html/rfc4685.html}
5
7
  module Threading
6
8
  include Xommelier::Xml
7
9
 
@@ -1,6 +1,8 @@
1
1
  require 'xommelier/xml'
2
2
 
3
3
  module Xommelier
4
+ # Implements The Atom Syndication Format
5
+ # See RFC 4287 {http://tools.ietf.org/html/rfc4287.html}
4
6
  module Atom
5
7
  include Xommelier::Xml
6
8
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Xommelier
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'xommelier/xml'
2
+ require 'xommelier/xml/namespace'
2
3
 
3
4
  module Xommelier
4
5
  module Xml
@@ -1,4 +1,5 @@
1
1
  require 'xommelier/xml/element'
2
+ require 'active_support/concern'
2
3
  require 'active_support/core_ext/module/delegation'
3
4
  require 'active_support/core_ext/object/with_options'
4
5
  require 'active_support/core_ext/object/try'
@@ -1,4 +1,6 @@
1
1
  require 'xommelier/xml'
2
+ require 'xommelier/collection'
3
+ require 'xommelier/xml/element'
2
4
  require 'active_support/core_ext/array/extract_options'
3
5
 
4
6
  module Xommelier
data/lib/xommelier/xml.rb CHANGED
@@ -12,9 +12,6 @@ module Xommelier
12
12
  instance_variable_set :@_xmlns, nil
13
13
  end
14
14
 
15
- autoload :Namespace, 'xommelier/xml/namespace'
16
- autoload :Element, 'xommelier/xml/element'
17
-
18
15
  extend ClassMethods
19
16
  xmlns DEFAULT_NS, as: :xml
20
17
 
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'
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Xommelier do
4
- it { Xommelier::VERSION.should == '0.1.7' }
4
+ it { Xommelier::VERSION.should == '0.1.8' }
5
5
  end
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.7
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-10 00:00:00.000000000 Z
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: &70339564926600 !ruby/object:Gem::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: *70339564926600
24
+ version_requirements: *70191338259060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70339564925760 !ruby/object:Gem::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: *70339564925760
35
+ version_requirements: *70191338258000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activemodel
38
- requirement: &70339564940960 !ruby/object:Gem::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: *70339564940960
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