curb 0.5.8.0-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curb might be problematic. Click here for more details.

data/LICENSE ADDED
@@ -0,0 +1,51 @@
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.
data/README ADDED
@@ -0,0 +1,157 @@
1
+ # Curb - Libcurl bindings for Ruby
2
+
3
+ + [rubyforge rdoc](http://curb.rubyforge.org/)
4
+ + [rubyforge project](http://rubyforge.org/projects/curb)
5
+ + [github project](http://github.com/taf2/curb/tree/master)
6
+
7
+ Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
8
+ libcurl(3), a fully-featured client-side URL transfer library.
9
+ cURL and libcurl live at [http://curl.haxx.se/](http://curl.haxx.se/) .
10
+
11
+ Curb is a work-in-progress, and currently only supports libcurl's 'easy' and 'multi' modes.
12
+
13
+ ## License
14
+
15
+ Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
16
+ Ruby license. See the LICENSE file for the gory details.
17
+
18
+ ## You will need
19
+
20
+ + A working Ruby installation (1.8+, tested with 1.8.6, 1.8.7, 1.9.1, and 1.9.2)
21
+ + A working (lib)curl installation, with development stuff (7.5+, tested with 7.19.x)
22
+ + A sane build environment (e.g. gcc, make)
23
+
24
+ ## Installation...
25
+
26
+ ... will usually be as simple as:
27
+
28
+ $ gem install curb
29
+
30
+ Or, if you downloaded the archive:
31
+
32
+ $ rake install
33
+
34
+ If you have a wierd setup, you might need extconf options. In this case, pass
35
+ them like so:
36
+
37
+ $ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
38
+
39
+ Curb is tested only on GNU/Linux x86 and Mac OSX - YMMV on other platforms.
40
+ If you do use another platform and experience problems, or if you can
41
+ expand on the above instructions, please report the issue at http://github.com/taf2/curb/issues
42
+
43
+ Curb has fairly extensive RDoc comments in the source. You can build the
44
+ documentation with:
45
+
46
+ $ rake doc
47
+
48
+ ## Examples
49
+
50
+ ### Simple fetch via HTTP:
51
+
52
+ c = Curl::Easy.perform("http://www.google.co.uk")
53
+ puts c.body_str
54
+
55
+ ### Same thing, more manual:
56
+
57
+ c = Curl::Easy.new("http://www.google.co.uk")
58
+ c.perform
59
+ puts c.body_str
60
+
61
+ ### Additional config:
62
+
63
+ Curl::Easy.perform("http://www.google.co.uk") do |curl|
64
+ curl.headers["User-Agent"] = "myapp-0.0"
65
+ curl.verbose = true
66
+ end
67
+
68
+ ### Same thing, more manual:
69
+
70
+ c = Curl::Easy.new("http://www.google.co.uk") do |curl|
71
+ curl.headers["User-Agent"] = "myapp-0.0"
72
+ curl.verbose = true
73
+ end
74
+
75
+ c.perform
76
+
77
+ ### Supplying custom handlers:
78
+
79
+ c = Curl::Easy.new("http://www.google.co.uk")
80
+
81
+ c.on_body { |data| print(data) }
82
+ c.on_header { |data| print(data) }
83
+
84
+ c.perform
85
+
86
+ ### Reusing Curls:
87
+
88
+ c = Curl::Easy.new
89
+
90
+ ["http://www.google.co.uk", "http://www.ruby-lang.org/"].map do |url|
91
+ c.url = url
92
+ c.perform
93
+ c.body_str
94
+ end
95
+
96
+ ### HTTP POST form:
97
+
98
+ c = Curl::Easy.http_post("http://my.rails.box/thing/create",
99
+ Curl::PostField.content('thing[name]', 'box'),
100
+ Curl::PostField.content('thing[type]', 'storage'))
101
+
102
+ ### HTTP POST file upload:
103
+
104
+ c = Curl::Easy.new("http://my.rails.box/files/upload")
105
+ c.multipart_form_post = true
106
+ c.http_post(Curl::PostField.file('myfile.rb'))
107
+
108
+ ### Multi Interface (Basic HTTP GET):
109
+
110
+ # make multiple GET requests
111
+ easy_options = {:follow_location => true}
112
+ multi_options = {:pipeline => true}
113
+
114
+ Curl::Multi.get('url1','url2','url3','url4','url5', easy_options, multi_options) do|easy|
115
+ # do something interesting with the easy response
116
+ puts easy.last_effective_url
117
+ end
118
+
119
+ ### Multi Interface (Basic HTTP POST):
120
+
121
+ # make multiple POST requests
122
+ easy_options = {:follow_location => true, :multipart_form_post => true}
123
+ multi_options = {:pipeline => true}
124
+
125
+ url_fields = [
126
+ { :url => 'url1', :post_fields => {'f1' => 'v1'} },
127
+ { :url => 'url2', :post_fields => {'f1' => 'v1'} },
128
+ { :url => 'url3', :post_fields => {'f1' => 'v1'} }
129
+ ]
130
+
131
+ Curl::Multi.post(url_fields, easy_options, multi_options) do|easy|
132
+ # do something interesting with the easy response
133
+ puts easy.last_effective_url
134
+ end
135
+
136
+ ### Multi Interface (Advanced):
137
+
138
+ responses = {}
139
+ requests = ["http://www.google.co.uk/", "http://www.ruby-lang.org/"]
140
+ m = Curl::Multi.new
141
+ # add a few easy handles
142
+ requests.each do |url|
143
+ responses[url] = ""
144
+ c = Curl::Easy.new(url) do|curl|
145
+ curl.follow_location = true
146
+ curl.on_body{|data| responses[url] << data; data.size }
147
+ end
148
+ m.add(c)
149
+ end
150
+
151
+ m.perform do
152
+ puts "idling... can do some work here, including add new requests"
153
+ end
154
+
155
+ requests.each do|url|
156
+ puts responses[url]
157
+ end
data/Rakefile ADDED
@@ -0,0 +1,297 @@
1
+ # $Id$
2
+ #
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ CLEAN.include '**/*.o'
8
+ CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
9
+ CLOBBER.include 'doc'
10
+ CLOBBER.include '**/*.log'
11
+ CLOBBER.include '**/Makefile'
12
+ CLOBBER.include '**/extconf.h'
13
+
14
+ def announce(msg='')
15
+ $stderr.puts msg
16
+ end
17
+
18
+ desc "Default Task (Test project)"
19
+ task :default => :test
20
+
21
+ # Determine the current version of the software
22
+ if File.read('ext/curb.h') =~ /\s*CURB_VERSION\s*['"](\d.+)['"]/
23
+ CURRENT_VERSION = $1
24
+ else
25
+ CURRENT_VERSION = "0.0.0"
26
+ end
27
+
28
+ if ENV['REL']
29
+ PKG_VERSION = ENV['REL']
30
+ else
31
+ PKG_VERSION = CURRENT_VERSION
32
+ end
33
+
34
+ task :test_ver do
35
+ puts PKG_VERSION
36
+ end
37
+
38
+ # Make tasks -----------------------------------------------------
39
+ make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
40
+ MAKECMD = ENV['MAKE_CMD'] || make_program
41
+ MAKEOPTS = ENV['MAKE_OPTS'] || ''
42
+
43
+ CURB_SO = "ext/curb_core.#{Config::MAKEFILE_CONFIG['DLEXT']}"
44
+
45
+ file 'ext/Makefile' => 'ext/extconf.rb' do
46
+ Dir.chdir('ext') do
47
+ ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
48
+ end
49
+ end
50
+
51
+ def make(target = '')
52
+ Dir.chdir('ext') do
53
+ pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
54
+ $?.exitstatus
55
+ end
56
+ end
57
+
58
+ # Let make handle dependencies between c/o/so - we'll just run it.
59
+ file CURB_SO => (['ext/Makefile'] + Dir['ext/*.c'] + Dir['ext/*.h']) do
60
+ m = make
61
+ fail "Make failed (status #{m})" unless m == 0
62
+ end
63
+
64
+ desc "Compile the shared object"
65
+ task :compile => [CURB_SO]
66
+
67
+ desc "Create the markdown file"
68
+ task :markdown do
69
+ cp "README", "README.markdown"
70
+ end
71
+
72
+ desc "Install to your site_ruby directory"
73
+ task :install => :alltests do
74
+ m = make 'install'
75
+ fail "Make install failed (status #{m})" unless m == 0
76
+ end
77
+
78
+ # Test Tasks ---------------------------------------------------------
79
+ task :ta => :alltests
80
+ task :tu => :unittests
81
+ task :test => [:rmpid,:unittests]
82
+
83
+ task :rmpid do
84
+ FileUtils.rm_rf Dir.glob("tests/server_lock-*")
85
+ end
86
+
87
+ if ENV['RELTEST']
88
+ announce "Release task testing - not running regression tests on alltests"
89
+ task :alltests => [:unittests]
90
+ else
91
+ task :alltests => [:unittests, :bugtests]
92
+ end
93
+
94
+ Rake::TestTask.new(:unittests) do |t|
95
+ t.test_files = FileList['tests/tc_*.rb']
96
+ t.verbose = false
97
+ end
98
+
99
+ Rake::TestTask.new(:bugtests) do |t|
100
+ t.test_files = FileList['tests/bug_*.rb']
101
+ t.verbose = false
102
+ end
103
+
104
+ #Rake::TestTask.new(:funtests) do |t|
105
+ # t.test_files = FileList['test/func_*.rb']
106
+ #t.warning = true
107
+ #t.warning = true
108
+ #end
109
+
110
+ task :unittests => :compile
111
+ task :bugtests => :compile
112
+
113
+ # RDoc Tasks ---------------------------------------------------------
114
+ desc "Create the RDOC documentation"
115
+ task :doc do
116
+ ruby "doc.rb #{ENV['DOC_OPTS']}"
117
+ end
118
+
119
+ desc "Publish the RDoc documentation to project web site"
120
+ task :doc_upload => [ :doc ] do
121
+ if ENV['RELTEST']
122
+ announce "Release Task Testing, skipping doc upload"
123
+ else
124
+ unless ENV['RUBYFORGE_ACCT']
125
+ raise "Need to set RUBYFORGE_ACCT to your rubyforge.org user name (e.g. 'fred')"
126
+ end
127
+
128
+ require 'rake/contrib/sshpublisher'
129
+ Rake::SshDirPublisher.new(
130
+ "#{ENV['RUBYFORGE_ACCT']}@rubyforge.org",
131
+ "/var/www/gforge-projects/curb",
132
+ "doc"
133
+ ).upload
134
+ end
135
+ end
136
+
137
+ if ! defined?(Gem)
138
+ warn "Package Target requires RubyGEMs"
139
+ else
140
+ desc 'Generate gem specification'
141
+ task :gemspec do
142
+ require 'erb'
143
+ tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'lib','curb.gemspec.erb')))
144
+ File.open(File.join(File.dirname(__FILE__),'curb.gemspec'),'wb') do|f|
145
+ f << tspec.result
146
+ end
147
+ end
148
+
149
+ desc 'Build gem'
150
+ task :package => :gemspec do
151
+ require 'rubygems/specification'
152
+ spec_source = File.read File.join(File.dirname(__FILE__),'curb.gemspec')
153
+ spec = nil
154
+ # see: http://gist.github.com/16215
155
+ Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
156
+ spec.validate
157
+ Gem::Builder.new(spec).build
158
+ end
159
+
160
+ task :static do
161
+ ENV['STATIC_BUILD'] = '1'
162
+ end
163
+
164
+ task :binary_gemspec => [:static, :compile] do
165
+ require 'erb'
166
+ ENV['BINARY_PACKAGE'] = '1'
167
+ tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'lib','curb.gemspec.erb')))
168
+
169
+ File.open(File.join(File.dirname(__FILE__),'curb-binary.gemspec'),'wb') do|f|
170
+ f << tspec.result
171
+ end
172
+ end
173
+
174
+ desc 'Strip extra strings from Binary'
175
+ task :binary_strip do
176
+ strip = '/usr/bin/strip'
177
+ if File.exist?(strip) and `#{strip} -h 2>&1`.match(/GNU/)
178
+ sh "#{strip} #{CURB_SO}"
179
+ end
180
+ end
181
+
182
+ desc 'Build gem'
183
+ task :binary_package => [:binary_gemspec, :binary_strip] do
184
+ require 'rubygems/specification'
185
+ spec_source = File.read File.join(File.dirname(__FILE__),'curb-binary.gemspec')
186
+ spec = nil
187
+ # see: http://gist.github.com/16215
188
+ Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
189
+ spec.validate
190
+ Gem::Builder.new(spec).build
191
+ end
192
+ end
193
+
194
+ # --------------------------------------------------------------------
195
+ # Creating a release
196
+ desc "Make a new release (Requires SVN commit / webspace access)"
197
+ task :release => [
198
+ :prerelease,
199
+ :clobber,
200
+ :alltests,
201
+ :update_version,
202
+ :package,
203
+ :tag,
204
+ :doc_upload] do
205
+
206
+ announce
207
+ announce "**************************************************************"
208
+ announce "* Release #{PKG_VERSION} Complete."
209
+ announce "* Packages ready to upload."
210
+ announce "**************************************************************"
211
+ announce
212
+ end
213
+
214
+ # Validate that everything is ready to go for a release.
215
+ task :prerelease do
216
+ announce
217
+ announce "**************************************************************"
218
+ announce "* Making RubyGem Release #{PKG_VERSION}"
219
+ announce "* (current version #{CURRENT_VERSION})"
220
+ announce "**************************************************************"
221
+ announce
222
+
223
+ # Is a release number supplied?
224
+ unless ENV['REL']
225
+ fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
226
+ end
227
+
228
+ # Is the release different than the current release.
229
+ # (or is REUSE set?)
230
+ if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
231
+ fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
232
+ end
233
+
234
+ # Are all source files checked in?
235
+ if ENV['RELTEST']
236
+ announce "Release Task Testing, skipping checked-in file test"
237
+ else
238
+ announce "Checking for unchecked-in files..."
239
+ data = `svn status`
240
+ unless data =~ /^$/
241
+ fail "SVN status is not clean ... do you have unchecked-in files?"
242
+ end
243
+ announce "No outstanding checkins found ... OK"
244
+ end
245
+
246
+ announce "Doc will try to use GNU cpp if available"
247
+ ENV['DOC_OPTS'] = "--cpp"
248
+ end
249
+
250
+ # Used during release packaging if a REL is supplied
251
+ task :update_version do
252
+ unless PKG_VERSION == CURRENT_VERSION
253
+ pkg_vernum = PKG_VERSION.tr('.','').sub(/^0*/,'')
254
+ pkg_vernum << '0' until pkg_vernum.length > 2
255
+
256
+ File.open('ext/curb.h.new','w+') do |f|
257
+ maj, min, mic, patch = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?/.match(PKG_VERSION).captures
258
+ f << File.read('ext/curb.h').
259
+ gsub(/CURB_VERSION\s+"(\d.+)"/) { "CURB_VERSION \"#{PKG_VERSION}\"" }.
260
+ gsub(/CURB_VER_NUM\s+\d+/) { "CURB_VER_NUM #{pkg_vernum}" }.
261
+ gsub(/CURB_VER_MAJ\s+\d+/) { "CURB_VER_MAJ #{maj}" }.
262
+ gsub(/CURB_VER_MIN\s+\d+/) { "CURB_VER_MIN #{min}" }.
263
+ gsub(/CURB_VER_MIC\s+\d+/) { "CURB_VER_MIC #{mic || 0}" }.
264
+ gsub(/CURB_VER_PATCH\s+\d+/) { "CURB_VER_PATCH #{patch || 0}" }
265
+ end
266
+ mv('ext/curb.h.new', 'ext/curb.h')
267
+ if ENV['RELTEST']
268
+ announce "Release Task Testing, skipping commiting of new version"
269
+ else
270
+ sh %{svn commit -m "Updated to version #{PKG_VERSION}" ext/curb.h}
271
+ end
272
+ end
273
+ end
274
+
275
+ # "Create a new SVN tag with the latest release number (REL=x.y.z)"
276
+ task :tag => [:prerelease] do
277
+ reltag = "curb-#{PKG_VERSION}"
278
+ reltag << ENV['REUSE'] if ENV['REUSE']
279
+ announce "Tagging SVN with [#{reltag}]"
280
+ if ENV['RELTEST']
281
+ announce "Release Task Testing, skipping SVN tagging"
282
+ else
283
+ # need to get current base URL
284
+ s = `svn info`
285
+ if s =~ /URL:\s*([^\n]*)\n/
286
+ svnroot = $1
287
+ if svnroot =~ /^(.*)\/trunk/i
288
+ svnbase = $1
289
+ sh %{svn cp #{svnroot} #{svnbase}/TAGS/#{reltag} -m "Release #{PKG_VERSION}"}
290
+ else
291
+ fail "Please merge to trunk before making a release"
292
+ end
293
+ else
294
+ fail "Unable to determine repository URL from 'svn info' - is this a working copy?"
295
+ end
296
+ end
297
+ end