nap 0.5.1 → 0.6.0

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/lib/rest.rb +23 -7
  4. data/lib/rest/request.rb +6 -3
  5. metadata +49 -80
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f7dc30c90be3d31f7cee006082d494ac5624471
4
+ data.tar.gz: 5e59d78e97e2bce1b2dd89c45d248d62583b6dd5
5
+ SHA512:
6
+ metadata.gz: 56226f0615470f7d34eadd68cee959259d93d97f1514f1545990a432bde9e6a66cb206bd70794409316c13676aee4d85eb4a5f5c49521e7aacd0670533bdfa40
7
+ data.tar.gz: 65780d4dc852035efd5271264994027d7812a3617d8c460dc2fa340ccc8b079df4d18bbe7e759fd7db9f088f3fc520b57c614e37b1841d4927434346b8dc8b59
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Manfred Stienstra, Fingertips <manfred@fngtps.com>
1
+ Copyright (c) 2013 Manfred Stienstra, Fingertips <manfred@fngtps.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
@@ -6,7 +6,7 @@ module REST
6
6
  # Raised when the remote server disconnects when reading the response
7
7
  class DisconnectedError < StandardError; end
8
8
 
9
- # Performs a HEAD on a resource. See REST::Request.new for a complete discussion of options.
9
+ # Performs a GET on a resource. See REST::Request.new for a complete discussion of options.
10
10
  #
11
11
  # response = REST.get('http://example.com/pigeons/12',
12
12
  # {'Accept' => 'text/plain'},
@@ -30,7 +30,7 @@ module REST
30
30
  # puts "Someone moved your pigeon!"
31
31
  # else
32
32
  # puts "Couldn't fetch your pigeon (#{response.status_code})"
33
- # end
33
+ # end
34
34
  def self.head(uri, headers={}, options={})
35
35
  REST::Request.perform(:head, URI.parse(uri), nil, headers, options)
36
36
  end
@@ -44,14 +44,14 @@ module REST
44
44
  # puts "Someone moved your pigeon!"
45
45
  # else
46
46
  # puts "Couldn't delete your pigeon (#{response.status_code})"
47
- # end
47
+ # end
48
48
  def self.delete(uri, headers={}, options={})
49
49
  REST::Request.perform(:delete, URI.parse(uri), nil, headers, options)
50
50
  end
51
51
 
52
- # Performs a PUT on a resource. See REST::Request.new for a complete discussion of options.
52
+ # Performs a PATCH on a resource. See REST::Request.new for a complete discussion of options.
53
53
  #
54
- # response = REST.put('http://example.com/pigeons/12',
54
+ # response = REST.patch('http://example.com/pigeons/12',
55
55
  # {'Name' => 'Homer'}.to_xml,
56
56
  # {'Accept' => 'application/xml, */*', 'Content-Type' => 'application/xml'}
57
57
  # )
@@ -60,7 +60,23 @@ module REST
60
60
  # else
61
61
  # puts "Couldn't rename your pigeon (#{response.status_code})"
62
62
  # puts XML.parse(response.body).reason
63
- # end
63
+ # end
64
+ def self.patch(uri, body, headers={}, options={})
65
+ REST::Request.perform(:patch, URI.parse(uri), body, headers, options)
66
+ end
67
+
68
+ # Performs a PUT on a resource. See REST::Request.new for a complete discussion of options.
69
+ #
70
+ # response = REST.put('http://example.com/pigeons/12',
71
+ # {'Name' => 'Homer'}.to_xml,
72
+ # {'Accept' => 'application/xml, */*', 'Content-Type' => 'application/xml'}
73
+ # )
74
+ # if response.ok?
75
+ # puts "Your pigeon 'Bowser' was replaced by 'Homer'!"
76
+ # else
77
+ # puts "Couldn't replace your pigeon (#{response.status_code})"
78
+ # puts XML.parse(response.body).reason
79
+ # end
64
80
  def self.put(uri, body, headers={}, options={})
