curb 0.1.0

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,106 @@
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' mode.
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'))
@@ -0,0 +1,302 @@
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 '**/*.so'
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 (Build packages)"
25
+ task :default => :package
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
+ file 'ext/Makefile' => 'ext/extconf.rb' do
49
+ Dir.chdir('ext') do
50
+ ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
51
+ end
52
+ end
53
+
54
+ def make(target = '')
55
+ Dir.chdir('ext') do
56
+ pid = fork { exec "#{MAKECMD} #{MAKEOPTS} #{target}" }
57
+ Process.waitpid pid
58
+ $?.exitstatus
59
+ end
60
+ end
61
+
62
+ # Let make handle dependencies between c/o/so - we'll just run it.
63
+ file 'ext/curb_core.so' => 'ext/Makefile' do
64
+ m = make
65
+ fail "Make failed (status #{m})" unless m == 0
66
+ end
67
+
68
+ desc "Compile the shared object"
69
+ task :compile => 'ext/curb_core.so'
70
+
71
+ desc "Install to your site_ruby directory"
72
+ task :install => :alltests do
73
+ m = make 'install'
74
+ fail "Make install failed (status #{m})" unless m == 0
75
+ end
76
+
77
+ # Test Tasks ---------------------------------------------------------
78
+ task :ta => :alltests
79
+ task :tu => :unittests
80
+ task :test => :unittests
81
+
82
+ if ENV['RELTEST']
83
+ announce "Release task testing - not running regression tests on alltests"
84
+ task :alltests => [:unittests]
85
+ else
86
+ task :alltests => [:unittests, :bugtests]
87
+ end
88
+
89
+ Rake::TestTask.new(:unittests) do |t|
90
+ t.test_files = FileList['tests/tc_*.rb']
91
+ t.verbose = false
92
+ end
93
+
94
+ Rake::TestTask.new(:bugtests) do |t|
95
+ t.test_files = FileList['tests/bug_*.rb']
96
+ t.verbose = false
97
+ end
98
+
99
+ #Rake::TestTask.new(:funtests) do |t|
100
+ # t.test_files = FileList['test/func_*.rb']
101
+ #t.warning = true
102
+ #t.warning = true
103
+ #end
104
+
105
+ task :unittests => :compile
106
+ task :bugtests => :compile
107
+
108
+ # RDoc Tasks ---------------------------------------------------------
109
+ desc "Create the RDOC documentation"
110
+ task :doc do
111
+ ruby "doc.rb #{ENV['DOC_OPTS']}"
112
+ end
113
+
114
+ desc "Publish the RDoc documentation to project web site"
115
+ task :doc_upload => [ :doc ] do
116
+ if ENV['RELTEST']
117
+ announce "Release Task Testing, skipping doc upload"
118
+ else
119
+ unless ENV['RUBYFORGE_ACCT']
120
+ raise "Need to set RUBYFORGE_ACCT to your rubyforge.org user name (e.g. 'fred')"
121
+ end
122
+
123
+ require 'rake/contrib/sshpublisher'
124
+ Rake::SshDirPublisher.new(
125
+ "#{ENV['RUBYFORGE_ACCT']}@rubyforge.org",
126
+ "/var/www/gforge-projects/curb",
127
+ "doc"
128
+ ).upload
129
+ end
130
+ end
131
+
132
+ # Packaging ------------------------------------------------
133
+ PKG_FILES = FileList[
134
+ 'ext/*.rb',
135
+ 'ext/*.c',
136
+ 'ext/*.h',
137
+ 'tests/**/*',
138
+ 'samples/**/*',
139
+ 'doc.rb',
140
+ '[A-Z]*',
141
+ ]
142
+
143
+ if ! defined?(Gem)
144
+ warn "Package Target requires RubyGEMs"
145
+ else
146
+ spec = Gem::Specification.new do |s|
147
+
148
+ #### Basic information.
149
+
150
+ s.name = 'curb'
151
+ s.version = PKG_VERSION
152
+ s.summary = "Ruby bindings for the libcurl(3) URL transfer library."
153
+ s.description = <<-EOF
154
+ C-language Ruby bindings for the libcurl(3) URL transfer library.
155
+ EOF
156
+ s.extensions = 'ext/extconf.rb'
157
+
158
+ #### Which files are to be included in this gem?
159
+
160
+ s.files = PKG_FILES.to_a
161
+
162
+ #### Load-time details
163
+ s.require_path = 'lib'
164
+
165
+ #### Documentation and testing.
166
+ s.has_rdoc = true
167
+ s.extra_rdoc_files = Dir['ext/*.c'] << 'ext/curb.rb' << 'README' << 'LICENSE'
168
+ s.rdoc_options <<
169
+ '--title' << 'Curb API' <<
170
+ '--main' << 'README'
171
+
172
+ s.test_files = Dir.glob('tests/tc_*.rb')
173
+
174
+ #### Author and project details.
175
+
176
+ s.author = "Ross Bamford"
177
+ s.email = "curb-devel@rubyforge.org"
178
+ s.homepage = "http://curb.rubyforge.org"
179
+ s.rubyforge_project = "curb"
180
+ end
181
+
182
+ # Quick fix for Ruby 1.8.3 / YAML bug
183
+ if (RUBY_VERSION == '1.8.3')
184
+ def spec.to_yaml
185
+ out = super
186
+ out = '--- ' + out unless out =~ /^---/
187
+ out
188
+ end
189
+ end
190
+
191
+ package_task = Rake::GemPackageTask.new(spec) do |pkg|
192
+ pkg.need_zip = true
193
+ pkg.need_tar_gz = true
194
+ pkg.package_dir = 'pkg'
195
+ end
196
+ end
197
+
198
+
199
+ # --------------------------------------------------------------------
200
+ # Creating a release
201
+ desc "Make a new release (Requires SVN commit / webspace access)"
202
+ task :release => [
203
+ :prerelease,
204
+ :clobber,
205
+ :alltests,
206
+ :update_version,
207
+ :package,
208
+ :tag,
209
+ :doc_upload] do
210
+
211
+ announce
212
+ announce "**************************************************************"
213
+ announce "* Release #{PKG_VERSION} Complete."
214
+ announce "* Packages ready to upload."
215
+ announce "**************************************************************"
216
+ announce
217
+ end
218
+
219
+ # Validate that everything is ready to go for a release.
220
+ task :prerelease do
221
+ announce
222
+ announce "**************************************************************"
223
+ announce "* Making RubyGem Release #{PKG_VERSION}"
224
+ announce "* (current version #{CURRENT_VERSION})"
225
+ announce "**************************************************************"
226
+ announce
227
+
228
+ # Is a release number supplied?
229
+ unless ENV['REL']
230
+ fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
231
+ end
232
+
233
+ # Is the release different than the current release.
234
+ # (or is REUSE set?)
235
+ if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
236
+ fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
237
+ end
238
+
239
+ # Are all source files checked in?
240
+ if ENV['RELTEST']
241
+ announce "Release Task Testing, skipping checked-in file test"
242
+ else
243
+ announce "Checking for unchecked-in files..."
244
+ data = `svn status`
245
+ unless data =~ /^$/
246
+ fail "SVN status is not clean ... do you have unchecked-in files?"
247
+ end
248
+ announce "No outstanding checkins found ... OK"
249
+ end
250
+
251
+ announce "Doc will try to use GNU cpp if available"
252
+ ENV['DOC_OPTS'] = "--cpp"
253
+ end
254
+
255
+ # Used during release packaging if a REL is supplied
256
+ task :update_version do
257
+ unless PKG_VERSION == CURRENT_VERSION
258
+ pkg_vernum = PKG_VERSION.tr('.','').sub(/^0*/,'')
259
+ pkg_vernum << '0' until pkg_vernum.length > 2
260
+
261
+ File.open('ext/curb.h.new','w+') do |f|
262
+ maj, min, mic, patch = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?/.match(PKG_VERSION).captures
263
+ f << File.read('ext/curb.h').
264
+ gsub(/CURB_VERSION\s+"(\d.+)"/) { "CURB_VERSION \"#{PKG_VERSION}\"" }.
265
+ gsub(/CURB_VER_NUM\s+\d+/) { "CURB_VER_NUM #{pkg_vernum}" }.
266
+ gsub(/CURB_VER_MAJ\s+\d+/) { "CURB_VER_MAJ #{maj}" }.
267
+ gsub(/CURB_VER_MIN\s+\d+/) { "CURB_VER_MIN #{min}" }.
268
+ gsub(/CURB_VER_MIC\s+\d+/) { "CURB_VER_MIC #{mic || 0}" }.
269
+ gsub(/CURB_VER_PATCH\s+\d+/) { "CURB_VER_PATCH #{patch || 0}" }
270
+ end
271
+ mv('ext/curb.h.new', 'ext/curb.h')
272
+ if ENV['RELTEST']
273
+ announce "Release Task Testing, skipping commiting of new version"
274
+ else
275
+ sh %{svn commit -m "Updated to version #{PKG_VERSION}" ext/curb.h}
276
+ end
277
+ end
278
+ end
279
+
280
+ # "Create a new SVN tag with the latest release number (REL=x.y.z)"
281
+ task :tag => [:prerelease] do
282
+ reltag = "curb-#{PKG_VERSION}"
283
+ reltag << ENV['REUSE'] if ENV['REUSE']
284
+ announce "Tagging SVN with [#{reltag}]"
285
+ if ENV['RELTEST']
286
+ announce "Release Task Testing, skipping SVN tagging"
287
+ else
288
+ # need to get current base URL
289
+ s = `svn info`
290
+ if s =~ /URL:\s*([^\n]*)\n/
291
+ svnroot = $1
292
+ if svnroot =~ /^(.*)\/trunk/
293
+ svnbase = $1
294
+ sh %{svn cp #{svnroot} #{svnbase}/TAGS/#{reltag} -m "Release #{PKG_VERSION}"}
295
+ else
296
+ fail "Please merge to trunk before making a release"
297
+ end
298
+ else
299
+ fail "Unable to determine repository URL from 'svn info' - is this a working copy?"
300
+ end
301
+ end
302
+ end