arbarlow-rubycurl 1.7.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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +46 -0
- data/Rakefile +55 -0
- data/lib/rubycurl.rb +43 -0
- data/rubycurl.gemspec +50 -0
- data/test/rubycurl_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/version.yml +4 -0
- metadata +64 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 arbarlow
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= RubyCurl
|
2
|
+
|
3
|
+
Authlogic is a simple way of getting html, xml or other text based files, into a variable, quick.
|
4
|
+
|
5
|
+
|
6
|
+
= Install
|
7
|
+
|
8
|
+
To install RubyCurl simply..
|
9
|
+
|
10
|
+
gem sources -a http://gems.github.com (you only have to do this once)
|
11
|
+
sudo gem install arbarlow-rubycurl
|
12
|
+
|
13
|
+
|
14
|
+
=Simple Get
|
15
|
+
|
16
|
+
In your controller..
|
17
|
+
|
18
|
+
@curl = RubyCurl.new('http://github.com')
|
19
|
+
|
20
|
+
In your view..
|
21
|
+
|
22
|
+
<%= @curl.body %>
|
23
|
+
|
24
|
+
Even more simply, in your view just put
|
25
|
+
|
26
|
+
<%= RubyCurl.new('http://github.com').body %>
|
27
|
+
|
28
|
+
|
29
|
+
=Posting A Form
|
30
|
+
|
31
|
+
RubyCurl.post({'username' => 'arbarlow','password' => 'arbarlowpassword'}, 'http://example.com' )
|
32
|
+
|
33
|
+
|
34
|
+
=Get With HTTP Authentication
|
35
|
+
|
36
|
+
@curl = RubyCurl.auth ('username', 'password', "http://twitter.com/statuses/friends_timeline.xml" )
|
37
|
+
|
38
|
+
|
39
|
+
=Post With HTTP Authentication
|
40
|
+
|
41
|
+
RubyCurl.post_with_auth({'username' => 'yourusername', 'password' => 'yourpassword'}, {'param1' => 'param1text','param2' => 'param2text'}, 'http://example.com' )
|
42
|
+
|
43
|
+
|
44
|
+
=Summary
|
45
|
+
|
46
|
+
Thats it really, nothing special.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rubycurl"
|
8
|
+
gem.summary = %Q{Easy use of curl for getting html, xml, etc}
|
9
|
+
gem.description = %Q{Easy use of curl for getting html, xml, etc}
|
10
|
+
gem.email = "alexbarlowis@me.com"
|
11
|
+
gem.homepage = "http://github.com/arbalrow/rubycurl/"
|
12
|
+
gem.authors = ["arbarlow"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :test => :check_dependencies
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
if File.exist?('VERSION')
|
46
|
+
version = File.read('VERSION')
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "rubycurl #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/lib/rubycurl.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
class RubyCurl
|
2
|
+
|
3
|
+
# Takes url and returns result with .body and follows redirect if any.
|
4
|
+
#
|
5
|
+
# Example RubyCurl.new ('http://apple.com')
|
6
|
+
def initialize(url)
|
7
|
+
@result = %x"curl #{url} -L"
|
8
|
+
end
|
9
|
+
|
10
|
+
# Takes username, password, url , then returns result and follows redirect if any.
|
11
|
+
#
|
12
|
+
# Example RubyCurl.auth ('username', 'password', "http://twitter.com/statuses/friends_timeline.xml" )
|
13
|
+
def self.auth(username, password, url)
|
14
|
+
@result = %x"curl -u #{username}:#{password} #{url} -L"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Uses HTTP post to post a form using params and returns the html, text or xml and follows redirect if any.
|
18
|
+
#
|
19
|
+
# Example RubyCurl.post({'param1' => 'param1text','param2' => 'param2text'}, 'http://example.com' )
|
20
|
+
def self.post(params, url)
|
21
|
+
curlparam = ""
|
22
|
+
params.each_pair {|key, value| curlparam << "#{key}=#{value}" }
|
23
|
+
@result = %x"curl -d #{curlparam} #{url} -L"
|
24
|
+
end
|
25
|
+
|
26
|
+
#Uses HTTP post to post a form using params and authentication
|
27
|
+
#
|
28
|
+
# Example RubyCurl.post_with_auth({'username' => 'yourusername', 'password' => 'yourpassword'}, {'param1' => 'param1text','param2' => 'param2text'}, 'http://example.com' )
|
29
|
+
def self.post_with_auth(auth, params, url)
|
30
|
+
curlparam = ""
|
31
|
+
params.each_pair {|key, value| curlparam << "#{key}=#{value}" }
|
32
|
+
@result = %x"curl -u #{auth['username']:auth['password']} -d #{curlparam} #{url} -L"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns result of .new in string
|
36
|
+
#
|
37
|
+
# Example @test = RubyCurl.new ('http://apple.com')
|
38
|
+
# puts @test.body
|
39
|
+
def body
|
40
|
+
"#{@result}"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/rubycurl.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rubycurl}
|
8
|
+
s.version = "1.7.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["arbarlow"]
|
12
|
+
s.date = %q{2009-09-08}
|
13
|
+
s.description = %q{Easy use of curl for getting html, xml, etc}
|
14
|
+
s.email = %q{alexbarlowis@me.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"lib/rubycurl.rb",
|
26
|
+
"rubycurl.gemspec",
|
27
|
+
"test/rubycurl_test.rb",
|
28
|
+
"test/test_helper.rb",
|
29
|
+
"version.yml"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/arbalrow/rubycurl/}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.5}
|
35
|
+
s.summary = %q{Easy use of curl for getting html, xml, etc}
|
36
|
+
s.test_files = [
|
37
|
+
"test/rubycurl_test.rb",
|
38
|
+
"test/test_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
data/test/test_helper.rb
ADDED
data/version.yml
ADDED
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arbarlow-rubycurl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- arbarlow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-08 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Easy use of curl for getting html, xml, etc
|
17
|
+
email: alexbarlowis@me.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- lib/rubycurl.rb
|
32
|
+
- rubycurl.gemspec
|
33
|
+
- test/rubycurl_test.rb
|
34
|
+
- test/test_helper.rb
|
35
|
+
- version.yml
|
36
|
+
has_rdoc: false
|
37
|
+
homepage: http://github.com/arbalrow/rubycurl/
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --charset=UTF-8
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
requirements: []
|
56
|
+
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.2.0
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Easy use of curl for getting html, xml, etc
|
62
|
+
test_files:
|
63
|
+
- test/rubycurl_test.rb
|
64
|
+
- test/test_helper.rb
|