taf2-curb 0.2.3

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/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,128 @@
1
+ == Curb - Libcurl bindings for Ruby
2
+
3
+ * http://curb.rubyforge.org/
4
+ * http://rubyforge.org/projects/curb
5
+
6
+ Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
7
+ libcurl(3), a fully-featured client-side URL transfer library.
8
+ cURL and libcurl live at http://curl.haxx.se/ .
9
+
10
+ Curb is a work-in-progress, and currently only supports libcurl's 'easy' and 'multi' modes.
11
+
12
+ === License
13
+
14
+ Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
15
+ Ruby license. See the LICENSE file for the gory details.
16
+
17
+ === You will need
18
+
19
+ * A working Ruby installation (1.8+, tested with 1.8.5)
20
+ * A working (lib)curl installation, with development stuff (7.5+, tested with 7.15)
21
+ * A sane build environment
22
+
23
+ === Installation...
24
+
25
+ ... will usually be as simple as:
26
+
27
+ $ gem install curb
28
+
29
+ Or, if you downloaded the archive:
30
+
31
+ $ rake install
32
+
33
+ If you have a wierd setup, you might need extconf options. In this case, pass
34
+ them like so:
35
+
36
+ $ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
37
+
38
+ Currently, Curb is tested only on GNU/Linux x86 - YMMV on other platforms.
39
+ If you do use another platform and experience problems, or if you can
40
+ expand on the above instructions, please get in touch via the mailing
41
+ list on Curb's Rubyforge page.
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:
109
+ responses = {}
110
+ requests = ["http://www.google.co.uk/", "http://www.ruby-lang.org/"]
111
+ m = Curl::Multi.new
112
+ # add a few easy handles
113
+ requests.each do |url|
114
+ responses[url] = ""
115
+ c = Curl::Easy.new(url) do|curl|
116
+ curl.follow_location = true
117
+ curl.on_body{|data| responses[url] << data; data.size }
118
+ end
119
+ m.add(c)
120
+ end
121
+
122
+ m.perform do
123
+ puts "idling... can do some work here, including add new requests"
124
+ end
125
+
126
+ requests.each do|url|
127
+ puts responses[url]
128
+ end
data/Rakefile ADDED
@@ -0,0 +1,303 @@
1
+ # $Id$
2
+ #
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ begin
8
+ require 'rake/gempackagetask'
9
+ rescue LoadError
10
+ $stderr.puts("Rubygems support disabled")
11
+ end
12
+
13
+ CLEAN.include '**/*.o'
14
+ CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
15
+ CLOBBER.include 'doc'
16
+ CLOBBER.include '**/*.log'
17
+ CLOBBER.include '**/Makefile'
18
+ CLOBBER.include '**/extconf.h'
19
+
20
+ def announce(msg='')
21
+ $stderr.puts msg
22
+ end
23
+
24
+ desc "Default Task (Test project)"
25
+ task :default => :test
26
+
27
+ # Determine the current version of the software
28
+ if File.read('ext/curb.h') =~ /\s*CURB_VERSION\s*['"](\d.+)['"]/
29
+ CURRENT_VERSION = $1
30
+ else
31
+ CURRENT_VERSION = "0.0.0"
32
+ end
33
+
34
+ if ENV['REL']
35
+ PKG_VERSION = ENV['REL']
36
+ else
37
+ PKG_VERSION = CURRENT_VERSION
38
+ end
39
+
40
+ task :test_ver do
41
+ puts PKG_VERSION
42
+ end
43
+
44
+ # Make tasks -----------------------------------------------------
45
+ MAKECMD = ENV['MAKE_CMD'] || 'make'
46
+ MAKEOPTS = ENV['MAKE_OPTS'] || ''
47
+
48
+ CURB_SO = "ext/curb_core.#{Config::MAKEFILE_CONFIG['DLEXT']}"
49
+
50
+ file 'ext/Makefile' => 'ext/extconf.rb' do
51
+ Dir.chdir('ext') do
52
+ ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
53
+ end
54
+ end
55
+
56
+ def make(target = '')
57
+ Dir.chdir('ext') do
58
+ pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
59
+ $?.exitstatus
60
+ end
61
+ end
62
+
63
+ # Let make handle dependencies between c/o/so - we'll just run it.
64
+ file CURB_SO => (['ext/Makefile'] + Dir['ext/*.c'] + Dir['ext/*.h']) do
65
+ m = make
66
+ fail "Make failed (status #{m})" unless m == 0
67
+ end
68
+
69
+ desc "Compile the shared object"
70
+ task :compile => [CURB_SO]
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 => :unittests
82
+
83
+ if ENV['RELTEST']
84
+ announce "Release task testing - not running regression tests on alltests"
85
+ task :alltests => [:unittests]
86
+ else
87
+ task :alltests => [:unittests, :bugtests]
88
+ end
89
+
90
+ Rake::TestTask.new(:unittests) do |t|
91
+ t.test_files = FileList['tests/tc_*.rb']
92
+ t.verbose = false
93
+ end
94
+
95
+ Rake::TestTask.new(:bugtests) do |t|
96
+ t.test_files = FileList['tests/bug_*.rb']
97
+ t.verbose = false
98
+ end
99
+
100
+ #Rake::TestTask.new(:funtests) do |t|
101
+ # t.test_files = FileList['test/func_*.rb']
102
+ #t.warning = true
103
+ #t.warning = true
104
+ #end
105
+
106
+ task :unittests => :compile
107
+ task :bugtests => :compile
108
+
109
+ # RDoc Tasks ---------------------------------------------------------
110
+ desc "Create the RDOC documentation"
111
+ task :doc do
112
+ ruby "doc.rb #{ENV['DOC_OPTS']}"
113
+ end
114
+
115
+ desc "Publish the RDoc documentation to project web site"
116
+ task :doc_upload => [ :doc ] do
117
+ if ENV['RELTEST']
118
+ announce "Release Task Testing, skipping doc upload"
119
+ else
120
+ unless ENV['RUBYFORGE_ACCT']
121
+ raise "Need to set RUBYFORGE_ACCT to your rubyforge.org user name (e.g. 'fred')"
122
+ end
123
+
124
+ require 'rake/contrib/sshpublisher'
125
+ Rake::SshDirPublisher.new(
126
+ "#{ENV['RUBYFORGE_ACCT']}@rubyforge.org",
127
+ "/var/www/gforge-projects/curb",
128
+ "doc"
129
+ ).upload
130
+ end
131
+ end
132
+
133
+ # Packaging ------------------------------------------------
134
+ PKG_FILES = FileList[
135
+ 'ext/*.rb',
136
+ 'ext/*.c',
137
+ 'ext/*.h',
138
+ 'tests/**/*',
139
+ 'samples/**/*',
140
+ 'doc.rb',
141
+ '[A-Z]*',
142
+ ]
143
+
144
+ if ! defined?(Gem)
145
+ warn "Package Target requires RubyGEMs"
146
+ else
147
+ spec = Gem::Specification.new do |s|
148
+
149
+ #### Basic information.
150
+
151
+ s.name = 'curb'
152
+ s.version = PKG_VERSION
153
+ s.summary = "Ruby bindings for the libcurl(3) URL transfer library."
154
+ s.description = <<-EOF
155
+ C-language Ruby bindings for the libcurl(3) URL transfer library.
156
+ EOF
157
+ s.extensions = 'ext/extconf.rb'
158
+
159
+ #### Which files are to be included in this gem?
160
+
161
+ s.files = PKG_FILES.to_a
162
+
163
+ #### Load-time details
164
+ s.require_path = 'lib'
165
+
166
+ #### Documentation and testing.
167
+ s.has_rdoc = true
168
+ s.extra_rdoc_files = Dir['ext/*.c'] << 'ext/curb.rb' << 'README' << 'LICENSE'
169
+ s.rdoc_options <<
170
+ '--title' << 'Curb API' <<
171
+ '--main' << 'README'
172
+
173
+ s.test_files = Dir.glob('tests/tc_*.rb')
174
+
175
+ #### Author and project details.
176
+
177
+ s.author = "Ross Bamford"
178
+ s.email = "curb-devel@rubyforge.org"
179
+ s.homepage = "http://curb.rubyforge.org"
180
+ s.rubyforge_project = "curb"
181
+ end
182
+
183
+ # Quick fix for Ruby 1.8.3 / YAML bug
184
+ if (RUBY_VERSION == '1.8.3')
185
+ def spec.to_yaml
186
+ out = super
187
+ out = '--- ' + out unless out =~ /^---/
188
+ out
189
+ end
190
+ end
191
+
192
+ package_task = Rake::GemPackageTask.new(spec) do |pkg|
193
+ pkg.need_zip = true
194
+ pkg.need_tar_gz = true
195
+ pkg.package_dir = 'pkg'
196
+ end
197
+ end
198
+
199
+
200
+ # --------------------------------------------------------------------
201
+ # Creating a release
202
+ desc "Make a new release (Requires SVN commit / webspace access)"
203
+ task :release => [
204
+ :prerelease,
205
+ :clobber,
206
+ :alltests,
207
+ :update_version,
208
+ :package,
209
+ :tag,
210
+ :doc_upload] do
211
+
212
+ announce
213
+ announce "**************************************************************"
214
+ announce "* Release #{PKG_VERSION} Complete."
215
+ announce "* Packages ready to upload."
216
+ announce "**************************************************************"
217
+ announce
218
+ end
219
+
220
+ # Validate that everything is ready to go for a release.
221
+ task :prerelease do
222
+ announce
223
+ announce "**************************************************************"
224
+ announce "* Making RubyGem Release #{PKG_VERSION}"
225
+ announce "* (current version #{CURRENT_VERSION})"
226
+ announce "**************************************************************"
227
+ announce
228
+
229
+ # Is a release number supplied?
230
+ unless ENV['REL']
231
+ fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
232
+ end
233
+
234
+ # Is the release different than the current release.
235
+ # (or is REUSE set?)
236
+ if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
237
+ fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
238
+ end
239
+
240
+ # Are all source files checked in?
241
+ if ENV['RELTEST']
242
+ announce "Release Task Testing, skipping checked-in file test"
243
+ else
244
+ announce "Checking for unchecked-in files..."
245
+ data = `svn status`
246
+ unless data =~ /^$/
247
+ fail "SVN status is not clean ... do you have unchecked-in files?"
248
+ end
249
+ announce "No outstanding checkins found ... OK"
250
+ end
251
+
252
+ announce "Doc will try to use GNU cpp if available"
253
+ ENV['DOC_OPTS'] = "--cpp"
254
+ end
255
+
256
+ # Used during release packaging if a REL is supplied
257
+ task :update_version do
258
+ unless PKG_VERSION == CURRENT_VERSION
259
+ pkg_vernum = PKG_VERSION.tr('.','').sub(/^0*/,'')
260
+ pkg_vernum << '0' until pkg_vernum.length > 2
261
+
262
+ File.open('ext/curb.h.new','w+') do |f|
263
+ maj, min, mic, patch = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?/.match(PKG_VERSION).captures
264
+ f << File.read('ext/curb.h').
265
+ gsub(/CURB_VERSION\s+"(\d.+)"/) { "CURB_VERSION \"#{PKG_VERSION}\"" }.
266
+ gsub(/CURB_VER_NUM\s+\d+/) { "CURB_VER_NUM #{pkg_vernum}" }.
267
+ gsub(/CURB_VER_MAJ\s+\d+/) { "CURB_VER_MAJ #{maj}" }.
268
+ gsub(/CURB_VER_MIN\s+\d+/) { "CURB_VER_MIN #{min}" }.
269
+ gsub(/CURB_VER_MIC\s+\d+/) { "CURB_VER_MIC #{mic || 0}" }.
270
+ gsub(/CURB_VER_PATCH\s+\d+/) { "CURB_VER_PATCH #{patch || 0}" }
271
+ end
272
+ mv('ext/curb.h.new', 'ext/curb.h')
273
+ if ENV['RELTEST']
274
+ announce "Release Task Testing, skipping commiting of new version"
275
+ else
276
+ sh %{svn commit -m "Updated to version #{PKG_VERSION}" ext/curb.h}
277
+ end
278
+ end
279
+ end
280
+
281
+ # "Create a new SVN tag with the latest release number (REL=x.y.z)"
282
+ task :tag => [:prerelease] do
283
+ reltag = "curb-#{PKG_VERSION}"
284
+ reltag << ENV['REUSE'] if ENV['REUSE']
285
+ announce "Tagging SVN with [#{reltag}]"
286
+ if ENV['RELTEST']
287
+ announce "Release Task Testing, skipping SVN tagging"
288
+ else
289
+ # need to get current base URL
290
+ s = `svn info`
291
+ if s =~ /URL:\s*([^\n]*)\n/
292
+ svnroot = $1
293
+ if svnroot =~ /^(.*)\/trunk/i
294
+ svnbase = $1
295
+ sh %{svn cp #{svnroot} #{svnbase}/TAGS/#{reltag} -m "Release #{PKG_VERSION}"}
296
+ else
297
+ fail "Please merge to trunk before making a release"
298
+ end
299
+ else
300
+ fail "Unable to determine repository URL from 'svn info' - is this a working copy?"
301
+ end
302
+ end
303
+ end
data/doc.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ begin
5
+ incflags = File.read('ext/Makefile')[/INCFLAGS\s*=\s*(.*)$/,1]
6
+ rescue Errno::ENOENT
7
+ $stderr.puts("No makefile found; run `rake ext/Makefile' first.")
8
+ end
9
+
10
+ pp_srcdir = 'ext'
11
+
12
+ rm_rf(tmpdir = '.doc-tmp')
13
+ mkdir(tmpdir)
14
+
15
+ begin
16
+ if ARGV.include?('--cpp')
17
+ begin
18
+ if `cpp --version` =~ /\(GCC\)/
19
+ # gnu cpp
20
+ $stderr.puts "Running GNU cpp over source"
21
+
22
+ Dir['ext/*.c'].each do |fn|
23
+ system("cpp -DRDOC_NEVER_DEFINED -C #{incflags} -o " +
24
+ "#{File.join(tmpdir, File.basename(fn))} #{fn}")
25
+ end
26
+
27
+ pp_srcdir = tmpdir
28
+ else
29
+ $stderr.puts "Not running cpp (non-GNU)"
30
+ end
31
+ rescue
32
+ # no cpp
33
+ $stderr.puts "No cpp found"
34
+ end
35
+ end
36
+
37
+ system("rdoc --title='Curb - libcurl bindings for ruby' --main=README #{pp_srcdir}/*.c README LICENSE ext/curb.rb")
38
+ ensure
39
+ rm_rf(tmpdir)
40
+ end
41
+
42
+