restfulie 0.8.0 → 0.8.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/Gemfile +10 -5
- data/Rakefile +5 -2
- data/lib/restfulie.rb +10 -5
- data/lib/restfulie/client.rb +13 -9
- data/lib/restfulie/client/base.rb +24 -65
- data/lib/restfulie/client/configuration.rb +62 -64
- data/lib/restfulie/client/entry_point.rb +36 -0
- data/lib/restfulie/client/ext/atom_ext.rb +12 -0
- data/lib/restfulie/client/ext/http_ext.rb +22 -0
- data/lib/restfulie/client/ext/json_ext.rb +12 -0
- data/lib/restfulie/client/ext/xml_ext.rb +4 -0
- data/lib/restfulie/client/http.rb +25 -13
- data/lib/restfulie/client/http/cache.rb +22 -22
- data/lib/restfulie/client/http/error.rb +70 -70
- data/lib/restfulie/client/http/link_request_builder.rb +15 -0
- data/lib/restfulie/client/http/request_adapter.rb +209 -0
- data/lib/restfulie/client/http/request_builder.rb +107 -0
- data/lib/restfulie/client/http/request_builder_executor.rb +24 -0
- data/lib/restfulie/client/http/request_executor.rb +17 -0
- data/lib/restfulie/client/http/request_follow.rb +42 -0
- data/lib/restfulie/client/http/request_follow_executor.rb +10 -0
- data/lib/restfulie/client/http/request_history.rb +69 -0
- data/lib/restfulie/client/http/request_history_executor.rb +10 -0
- data/lib/restfulie/client/http/request_marshaller.rb +127 -0
- data/lib/restfulie/client/http/request_marshaller_executor.rb +10 -0
- data/lib/restfulie/client/http/response.rb +23 -0
- data/lib/restfulie/client/http/response_handler.rb +67 -0
- data/lib/restfulie/client/http/response_holder.rb +9 -0
- data/lib/restfulie/client/mikyung.rb +17 -14
- data/lib/restfulie/client/mikyung/concatenator.rb +15 -12
- data/lib/restfulie/client/mikyung/core.rb +65 -39
- data/lib/restfulie/client/mikyung/languages.rb +8 -26
- data/lib/restfulie/client/mikyung/languages/german.rb +24 -0
- data/lib/restfulie/client/mikyung/languages/portuguese.rb +23 -0
- data/lib/restfulie/client/mikyung/rest_process_model.rb +184 -107
- data/lib/restfulie/client/mikyung/steady_state_walker.rb +34 -28
- data/lib/restfulie/client/mikyung/then_condition.rb +33 -27
- data/lib/restfulie/client/mikyung/when_condition.rb +53 -49
- data/lib/restfulie/common.rb +7 -12
- data/lib/restfulie/common/converter.rb +20 -9
- data/lib/restfulie/common/converter/atom.rb +8 -83
- data/lib/restfulie/common/converter/atom/base.rb +89 -0
- data/lib/restfulie/common/converter/atom/builder.rb +101 -99
- data/lib/restfulie/common/converter/atom/helpers.rb +16 -8
- data/lib/restfulie/common/converter/json.rb +12 -0
- data/lib/restfulie/common/converter/json/base.rb +84 -0
- data/lib/restfulie/common/converter/json/builder.rb +102 -0
- data/lib/restfulie/common/converter/json/helpers.rb +17 -0
- data/lib/restfulie/common/converter/values.rb +30 -26
- data/lib/restfulie/common/converter/xml.rb +14 -0
- data/lib/restfulie/common/converter/xml/base.rb +61 -0
- data/lib/restfulie/common/converter/xml/builder.rb +112 -0
- data/lib/restfulie/common/converter/xml/helpers.rb +17 -0
- data/lib/restfulie/common/converter/xml/link.rb +25 -0
- data/lib/restfulie/common/converter/xml/links.rb +25 -0
- data/lib/restfulie/common/core_ext.rb +1 -5
- data/lib/restfulie/common/core_ext/hash.rb +12 -0
- data/lib/restfulie/common/error.rb +19 -0
- data/lib/restfulie/common/logger.rb +17 -9
- data/lib/restfulie/common/representation.rb +9 -10
- data/lib/restfulie/common/representation/atom.rb +15 -47
- data/lib/restfulie/common/representation/atom/base.rb +122 -365
- data/lib/restfulie/common/representation/atom/category.rb +41 -0
- data/lib/restfulie/common/representation/atom/entry.rb +52 -100
- data/lib/restfulie/common/representation/atom/factory.rb +43 -0
- data/lib/restfulie/common/representation/atom/feed.rb +103 -99
- data/lib/restfulie/common/representation/atom/link.rb +68 -0
- data/lib/restfulie/common/representation/atom/person.rb +48 -0
- data/lib/restfulie/common/representation/atom/source.rb +59 -0
- data/lib/restfulie/common/representation/atom/tag_collection.rb +38 -0
- data/lib/restfulie/common/representation/atom/xml.rb +95 -0
- data/lib/restfulie/common/representation/generic.rb +30 -29
- data/lib/restfulie/common/representation/json.rb +10 -22
- data/lib/restfulie/common/representation/json/base.rb +27 -0
- data/lib/restfulie/common/representation/json/keys_as_methods.rb +72 -0
- data/lib/restfulie/common/representation/json/link.rb +29 -0
- data/lib/restfulie/common/representation/json/link_collection.rb +23 -0
- data/lib/restfulie/common/representation/xml.rb +18 -227
- data/lib/restfulie/server.rb +9 -10
- data/lib/restfulie/server/action_controller.rb +10 -12
- data/lib/restfulie/server/action_controller/base.rb +18 -15
- data/lib/restfulie/server/action_controller/{routing/patch.rb → patch.rb} +0 -0
- data/lib/restfulie/server/action_controller/restful_responder.rb +43 -35
- data/lib/restfulie/server/action_view.rb +8 -6
- data/lib/restfulie/server/action_view/helpers.rb +47 -41
- data/lib/restfulie/server/action_view/template_handlers.rb +24 -12
- data/lib/restfulie/server/action_view/template_handlers/tokamak.rb +17 -12
- data/lib/restfulie/server/configuration.rb +22 -19
- data/lib/restfulie/server/{restfulie_controller.rb → controller.rb} +1 -10
- data/lib/restfulie/server/core_ext.rb +1 -1
- data/lib/restfulie/version.rb +14 -0
- metadata +52 -16
- data/lib/restfulie/client/http/adapter.rb +0 -502
- data/lib/restfulie/client/http/atom_ext.rb +0 -4
- data/lib/restfulie/client/http/core_ext.rb +0 -6
- data/lib/restfulie/client/http/core_ext/http.rb +0 -19
- data/lib/restfulie/client/http/marshal.rb +0 -145
- data/lib/restfulie/client/http/xml_ext.rb +0 -7
- data/lib/restfulie/common/core_ext/proc.rb +0 -48
- data/lib/restfulie/common/errors.rb +0 -15
- data/lib/restfulie/server/action_controller/routing.rb +0 -12
- data/lib/restfulie/server/action_controller/routing/restful_route.rb +0 -14
@@ -0,0 +1,41 @@
|
|
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,107 +1,59 @@
|
|
1
|
-
module Restfulie
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def content=(value)
|
17
|
-
set_text("content", value)
|
18
|
-
end
|
19
|
-
|
20
|
-
#text
|
21
|
-
def summary
|
22
|
-
text("summary")
|
23
|
-
end
|
24
|
-
|
25
|
-
def summary=(value)
|
26
|
-
set_text("summary", value)
|
27
|
-
end
|
28
|
-
|
29
|
-
#rfc 3339
|
30
|
-
def published
|
31
|
-
value = text("published")
|
32
|
-
Time.parse(value) unless value.nil?
|
33
|
-
end
|
34
|
-
|
35
|
-
def published=(value)
|
36
|
-
set_text("published", value)
|
37
|
-
end
|
38
|
-
|
39
|
-
# comp: id, title, udpated, rights (optional)
|
40
|
-
def source
|
41
|
-
unless @source
|
42
|
-
@doc.xpath("xmlns:source").each do |source|
|
43
|
-
@source = Generator.new(source)
|
44
|
-
end
|
45
|
-
end
|
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
|
46
16
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
65
54
|
end
|
66
|
-
else
|
67
|
-
super(options_or_obj)
|
68
55
|
end
|
69
56
|
end
|
70
|
-
|
71
|
-
def id
|
72
|
-
text("id")
|
73
|
-
end
|
74
|
-
|
75
|
-
def id=(value)
|
76
|
-
set_text("id", value)
|
77
|
-
end
|
78
|
-
|
79
|
-
# text
|
80
|
-
def title
|
81
|
-
text("title")
|
82
|
-
end
|
83
|
-
|
84
|
-
def title=(value)
|
85
|
-
set_text("title", value)
|
86
|
-
end
|
87
|
-
|
88
|
-
def updated
|
89
|
-
value = text("updated")
|
90
|
-
Time.parse(value) unless value.nil?
|
91
|
-
end
|
92
|
-
|
93
|
-
def updated=(value)
|
94
|
-
set_text("updated", value)
|
95
|
-
end
|
96
|
-
|
97
|
-
# text
|
98
|
-
def rights
|
99
|
-
text("rights")
|
100
|
-
end
|
101
|
-
|
102
|
-
def rights=(value)
|
103
|
-
set_text("rights", value)
|
104
|
-
end
|
105
57
|
end
|
106
58
|
end
|
107
59
|
|
@@ -0,0 +1,43 @@
|
|
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,106 +1,110 @@
|
|
1
|
-
module Restfulie
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
19
43
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
44
|
+
def icon=(value)
|
45
|
+
set_text("icon", value)
|
46
|
+
end
|
47
|
+
|
48
|
+
# simple text
|
49
|
+
def logo
|
50
|
+
text("logo")
|
51
|
+
end
|
30
52
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
76
106
|
end
|
77
|
-
else
|
78
|
-
super(options_or_obj)
|
79
107
|
end
|
80
108
|
end
|
81
|
-
|
82
|
-
def content
|
83
|
-
@doc.content
|
84
|
-
end
|
85
|
-
|
86
|
-
def content=(value)
|
87
|
-
@doc.content = value
|
88
|
-
end
|
89
|
-
|
90
|
-
def uri
|
91
|
-
@doc["uri"]
|
92
|
-
end
|
93
|
-
|
94
|
-
def uri=(value)
|
95
|
-
@doc["uri"] = value
|
96
|
-
end
|
97
|
-
|
98
|
-
def version
|
99
|
-
@doc["version"]
|
100
|
-
end
|
101
|
-
|
102
|
-
def version=(value)
|
103
|
-
@doc["version"] = value
|
104
|
-
end
|
105
109
|
end
|
106
110
|
end
|