rapidash 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ce1818f4254102ef82a678267950073b326c929
4
- data.tar.gz: 3d34ef35a0d0880eb8cd7b271ecfb334626082f3
3
+ metadata.gz: dc6b0e6636bacbfbc9b0294b808b87e69d8ed6d9
4
+ data.tar.gz: 58ff477a1fd01590ed8deb47647e9be8c0212ff5
5
5
  SHA512:
6
- metadata.gz: 1bb35f3c4f249141ae9bfe3568d6378cb164e41cfecce8bdc1c6a67338a0938bd46e7c096fc72a0f848bdf3eca4f8dcf9c5034232f45f9304ce970c5ac5b3543
7
- data.tar.gz: 23be2377818a96d182531e424aff5cad7a7b2df8248a0d7ae4a404a6bb59fd31a97202eb6bb9ea8f1c853238b980f39ab51d33ef5664f83047294d58fd150252
6
+ metadata.gz: 715b0e98003340a217a1d0d3b673a7f0b5d96e4dbbe45b0f26e718d949a5777c5ae16b392573df2f005fa36e69f2dfa1347c5c9e320827ad957ab177ebb438e7
7
+ data.tar.gz: 470f35e9d9234fd207d1a002875957f453c8fd55541a3c2ecd86a91124fca19dd48d890e3b7f3fe2cac1ec56db000783d7169d4db0768eadec61aa6eb4dd1edc
data/lib/rapidash/base.rb CHANGED
@@ -26,7 +26,7 @@ module Rapidash
26
26
  end
27
27
 
28
28
  def update!(params)
29
- self.options[:method] = :put
29
+ self.options[:method] = client.class.patch ? :patch : :put
30
30
  self.options[:body] = params.to_json
31
31
  call!
32
32
  end
@@ -19,6 +19,10 @@ module Rapidash
19
19
  request(:put, url, options)
20
20
  end
21
21
 
22
+ def patch(url, options = {})
23
+ request(:patch, url, options)
24
+ end
25
+
22
26
  def delete(url, options = {})
23
27
  request(:delete, url, options)
24
28
  end
@@ -7,6 +7,8 @@ module Rapidash
7
7
 
8
8
  module ClassMethods
9
9
 
10
+ attr_accessor :patch
11
+
10
12
  def method(method)
11
13
  case method
12
14
  when :http then include HTTPClient
@@ -16,6 +18,10 @@ module Rapidash
16
18
  raise ConfigurationError.new "Invalid API Authentication Method"
17
19
  end
18
20
  end
21
+
22
+ def use_patch
23
+ @patch = true
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -7,12 +7,10 @@ module Rapidash
7
7
 
8
8
  module ClassMethods
9
9
  def url(url)
10
- self.class_eval do
11
- define_method(:initialize) do |*args|
12
- super(*args)
13
- @url = "#{base_url}#{url.to_s}"
14
- @url += "/#{@id}" if @id
15
- end
10
+ define_method(:initialize) do |*args|
11
+ super(*args)
12
+ @url = "#{base_url}#{url.to_s}"
13
+ @url += "/#{@id}" if @id
16
14
  end
17
15
  end
18
16
  end
@@ -1,3 +1,3 @@
1
1
  module Rapidash
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/rapidash.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["gazler@gmail.com"]
11
11
  spec.description = %q{Evolve your API}
12
12
  spec.summary = %q{An opinionated core for creating clients for RESTful APIs quickly}
13
- spec.homepage = ""
13
+ spec.homepage = "http://github.com/Gazler/rapidash"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -10,6 +10,12 @@ end
10
10
  class Rapidash::Resource < Rapidash::Base
11
11
  end
12
12
 
13
+ class BaseTesterClient
14
+ class << self
15
+ attr_accessor :patch
16
+ end
17
+ end
18
+
13
19
 
14
20
  describe Rapidash::Base do
15
21
 
@@ -28,7 +34,7 @@ describe Rapidash::Base do
28
34
  end
29
35
  end
30
36
 
31
- let(:client) { mock }
37
+ let(:client) { BaseTesterClient.new }
32
38
  let(:headers) { {"content-type" => "application/json"} }
33
39
  let(:subject) { BaseTester.new(client) }
34
40
 
@@ -60,6 +66,16 @@ describe Rapidash::Base do
60
66
  :body => post.to_json
61
67
  })
62
68
  end
69
+
70
+ it "should use the patch verb if set on the client" do
71
+ client.class.patch = true
72
+ subject.should_receive(:call!)
73
+ subject.update!(post)
74
+ subject.instance_variable_get(:@options).should eql({
75
+ :method => :patch,
76
+ :body => post.to_json
77
+ })
78
+ end
63
79
  end
64
80
 
65
81
  describe ".delete!" do
@@ -35,6 +35,12 @@ describe Rapidash::Client do
35
35
  end
36
36
  end
37
37
 
38
+ describe ".patch" do
39
+ it "should call request" do
40
+ subject.should_receive(:request).with(:patch, "foo", {})
41
+ subject.patch("foo")
42
+ end
43
+ end
38
44
 
39
45
  describe ".delete" do
40
46
  it "should call request" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapidash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary 'Gazler' Rennie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-09 00:00:00.000000000 Z
11
+ date: 2013-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,7 +146,7 @@ files:
146
146
  - spec/rapidash/test_client_spec.rb
147
147
  - spec/rapidash/urlable_spec.rb
148
148
  - spec/spec_helper.rb
149
- homepage: ''
149
+ homepage: http://github.com/Gazler/rapidash
150
150
  licenses:
151
151
  - MIT
152
152
  metadata: {}