divoxx-patronage 0.0.4 → 0.0.5
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.rdoc +25 -3
- data/VERSION +1 -1
- data/lib/patronage/api.rb +2 -2
- data/lib/patronage/service.rb +5 -2
- data/patronage.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,13 +1,35 @@
|
|
1
|
-
=
|
1
|
+
= Patronage
|
2
2
|
|
3
|
-
|
3
|
+
Patronage is a small and generic library for accessing and interacting with web-services. It is
|
4
|
+
built on top of another Ruby library named Patron, which uses libcurl.
|
5
|
+
|
6
|
+
== Usage Example
|
7
|
+
|
8
|
+
Supposing there's an API in the address http://example.com/api and you want to perform a query to
|
9
|
+
/users.xml.
|
10
|
+
|
11
|
+
# Creates an API instance with a default parameter that should be sent in all requests
|
12
|
+
api = Patronage::API.new("http://example.com/api", :params => {:token => "79173109187231827312"})
|
13
|
+
|
14
|
+
# Will perform a GET request to http://example.com/api/users.xml?token=79173109187231827312&id=1
|
15
|
+
resp = api.service(:users, :format => 'xml').get(:id => "1")
|
16
|
+
|
17
|
+
# To access the response, already parsed.
|
18
|
+
resp.payload
|
19
|
+
|
20
|
+
# To access the raw response
|
21
|
+
resp.body
|
22
|
+
|
23
|
+
# Get the response status code
|
24
|
+
resp.status
|
4
25
|
|
5
26
|
== Note on Patches/Pull Requests
|
6
27
|
|
7
28
|
* Fork the project.
|
8
29
|
* Make your feature addition or bug fix.
|
9
30
|
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
10
|
-
* Commit, do not mess with rakefile, version, or history (if you want to have your own version,
|
31
|
+
* Commit, do not mess with rakefile, version, or history (if you want to have your own version,
|
32
|
+
that is fine but bump version in a commit by itself I can ignore when I pull).
|
11
33
|
* Send me a pull request. Bonus points for topic branches.
|
12
34
|
|
13
35
|
== Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/patronage/api.rb
CHANGED
data/lib/patronage/service.rb
CHANGED
@@ -2,13 +2,16 @@ module Patronage
|
|
2
2
|
class Service
|
3
3
|
attr_reader :name
|
4
4
|
|
5
|
-
def initialize(api, name)
|
5
|
+
def initialize(api, name, opts = {})
|
6
6
|
@api = api
|
7
7
|
@name = name.to_s
|
8
|
+
@opts = opts
|
8
9
|
end
|
9
10
|
|
10
11
|
def service_location
|
11
|
-
"/#{name}"
|
12
|
+
location = "/#{name}"
|
13
|
+
location << ".#{@opts[:format]}" if @opts[:format]
|
14
|
+
location
|
12
15
|
end
|
13
16
|
|
14
17
|
def get(params)
|
data/patronage.gemspec
CHANGED