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 CHANGED
@@ -1,13 +1,35 @@
1
- = patronage
1
+ = Patronage
2
2
 
3
- Description goes here.
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, that is fine but bump version in a commit by itself I can ignore when I pull).
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.4
1
+ 0.0.5
data/lib/patronage/api.rb CHANGED
@@ -18,8 +18,8 @@ module Patronage
18
18
  @session.get(url.to_s, headers)
19
19
  end
20
20
 
21
- def service(service_name)
22
- Service.new(self, service_name)
21
+ def service(service_name, opts = {})
22
+ Service.new(self, service_name, opts)
23
23
  end
24
24
  end
25
25
  end
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{patronage}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rodrigo Kochenburger"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divoxx-patronage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Kochenburger