restfulie 0.1.0.beta1 → 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/README.textile +87 -99
- data/Rakefile +14 -109
- data/lib/restfulie.rb +183 -23
- metadata +12 -197
- data/Gemfile +0 -28
- data/Gemfile.lock +0 -128
- data/LICENSE +0 -17
- data/lib/restfulie/client.rb +0 -26
- data/lib/restfulie/client/base.rb +0 -36
- data/lib/restfulie/client/cache.rb +0 -11
- data/lib/restfulie/client/cache/basic.rb +0 -76
- data/lib/restfulie/client/cache/fake.rb +0 -15
- data/lib/restfulie/client/cache/http_ext.rb +0 -123
- data/lib/restfulie/client/cache/restrictions.rb +0 -13
- data/lib/restfulie/client/configuration.rb +0 -67
- data/lib/restfulie/client/dsl.rb +0 -66
- data/lib/restfulie/client/entry_point.rb +0 -61
- data/lib/restfulie/client/ext/atom_ext.rb +0 -14
- data/lib/restfulie/client/ext/http_ext.rb +0 -22
- data/lib/restfulie/client/ext/json_ext.rb +0 -16
- data/lib/restfulie/client/feature.rb +0 -5
- data/lib/restfulie/client/feature/base.rb +0 -75
- data/lib/restfulie/client/feature/base_request.rb +0 -35
- data/lib/restfulie/client/feature/cache.rb +0 -16
- data/lib/restfulie/client/feature/enhance_response.rb +0 -12
- data/lib/restfulie/client/feature/follow_request.rb +0 -41
- data/lib/restfulie/client/feature/history.rb +0 -26
- data/lib/restfulie/client/feature/history_request.rb +0 -19
- data/lib/restfulie/client/feature/open_search.rb +0 -21
- data/lib/restfulie/client/feature/open_search/pattern_matcher.rb +0 -25
- data/lib/restfulie/client/feature/serialize_body.rb +0 -32
- data/lib/restfulie/client/feature/setup_header.rb +0 -22
- data/lib/restfulie/client/feature/throw_error.rb +0 -41
- data/lib/restfulie/client/feature/verb.rb +0 -119
- data/lib/restfulie/client/http.rb +0 -7
- data/lib/restfulie/client/http/cache.rb +0 -28
- data/lib/restfulie/client/http/error.rb +0 -77
- data/lib/restfulie/client/http/response_holder.rb +0 -29
- data/lib/restfulie/client/master_delegator.rb +0 -31
- data/lib/restfulie/client/mikyung.rb +0 -15
- data/lib/restfulie/client/mikyung/concatenator.rb +0 -18
- data/lib/restfulie/client/mikyung/core.rb +0 -70
- data/lib/restfulie/client/mikyung/languages.rb +0 -11
- data/lib/restfulie/client/mikyung/languages/german.rb +0 -24
- data/lib/restfulie/client/mikyung/languages/portuguese.rb +0 -23
- data/lib/restfulie/client/mikyung/rest_process_model.rb +0 -191
- data/lib/restfulie/client/mikyung/steady_state_walker.rb +0 -38
- data/lib/restfulie/client/mikyung/then_condition.rb +0 -39
- data/lib/restfulie/client/mikyung/when_condition.rb +0 -57
- data/lib/restfulie/common.rb +0 -18
- data/lib/restfulie/common/converter.rb +0 -43
- data/lib/restfulie/common/converter/atom.rb +0 -12
- data/lib/restfulie/common/converter/atom/base.rb +0 -91
- data/lib/restfulie/common/converter/atom/builder.rb +0 -111
- data/lib/restfulie/common/converter/atom/helpers.rb +0 -17
- data/lib/restfulie/common/converter/json.rb +0 -12
- data/lib/restfulie/common/converter/json/base.rb +0 -87
- data/lib/restfulie/common/converter/json/builder.rb +0 -102
- data/lib/restfulie/common/converter/json/helpers.rb +0 -17
- data/lib/restfulie/common/converter/open_search.rb +0 -16
- data/lib/restfulie/common/converter/open_search/descriptor.rb +0 -32
- data/lib/restfulie/common/converter/values.rb +0 -33
- data/lib/restfulie/common/converter/xml.rb +0 -14
- data/lib/restfulie/common/converter/xml/base.rb +0 -63
- data/lib/restfulie/common/converter/xml/builder.rb +0 -113
- data/lib/restfulie/common/converter/xml/helpers.rb +0 -17
- data/lib/restfulie/common/converter/xml/link.rb +0 -30
- data/lib/restfulie/common/converter/xml/links.rb +0 -21
- data/lib/restfulie/common/core_ext.rb +0 -1
- data/lib/restfulie/common/core_ext/hash.rb +0 -18
- data/lib/restfulie/common/error.rb +0 -19
- data/lib/restfulie/common/links.rb +0 -9
- data/lib/restfulie/common/logger.rb +0 -19
- data/lib/restfulie/common/representation.rb +0 -3
- data/lib/restfulie/common/representation/atom.rb +0 -20
- data/lib/restfulie/common/representation/atom/atom.rng +0 -597
- data/lib/restfulie/common/representation/atom/base.rb +0 -142
- data/lib/restfulie/common/representation/atom/category.rb +0 -41
- data/lib/restfulie/common/representation/atom/entry.rb +0 -59
- data/lib/restfulie/common/representation/atom/factory.rb +0 -43
- data/lib/restfulie/common/representation/atom/feed.rb +0 -110
- data/lib/restfulie/common/representation/atom/link.rb +0 -68
- data/lib/restfulie/common/representation/atom/person.rb +0 -48
- data/lib/restfulie/common/representation/atom/source.rb +0 -59
- data/lib/restfulie/common/representation/atom/tag_collection.rb +0 -38
- data/lib/restfulie/common/representation/atom/xml.rb +0 -90
- data/lib/restfulie/common/representation/generic.rb +0 -22
- data/lib/restfulie/common/representation/json.rb +0 -13
- data/lib/restfulie/common/representation/json/base.rb +0 -27
- data/lib/restfulie/common/representation/json/keys_as_methods.rb +0 -74
- data/lib/restfulie/common/representation/json/link.rb +0 -29
- data/lib/restfulie/common/representation/json/link_collection.rb +0 -23
- data/lib/restfulie/common/representation/links.rb +0 -11
- data/lib/restfulie/server.rb +0 -25
- data/lib/restfulie/server/action_controller.rb +0 -11
- data/lib/restfulie/server/action_controller/base.rb +0 -48
- data/lib/restfulie/server/action_controller/params_parser.rb +0 -100
- data/lib/restfulie/server/action_controller/patch.rb +0 -6
- data/lib/restfulie/server/action_controller/restful_responder.rb +0 -12
- data/lib/restfulie/server/action_controller/trait.rb +0 -9
- data/lib/restfulie/server/action_controller/trait/cacheable.rb +0 -81
- data/lib/restfulie/server/action_controller/trait/created.rb +0 -17
- data/lib/restfulie/server/action_view.rb +0 -10
- data/lib/restfulie/server/action_view/helpers.rb +0 -50
- data/lib/restfulie/server/action_view/template_handlers.rb +0 -30
- data/lib/restfulie/server/action_view/template_handlers/tokamak.rb +0 -21
- data/lib/restfulie/server/configuration.rb +0 -24
- data/lib/restfulie/server/controller.rb +0 -74
- data/lib/restfulie/server/core_ext.rb +0 -1
- data/lib/restfulie/server/core_ext/array.rb +0 -61
- data/lib/restfulie/version.rb +0 -14
@@ -1,142 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
class Base < XML
|
6
|
-
ATOM_ATTRIBUTES = {
|
7
|
-
:feed => {
|
8
|
-
:required => [:id, :title, :updated],
|
9
|
-
:recommended => [:author, :link],
|
10
|
-
:optional => [:category, :contributor, :rights, :generator, :icon, :logo, :subtitle]
|
11
|
-
},
|
12
|
-
|
13
|
-
:entry => {
|
14
|
-
:required => [:id, :title, :updated],
|
15
|
-
:recommended => [:author, :link, :content, :summary],
|
16
|
-
:optional => [:category, :contributor, :rights, :published, :source]
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
def initialize(xml_obj = nil)
|
21
|
-
@authors = nil
|
22
|
-
@contributors = nil
|
23
|
-
@links = nil
|
24
|
-
@categories = nil
|
25
|
-
@reserved = []
|
26
|
-
super(xml_obj)
|
27
|
-
end
|
28
|
-
|
29
|
-
# lists all extension points available in this entry
|
30
|
-
def extensions
|
31
|
-
result = []
|
32
|
-
@doc.children.each do |e|
|
33
|
-
if e.element?
|
34
|
-
result << e unless @reserved.map(&:to_s).include?(e.node_name)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
return result
|
38
|
-
end
|
39
|
-
|
40
|
-
# simpletext
|
41
|
-
def id
|
42
|
-
text("id")
|
43
|
-
end
|
44
|
-
|
45
|
-
def id=(value)
|
46
|
-
set_text("id", value)
|
47
|
-
end
|
48
|
-
|
49
|
-
# text
|
50
|
-
def title
|
51
|
-
text("title")
|
52
|
-
end
|
53
|
-
|
54
|
-
def title=(value)
|
55
|
-
set_text("title", value)
|
56
|
-
end
|
57
|
-
|
58
|
-
def updated
|
59
|
-
value = text("updated")
|
60
|
-
Time.parse(value) unless value.nil?
|
61
|
-
end
|
62
|
-
|
63
|
-
def updated=(value)
|
64
|
-
set_text("updated", value)
|
65
|
-
end
|
66
|
-
|
67
|
-
def published
|
68
|
-
value = text("published")
|
69
|
-
Time.parse(value) unless value.nil?
|
70
|
-
end
|
71
|
-
|
72
|
-
def published=(value)
|
73
|
-
set_text("published", value)
|
74
|
-
end
|
75
|
-
|
76
|
-
# text
|
77
|
-
def rights
|
78
|
-
text("rights")
|
79
|
-
end
|
80
|
-
|
81
|
-
def rights=(value)
|
82
|
-
set_text("rights", value)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Author have name, and optional uri and email, this describes a person
|
86
|
-
def authors
|
87
|
-
return @authors if @authors
|
88
|
-
|
89
|
-
@authors = TagCollection.new(@doc)
|
90
|
-
@doc.xpath("xmlns:author").each do |author|
|
91
|
-
@authors << Person.new("author", author)
|
92
|
-
end
|
93
|
-
@authors
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
def contributors
|
98
|
-
return @contributors if @contributors
|
99
|
-
|
100
|
-
@contributors = TagCollection.new(@doc)
|
101
|
-
@doc.xpath("xmlns:author").each do |contributor|
|
102
|
-
@contributors << Person.new("contributor", contributor)
|
103
|
-
end
|
104
|
-
@contributors
|
105
|
-
end
|
106
|
-
|
107
|
-
include Restfulie::Common::Links
|
108
|
-
|
109
|
-
# It has one required attribute, href, and five optional attributes: rel, type, hreflang, title, and length
|
110
|
-
def links
|
111
|
-
return @links if @links
|
112
|
-
|
113
|
-
@links = TagCollection.new(@doc) do |array, symbol, *args|
|
114
|
-
linkset = array.select {|link| link.rel == symbol.to_s }
|
115
|
-
unless linkset.empty?
|
116
|
-
linkset.size == 1 ? linkset.first : linkset
|
117
|
-
else
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
end
|
121
|
-
@doc.xpath("xmlns:link").each do |link|
|
122
|
-
@links << Link.new(link)
|
123
|
-
end
|
124
|
-
@links
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
def categories
|
129
|
-
return @categories if @categories
|
130
|
-
|
131
|
-
@categories = TagCollection.new(@doc)
|
132
|
-
@doc.xpath("xmlns:category").each do |category|
|
133
|
-
@categories << Link.new(category)
|
134
|
-
end
|
135
|
-
@categories
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
class Category < XML
|
6
|
-
def initialize(options_or_obj)
|
7
|
-
if options_or_obj.kind_of?(Hash)
|
8
|
-
@doc = Nokogiri::XML::Document.new()
|
9
|
-
options_or_obj = create_element("category", options_or_obj)
|
10
|
-
end
|
11
|
-
super(options_or_obj)
|
12
|
-
end
|
13
|
-
|
14
|
-
def term
|
15
|
-
@doc["term"]
|
16
|
-
end
|
17
|
-
|
18
|
-
def term=(value)
|
19
|
-
@doc["term"] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
def scheme
|
23
|
-
@doc["scheme"]
|
24
|
-
end
|
25
|
-
|
26
|
-
def scheme=(value)
|
27
|
-
@doc["scheme"] = value
|
28
|
-
end
|
29
|
-
|
30
|
-
def label
|
31
|
-
@doc["label"]
|
32
|
-
end
|
33
|
-
|
34
|
-
def label=(value)
|
35
|
-
@doc["label"] = value
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
class Entry < Base
|
6
|
-
def initialize(xml_obj = nil)
|
7
|
-
@source = nil
|
8
|
-
super(xml_obj)
|
9
|
-
@reserved = Base::ATOM_ATTRIBUTES[:entry][:required] + Base::ATOM_ATTRIBUTES[:entry][:recommended] + Base::ATOM_ATTRIBUTES[:entry][:optional]
|
10
|
-
end
|
11
|
-
|
12
|
-
# text
|
13
|
-
def content
|
14
|
-
text("content")
|
15
|
-
end
|
16
|
-
|
17
|
-
def content=(value)
|
18
|
-
set_text("content", value)
|
19
|
-
end
|
20
|
-
|
21
|
-
# text
|
22
|
-
def summary
|
23
|
-
text("summary")
|
24
|
-
end
|
25
|
-
|
26
|
-
def summary=(value)
|
27
|
-
set_text("summary", value)
|
28
|
-
end
|
29
|
-
|
30
|
-
# rfc 3339
|
31
|
-
def published
|
32
|
-
value = text("published")
|
33
|
-
Time.parse(value) unless value.nil?
|
34
|
-
end
|
35
|
-
|
36
|
-
def published=(value)
|
37
|
-
set_text("published", value)
|
38
|
-
end
|
39
|
-
|
40
|
-
# comp: id, title, udpated, rights (optional)
|
41
|
-
def source
|
42
|
-
unless @source
|
43
|
-
@doc.xpath("xmlns:source").each do |source|
|
44
|
-
@source = Generator.new(source)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
return source
|
49
|
-
end
|
50
|
-
|
51
|
-
def source=(obj)
|
52
|
-
@source = obj
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
# Create a new Representation::Atom object using a +string_or_io+
|
6
|
-
# object.
|
7
|
-
#
|
8
|
-
# Examples
|
9
|
-
# xml = IO.read("spec/units/lib/atoms/full_atom.xml")
|
10
|
-
# atom = Restfulie::Common::Representation::Atom.new(xml)
|
11
|
-
class Factory
|
12
|
-
# RelaxNG file to validate atom
|
13
|
-
RELAXNG_ATOM = File.join(File.dirname(__FILE__), 'atom.rng')
|
14
|
-
|
15
|
-
if Nokogiri::VERSION_INFO["libxml"]["loaded"] < "2.7.7"
|
16
|
-
puts "WARNING! In order to use schema validation on atom representations you need libxml version 2.7.7 or superior loaded in your system."
|
17
|
-
SCHEMA = nil
|
18
|
-
else
|
19
|
-
SCHEMA = ::Nokogiri::XML::RelaxNG(File.open(RELAXNG_ATOM))
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.create(string_or_io)
|
23
|
-
doc = string_or_io.kind_of?(Nokogiri::XML::Document) ? string_or_io : Nokogiri::XML(string_or_io)
|
24
|
-
|
25
|
-
if SCHEMA && !(errors = SCHEMA.validate(doc)).empty?
|
26
|
-
raise AtomInvalid.new("Invalid Atom: "+ errors.join(", "))
|
27
|
-
end
|
28
|
-
|
29
|
-
case doc.root.name
|
30
|
-
when "feed"
|
31
|
-
Restfulie::Common::Representation::Atom::Feed.new(doc)
|
32
|
-
when "entry"
|
33
|
-
Restfulie::Common::Representation::Atom::Entry.new(doc)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class AtomInvalid < StandardError
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
class Feed < Base
|
6
|
-
def initialize(xml_obj = nil)
|
7
|
-
@generator = nil
|
8
|
-
@entries = nil
|
9
|
-
super(xml_obj)
|
10
|
-
@reserved = Base::ATOM_ATTRIBUTES[:feed][:required] + Base::ATOM_ATTRIBUTES[:feed][:recommended] + Base::ATOM_ATTRIBUTES[:feed][:optional] + [:entry]
|
11
|
-
end
|
12
|
-
|
13
|
-
def entries
|
14
|
-
unless @entries
|
15
|
-
@entries = TagCollection.new(@doc)
|
16
|
-
@doc.xpath("xmlns:entry").each do |entry|
|
17
|
-
@entries << Entry.new(entry)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
return @entries
|
22
|
-
end
|
23
|
-
|
24
|
-
# comp: attr: uri, version (optionals); content (mandatory)
|
25
|
-
def generator
|
26
|
-
unless @generator
|
27
|
-
@doc.xpath("xmlns:generator").each do |generator|
|
28
|
-
@generator = Generator.new(generator)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
return generator
|
33
|
-
end
|
34
|
-
|
35
|
-
def generator=(obj)
|
36
|
-
@generator = obj
|
37
|
-
end
|
38
|
-
|
39
|
-
# simple text
|
40
|
-
def icon
|
41
|
-
text("icon")
|
42
|
-
end
|
43
|
-
|
44
|
-
def icon=(value)
|
45
|
-
set_text("icon", value)
|
46
|
-
end
|
47
|
-
|
48
|
-
# simple text
|
49
|
-
def logo
|
50
|
-
text("logo")
|
51
|
-
end
|
52
|
-
|
53
|
-
def logo=(value)
|
54
|
-
set_text("logo", value)
|
55
|
-
end
|
56
|
-
|
57
|
-
# text
|
58
|
-
def subtitle
|
59
|
-
text("subtitle")
|
60
|
-
end
|
61
|
-
|
62
|
-
def subtitle=(value)
|
63
|
-
set_text("subtitle", value)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class Generator < XML
|
68
|
-
def initialize(options_or_obj)
|
69
|
-
if options_or_obj.kind_of?(Hash)
|
70
|
-
@doc = Nokogiri::XML::Document.new()
|
71
|
-
node = @doc.create_element("generator")
|
72
|
-
node.add_namespace_definition(nil, "http://www.w3.org/2005/Atom")
|
73
|
-
node.parent = @doc
|
74
|
-
super(node)
|
75
|
-
options_or_obj.each do |key,value|
|
76
|
-
self.send("#{key}=".to_sym, value)
|
77
|
-
end
|
78
|
-
else
|
79
|
-
super(options_or_obj)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def content
|
84
|
-
@doc.content
|
85
|
-
end
|
86
|
-
|
87
|
-
def content=(value)
|
88
|
-
@doc.content = value
|
89
|
-
end
|
90
|
-
|
91
|
-
def uri
|
92
|
-
@doc["uri"]
|
93
|
-
end
|
94
|
-
|
95
|
-
def uri=(value)
|
96
|
-
@doc["uri"] = value
|
97
|
-
end
|
98
|
-
|
99
|
-
def version
|
100
|
-
@doc["version"]
|
101
|
-
end
|
102
|
-
|
103
|
-
def version=(value)
|
104
|
-
@doc["version"] = value
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module Restfulie
|
2
|
-
module Common
|
3
|
-
module Representation
|
4
|
-
module Atom
|
5
|
-
class Link < XML
|
6
|
-
def initialize(options_or_obj)
|
7
|
-
if options_or_obj.kind_of?(Hash)
|
8
|
-
@doc = Nokogiri::XML::Document.new()
|
9
|
-
options_or_obj = create_element("link", options_or_obj)
|
10
|
-
end
|
11
|
-
super(options_or_obj)
|
12
|
-
end
|
13
|
-
|
14
|
-
def href
|
15
|
-
@doc["href"]
|
16
|
-
end
|
17
|
-
|
18
|
-
def href=(value)
|
19
|
-
@doc["href"] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
def rel
|
23
|
-
@doc["rel"]
|
24
|
-
end
|
25
|
-
|
26
|
-
def rel=(value)
|
27
|
-
@doc["rel"] = value
|
28
|
-
end
|
29
|
-
|
30
|
-
if method_defined?(:type)
|
31
|
-
alias_method :__type__, :type
|
32
|
-
end
|
33
|
-
def type
|
34
|
-
@doc["type"]
|
35
|
-
end
|
36
|
-
|
37
|
-
def type=(value)
|
38
|
-
@doc["type"] = value
|
39
|
-
end
|
40
|
-
|
41
|
-
def hreflang
|
42
|
-
@doc["hreflang"]
|
43
|
-
end
|
44
|
-
|
45
|
-
def hreflang=(value)
|
46
|
-
@doc["hreflang"] = value
|
47
|
-
end
|
48
|
-
|
49
|
-
def title
|
50
|
-
@doc["title"]
|
51
|
-
end
|
52
|
-
|
53
|
-
def title=(value)
|
54
|
-
@doc["title"] = value
|
55
|
-
end
|
56
|
-
|
57
|
-
def length
|
58
|
-
@doc["length"]
|
59
|
-
end
|
60
|
-
|
61
|
-
def length=(value)
|
62
|
-
@doc["length"] = value
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|