65
81
  REST::Request.perform(:put, URI.parse(uri), body, headers, options)
66
82
  end
@@ -83,4 +99,4 @@ module REST
83
99
  end
84
100
 
85
101
  require File.expand_path('../rest/request', __FILE__)
86
- require File.expand_path('../rest/response', __FILE__)
102
+ require File.expand_path('../rest/response', __FILE__)
@@ -6,7 +6,7 @@ module REST
6
6
  class Request
7
7
  attr_accessor :verb, :url, :body, :headers, :options, :request
8
8
 
9
- # * <tt>verb</tt>: The verb to use in the request, either :get, :head, :put, or :post
9
+ # * <tt>verb</tt>: The verb to use in the request, either :get, :head, :patch, :put, or :post
10
10
  # * <tt>url</tt>: The URL to send the request to, must be a URI instance
11
11
  # * <tt>body</tt>: The body to use in the request
12
12
  # * <tt>headers</tt>: A hash of headers to add to the request
@@ -107,6 +107,9 @@ module REST
107
107
  self.request = Net::HTTP::Head.new(path, headers)
108
108
  when :delete
109
109
  self.request = Net::HTTP::Delete.new(path, headers)
110
+ when :patch
111
+ self.request = Net::HTTP::Patch.new(path, headers)
112
+ self.request.body = body
110
113
  when :put
111
114
  self.request = Net::HTTP::Put.new(path, headers)
112
115
  self.request.body = body
@@ -135,7 +138,7 @@ module REST
135
138
  http_request.enable_post_connection_check = true
136
139
  end
137
140
  # from http://curl.haxx.se/ca/cacert.pem
138
- http_request.ca_file = options[:tls_ca_file] || File.join(File.expand_path('../../../support/cacert.pem', __FILE__))
141
+ http_request.ca_file = options[:tls_ca_file] || File.expand_path('../../../support/cacert.pem', __FILE__)
139
142
  http_request.verify_mode = OpenSSL::SSL::VERIFY_PEER
140
143
  else
141
144
  http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -171,4 +174,4 @@ module REST
171
174
  request.perform
172
175
  end
173
176
  end
174
- end
177
+ end
metadata CHANGED
@@ -1,74 +1,53 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: nap
3
- version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Manfred Stienstra
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-03-14 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
32
20
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: test-spec
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: peck
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
46
34
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: mocha
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
60
- type: :development
61
- version_requirements: *id003
62
- description: " Nap is a really simple REST library. It allows you to perform HTTP requests\n with minimal amounts of code.\n"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |2
42
+ Nap is a really simple REST library. It allows you to perform HTTP requests
43
+ with minimal amounts of code.
63
44
  email: manfred@fngtps.com
64
45
  executables: []
65
-
66
46
  extensions: []
67
-
68
- extra_rdoc_files:
47
+ extra_rdoc_files:
69
48
  - README.md
70
49
  - LICENSE
71
- files:
50
+ files:
72
51
  - lib/rest.rb
73
52
  - lib/rest/request.rb
74
53
  - lib/rest/response.rb
@@ -77,36 +56,26 @@ files:
77
56
  - LICENSE
78
57
  homepage:
79
58
  licenses: []
80
-
59
+ metadata: {}
81
60
  post_install_message:
82
- rdoc_options:
61
+ rdoc_options:
83
62
  - --charset=utf-8
84
- require_paths:
63
+ require_paths:
85
64
  - lib
86
- required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
95
- required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
104
75
  requirements: []
105
-
106
76
  rubyforge_project:
107
- rubygems_version: 1.8.18
77
+ rubygems_version: 2.0.3
108
78
  signing_key:
109
- specification_version: 3
79
+ specification_version: 4
110
80
  summary: Nap is a really simple REST library.
111
81
  test_files: []
112
-