curb-fu 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +52 -0
- data/README.md +111 -0
- data/Rakefile +12 -0
- data/curb-fu.gemspec +25 -0
- data/lib/curb-fu/request/test.rb +1 -1
- data/lib/curb-fu/version.rb +3 -0
- data/spec/spec_helper.rb +5 -7
- metadata +68 -18
- data/spec/spec.opts +0 -6
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.3@curb-fu
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
curb-fu (0.6.2)
|
5
|
+
curb (>= 0.5.4.0)
|
6
|
+
rack-test (>= 0.2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
curb (0.8.2)
|
12
|
+
diff-lcs (1.1.3)
|
13
|
+
htmlentities (4.3.1)
|
14
|
+
rack (1.4.1)
|
15
|
+
rack-test (0.6.2)
|
16
|
+
rack (>= 1.0)
|
17
|
+
rake (0.9.2.2)
|
18
|
+
rspec (2.11.0)
|
19
|
+
rspec-core (~> 2.11.0)
|
20
|
+
rspec-expectations (~> 2.11.0)
|
21
|
+
rspec-mocks (~> 2.11.0)
|
22
|
+
rspec-core (2.11.1)
|
23
|
+
rspec-expectations (2.11.3)
|
24
|
+
diff-lcs (~> 1.1.3)
|
25
|
+
rspec-mocks (2.11.3)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
curb-fu!
|
32
|
+
htmlentities
|
33
|
+
rake
|
34
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
Copyright (c) 2006 Ross Bamford (rosco AT roscopeco DOT co DOT uk).
|
2
|
+
Curb is free software licensed under the following terms:
|
3
|
+
|
4
|
+
1. You may make and give away verbatim copies of the source form of the
|
5
|
+
software without restriction, provided that you duplicate all of the
|
6
|
+
original copyright notices and associated disclaimers.
|
7
|
+
|
8
|
+
2. You may modify your copy of the software in any way, provided that
|
9
|
+
you do at least ONE of the following:
|
10
|
+
|
11
|
+
a) place your modifications in the Public Domain or otherwise
|
12
|
+
make them Freely Available, such as by posting said
|
13
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
14
|
+
the author to include your modifications in the software.
|
15
|
+
|
16
|
+
b) use the modified software only within your corporation or
|
17
|
+
organization.
|
18
|
+
|
19
|
+
c) give non-standard binaries non-standard names, with
|
20
|
+
instructions on where to get the original software distribution.
|
21
|
+
|
22
|
+
d) make other distribution arrangements with the author.
|
23
|
+
|
24
|
+
3. You may distribute the software in object code or binary form,
|
25
|
+
provided that you do at least ONE of the following:
|
26
|
+
|
27
|
+
a) distribute the binaries and library files of the software,
|
28
|
+
together with instructions (in the manual page or equivalent)
|
29
|
+
on where to get the original distribution.
|
30
|
+
|
31
|
+
b) accompany the distribution with the machine-readable source of
|
32
|
+
the software.
|
33
|
+
|
34
|
+
c) give non-standard binaries non-standard names, with
|
35
|
+
instructions on where to get the original software distribution.
|
36
|
+
|
37
|
+
d) make other distribution arrangements with the author.
|
38
|
+
|
39
|
+
4. You may modify and include the part of the software into any other
|
40
|
+
software (possibly commercial).
|
41
|
+
|
42
|
+
5. The scripts and library files supplied as input to or produced as
|
43
|
+
output from the software do not automatically fall under the
|
44
|
+
copyright of the software, but belong to whomever generated them,
|
45
|
+
and may be sold commercially, and may be aggregated with this
|
46
|
+
software.
|
47
|
+
|
48
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
49
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
50
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
51
|
+
PURPOSE.
|
52
|
+
|
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# curb-fu - easy-to-use wrapper around curb - the ruby wrapper around libcurl
|
2
|
+
|
3
|
+
* http://github.com/curb-fu
|
4
|
+
|
5
|
+
Curb can be found at http://github.com/taf2/curb
|
6
|
+
|
7
|
+
## License
|
8
|
+
|
9
|
+
This gem is released under the terms of the Ruby license. See the LICENSE file for details.
|
10
|
+
|
11
|
+
## Troubleshooting
|
12
|
+
|
13
|
+
If you are POSTing data and curb seems to be locking up, try posting it with an explicit 'Expect: 100-continue' header.
|
14
|
+
|
15
|
+
You can set this per-request, e.g.
|
16
|
+
|
17
|
+
CurbFu.post({:host => 'example.com', :headers => { "Expect" => "100-continue" }}, { "data" => "here" })
|
18
|
+
|
19
|
+
or you can configure it as a global header, e.g.
|
20
|
+
|
21
|
+
CurbFu.global_headers = { "Expect" => "100-continue" }
|
22
|
+
# ... then make your requests as normal
|
23
|
+
|
24
|
+
however you feel best.
|
25
|
+
|
26
|
+
## Prerequisites
|
27
|
+
|
28
|
+
* Ruby (tested on 1.8.7, 1.9.x)
|
29
|
+
* The Curb gem (and its libcurl dependency)
|
30
|
+
* http://github.com/taf2/curb
|
31
|
+
|
32
|
+
## Installation
|
33
|
+
|
34
|
+
$ gem install curb-fu --source http://gems.github.com
|
35
|
+
|
36
|
+
Or, if you have the source:
|
37
|
+
|
38
|
+
$ cd <source-dir>
|
39
|
+
$ rake gem
|
40
|
+
$ gem install pkg/
|
41
|
+
|
42
|
+
## Examples
|
43
|
+
|
44
|
+
Urls can be requested using hashes of options or strings. The GET, POST, PUT, and DELETE methods are supported
|
45
|
+
through their respective methods on CurbFu and CurbFu::Request.
|
46
|
+
|
47
|
+
### String Examples
|
48
|
+
|
49
|
+
response = CurbFu.get('http://slashdot.org')
|
50
|
+
puts response.body
|
51
|
+
|
52
|
+
response = CurbFu.post('http://example.com/some/resource', { :color => 'red', :shape => 'sphere' })
|
53
|
+
puts response.body unless response.success?
|
54
|
+
|
55
|
+
If you need to pass custom headers, you can still pass a string URL with :url :
|
56
|
+
|
57
|
+
response = CurbFu.post(:url => 'http://example.com/some/resource', :headers => {'Content-Type' => 'application/xml'})
|
58
|
+
|
59
|
+
|
60
|
+
### Hash Examples
|
61
|
+
|
62
|
+
response = CurbFu.get(:host => 'github.com', :path => '/gdi/curb-fu')
|
63
|
+
puts response.body
|
64
|
+
|
65
|
+
response = CurbFu.post({:host => 'example.com', :path => '/some/resource'}, { :color => 'red', :shape => 'sphere' })
|
66
|
+
puts response.body unless response.success?
|
67
|
+
|
68
|
+
if you need https:
|
69
|
+
|
70
|
+
response = CurbFu.post({:host => 'example.com', :path => '/some/resource', :protocol => "https"}, { :color => 'red', :shape => 'sphere' })
|
71
|
+
|
72
|
+
### Cookies; changes as of 0.6.1
|
73
|
+
|
74
|
+
if you want to send a cookie, previous to 0.6.1 you have to pass a block to the HTTP verb method like so:
|
75
|
+
|
76
|
+
response = CurbFu.get("http://myhost.com") do |curb|
|
77
|
+
curb.cookies = "SekretToken=123234234235;"
|
78
|
+
end
|
79
|
+
|
80
|
+
As of 0.6.1 one can set the cookies either as an optional final parameter or via a hash, e.g.:
|
81
|
+
|
82
|
+
response = CurbFu.get("http://myhost.com", { :param => "value" }, "SekretToken=123234;")
|
83
|
+
# or with a hash:
|
84
|
+
response = CurbFu.get({ :host => "http://myhost", :cookies => "SekretToken=1234;" })
|
85
|
+
|
86
|
+
etc.
|
87
|
+
|
88
|
+
Have fun!
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
93
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
94
|
+
* Fork the project
|
95
|
+
* Start a feature/bugfix branch
|
96
|
+
* Commit and push until you are happy with your contribution
|
97
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
98
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
99
|
+
* Send a pull request!
|
100
|
+
|
101
|
+
## Contributors
|
102
|
+
|
103
|
+
* thickpaddy (https://github.com/thickpaddy)
|
104
|
+
* hoverlover (https://github.com/hoverlover)
|
105
|
+
* whatcould (https://github.com/whatcould)
|
106
|
+
|
107
|
+
## Original Authorship
|
108
|
+
|
109
|
+
* dkastner (https://github.com/dkastner)
|
110
|
+
* hypomodern (https://github.com/hypomodern)
|
111
|
+
* Greenview Data, Inc. (http://greenviewdata.com)
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
7
|
+
spec.rspec_opts = ['--backtrace']
|
8
|
+
# spec.ruby_opts = ['-w']
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
|
data/curb-fu.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'curb-fu/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.name = "curb-fu"
|
8
|
+
s.version = CurbFu::VERSION
|
9
|
+
s.author = "Derek Kastner, Matt Wilson"
|
10
|
+
s.email = "development@greenviewdata.com"
|
11
|
+
s.summary = "Friendly wrapper for curb"
|
12
|
+
s.has_rdoc = false
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency('curb', '>= 0.5.4.0')
|
20
|
+
s.add_dependency('rack-test', '>= 0.2.0')
|
21
|
+
|
22
|
+
s.add_development_dependency('rake')
|
23
|
+
s.add_development_dependency('rspec')
|
24
|
+
s.add_development_dependency('htmlentities')
|
25
|
+
end
|
data/lib/curb-fu/request/test.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'rspec'
|
2
|
+
require 'curb-fu'
|
2
3
|
require 'htmlentities'
|
3
4
|
|
4
|
-
|
5
|
-
lib_path = File.expand_path(File.join(dir,'..','lib'))
|
6
|
-
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
7
|
-
|
8
|
-
Dir.glob(File.join(dir,'helpers','**','*')).each { |helper| require helper }
|
5
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
6
|
|
10
|
-
|
7
|
+
RSpec.configure do |config|
|
8
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curb-fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: curb
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 0.5.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.5.4.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rack-test
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,21 +37,47 @@ dependencies:
|
|
32
37
|
version: 0.2.0
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
36
62
|
- !ruby/object:Gem::Dependency
|
37
63
|
name: rspec
|
38
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
39
65
|
none: false
|
40
66
|
requirements:
|
41
|
-
- -
|
67
|
+
- - ! '>='
|
42
68
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
69
|
+
version: '0'
|
44
70
|
type: :development
|
45
71
|
prerelease: false
|
46
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
47
78
|
- !ruby/object:Gem::Dependency
|
48
79
|
name: htmlentities
|
49
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
50
81
|
none: false
|
51
82
|
requirements:
|
52
83
|
- - ! '>='
|
@@ -54,25 +85,40 @@ dependencies:
|
|
54
85
|
version: '0'
|
55
86
|
type: :development
|
56
87
|
prerelease: false
|
57
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
58
94
|
description:
|
59
95
|
email: development@greenviewdata.com
|
60
96
|
executables: []
|
61
97
|
extensions: []
|
62
98
|
extra_rdoc_files: []
|
63
99
|
files:
|
100
|
+
- .gitignore
|
101
|
+
- .rspec
|
102
|
+
- .rvmrc
|
103
|
+
- Gemfile
|
104
|
+
- Gemfile.lock
|
105
|
+
- LICENSE
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- curb-fu.gemspec
|
109
|
+
- lib/curb-fu.rb
|
64
110
|
- lib/curb-fu/authentication.rb
|
65
111
|
- lib/curb-fu/core_ext.rb
|
112
|
+
- lib/curb-fu/request.rb
|
66
113
|
- lib/curb-fu/request/base.rb
|
67
114
|
- lib/curb-fu/request/common.rb
|
68
115
|
- lib/curb-fu/request/parameter.rb
|
69
116
|
- lib/curb-fu/request/test.rb
|
70
|
-
- lib/curb-fu/request.rb
|
71
117
|
- lib/curb-fu/response.rb
|
118
|
+
- lib/curb-fu/test.rb
|
72
119
|
- lib/curb-fu/test/request_logger.rb
|
73
120
|
- lib/curb-fu/test/server.rb
|
74
|
-
- lib/curb-fu/
|
75
|
-
- lib/curb-fu.rb
|
121
|
+
- lib/curb-fu/version.rb
|
76
122
|
- spec/fixtures/foo.txt
|
77
123
|
- spec/lib/curb-fu/core_ext_spec.rb
|
78
124
|
- spec/lib/curb-fu/request/base_spec.rb
|
@@ -80,7 +126,6 @@ files:
|
|
80
126
|
- spec/lib/curb-fu/request/test_spec.rb
|
81
127
|
- spec/lib/curb-fu/response_spec.rb
|
82
128
|
- spec/lib/curb_fu_spec.rb
|
83
|
-
- spec/spec.opts
|
84
129
|
- spec/spec_helper.rb
|
85
130
|
homepage:
|
86
131
|
licenses: []
|
@@ -94,15 +139,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
139
|
- - ! '>='
|
95
140
|
- !ruby/object:Gem::Version
|
96
141
|
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: 4389421244685267208
|
97
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
146
|
none: false
|
99
147
|
requirements:
|
100
148
|
- - ! '>='
|
101
149
|
- !ruby/object:Gem::Version
|
102
150
|
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: 4389421244685267208
|
103
154
|
requirements: []
|
104
155
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.8.
|
156
|
+
rubygems_version: 1.8.24
|
106
157
|
signing_key:
|
107
158
|
specification_version: 3
|
108
159
|
summary: Friendly wrapper for curb
|
@@ -114,5 +165,4 @@ test_files:
|
|
114
165
|
- spec/lib/curb-fu/request/test_spec.rb
|
115
166
|
- spec/lib/curb-fu/response_spec.rb
|
116
167
|
- spec/lib/curb_fu_spec.rb
|
117
|
-
- spec/spec.opts
|
118
168
|
- spec/spec_helper.rb
|