rest_api 0.1.2.1 → 0.1.3.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/lib/rest_api.rb CHANGED
@@ -24,6 +24,22 @@ module RestApi
24
24
  self.api.url = value + "/"
25
25
  end
26
26
  end
27
+
28
+ def self.api_key_name
29
+ self.api.api_key_name
30
+ end
31
+
32
+ def self.api_key_name=(value)
33
+ self.api.api_key_name = value
34
+ end
35
+
36
+ def self.api_key_value
37
+ self.api.api_key_value
38
+ end
39
+
40
+ def self.api_key_value=(value)
41
+ self.api.api_key_value = value
42
+ end
27
43
 
28
44
  # api reference
29
45
  def self.api
data/lib/rest_api/api.rb CHANGED
@@ -15,5 +15,23 @@ module RestApi
15
15
  @@url = value + "/"
16
16
  end
17
17
  end
18
+
19
+ def self.api_key_name
20
+ @@api_key_name = "" unless defined?(@@api_key_name)
21
+ @@api_key_name
22
+ end
23
+
24
+ def self.api_key_name=(value)
25
+ @@api_key_name=value
26
+ end
27
+
28
+ def self.api_key_value
29
+ @@api_key_value = "" unless defined?(@@api_key_value)
30
+ @@api_key_value
31
+ end
32
+
33
+ def self.api_key_value=(value)
34
+ @@api_key_value=value
35
+ end
18
36
  end
19
37
  end
@@ -11,6 +11,11 @@ module RestApi
11
11
 
12
12
  def self.make_request(request_type, request_url, request_params = nil)
13
13
  request_params ||= {}
14
+
15
+ if RestApi.api_key_name != ""
16
+ request_params.merge!({RestApi.api_key_name.to_sym => RestApi.api_key_value,})
17
+ end
18
+
14
19
  begin
15
20
  case request_type
16
21
  when :put
@@ -1,3 +1,3 @@
1
1
  module RestApi
2
- VERSION = "0.1.2.1"
2
+ VERSION = "0.1.3.1"
3
3
  end
data/rest_api.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["Codus Tecnologia"]
6
6
  gem.email = ["vinicius.oyama@codus.com.br"]
7
7
  gem.platform = Gem::Platform::RUBY
8
- gem.description = %q{An easy to use, no configuration REST API client!}
9
- gem.summary = %q{An easy to use, no configuration REST API client!}
8
+ gem.description = %q{An easy to use, no configuration API client!}
9
+ gem.summary = %q{An easy to use, no configuration API client!}
10
10
  gem.homepage = "https://github.com/codus/rest_api"
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
@@ -57,6 +57,14 @@ describe "RestApi::request_hander" do
57
57
  RestApi::RequestHandler::Client.should_receive(:delete).with("http://www.fakeurl.com.br/test/5", {})
58
58
  RestApi::RequestHandler.make_request :delete, "http://www.fakeurl.com.br/test/5"
59
59
  end
60
+
61
+ it "should call client get with api_url" do
62
+ RestApi.api_key_name = "key_name"
63
+ RestApi.api_key_value = "key_value"
64
+
65
+ RestApi::RequestHandler::Client.should_receive(:get).with("http://www.fakeurl.com.br/test", {:key_name => "key_value"})
66
+ RestApi::RequestHandler.make_request :get, "http://www.fakeurl.com.br/test"
67
+ end
60
68
  end
61
69
 
62
70
  describe "method_missing" do
@@ -17,6 +17,19 @@ describe "RestApi" do
17
17
  RestApi.instance_eval { api_url }.should be == "http://www.localhost.com:4000/"
18
18
  end
19
19
 
20
+ it "should configure api_key_name" do
21
+ RestApi.setup do |config|
22
+ config.api_key_name = "api_key_name"
23
+ end
24
+ RestApi.instance_eval { api_key_name }.should be == "api_key_name"
25
+ end
26
+
27
+ it "should configure api_key_value" do
28
+ RestApi.setup do |config|
29
+ config.api_key_value = "api_key_value"
30
+ end
31
+ RestApi.instance_eval { api_key_value }.should be == "api_key_value"
32
+ end
20
33
 
21
34
  it "should configure api_url - whithout slash" do
22
35
  RestApi.setup do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.1
4
+ version: 0.1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-26 00:00:00.000000000 Z
12
+ date: 2012-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.6'
62
- description: An easy to use, no configuration REST API client!
62
+ description: An easy to use, no configuration API client!
63
63
  email:
64
64
  - vinicius.oyama@codus.com.br
65
65
  executables: []
@@ -112,7 +112,7 @@ rubyforge_project:
112
112
  rubygems_version: 1.8.24
113
113
  signing_key:
114
114
  specification_version: 3
115
- summary: An easy to use, no configuration REST API client!
115
+ summary: An easy to use, no configuration API client!
116
116
  test_files:
117
117
  - spec/rest_api/api/request_parser_spec.rb
118
118
  - spec/rest_api/api_spec.rb