lwr-simple 0.0.1
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/History.txt +4 -0
- data/Manifest.txt +14 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +71 -0
- data/Rakefile +28 -0
- data/lib/lwr-simple.rb +155 -0
- data/lwr-simple.gemspec +38 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/lwr-simple_spec.rb +98 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +90 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
= lwr-simple
|
2
|
+
|
3
|
+
LWR::Simple library is yet another LWP::Simple library for ruby.
|
4
|
+
|
5
|
+
== SYNOPSIS:
|
6
|
+
|
7
|
+
It is an interface that assumes the scene to which LWR::Simple is taken an active part by the one liner like begin so LWP::Simple, too.
|
8
|
+
Its interface really looks like the LWP::Simple.
|
9
|
+
|
10
|
+
# example. 1
|
11
|
+
$ ruby -rlwr-simple -e 'getprint "http://www.sn.no"'
|
12
|
+
|
13
|
+
# example. 2
|
14
|
+
$ ruby -rlwr-simple -e 'get("http://www.ruby-lang.org/ja/").scan(/<a.*href="(.+?)"/) {|refs| puts(refs[0])}'
|
15
|
+
|
16
|
+
|
17
|
+
== FEATURES:
|
18
|
+
|
19
|
+
LWR::Simple library provides 5 methods in toplevel.
|
20
|
+
* get(url)
|
21
|
+
* head(url)
|
22
|
+
* getprint(url)
|
23
|
+
* getstore(url, file)
|
24
|
+
* mirror(url, file)
|
25
|
+
|
26
|
+
All methods looks like the LWP::Simple library. Please refer to rdoc for details.
|
27
|
+
|
28
|
+
== REQUIREMENTS:
|
29
|
+
|
30
|
+
Self operation capabilities on ruby 1.8.6 or more.
|
31
|
+
Probably, it operates on ruby 1.8.3. (relation of dependence on "net/http" library.)
|
32
|
+
|
33
|
+
== INSTALL:
|
34
|
+
|
35
|
+
It is not possible to prepare it. It is only git for a while in now.
|
36
|
+
Sorry...
|
37
|
+
|
38
|
+
Install by git, see
|
39
|
+
|
40
|
+
git clone git://github.com/yagihiro/lwr-simple.git
|
41
|
+
cd lwr-simple
|
42
|
+
rake gem
|
43
|
+
rake install_gem
|
44
|
+
|
45
|
+
== LICENSE:
|
46
|
+
|
47
|
+
Copyright (c) 2008 Hiroki Yagita
|
48
|
+
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
50
|
+
a copy of this software and associated documentation files (the
|
51
|
+
'Software'), to deal in the Software without restriction, including
|
52
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
53
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
54
|
+
permit persons to whom the Software is furnished to do so, subject to
|
55
|
+
the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be
|
58
|
+
included in all copies or substantial portions of the Software.
|
59
|
+
|
60
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
61
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
62
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
63
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
64
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
65
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
66
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
67
|
+
|
68
|
+
== AUTHOR:
|
69
|
+
|
70
|
+
Hiroki Yagita <yagihiro@gmail.com>
|
71
|
+
http://d.hatena.ne.jp/clayfish/
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/lwr-simple'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('lwr-simple', LWR::Simple::VERSION) do |p|
|
7
|
+
p.developer('yagita', 'yagihiro@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
10
|
+
p.rubyforge_name = p.name # TODO this is default value
|
11
|
+
# p.extra_deps = [
|
12
|
+
# ['activesupport','>= 2.0.2'],
|
13
|
+
# ]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
|
18
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
|
+
|
27
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
28
|
+
# task :default => [:spec, :features]
|
data/lib/lwr-simple.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
#
|
2
|
+
# = lwr-simple.rb
|
3
|
+
#
|
4
|
+
# LWR::Simple library is yet another LWP::Simple library for ruby.
|
5
|
+
#
|
6
|
+
# == SYNOPSIS:
|
7
|
+
#
|
8
|
+
# It is an interface that assumes the scene to which LWR::Simple is taken an active part by the one liner like begin so LWP::Simple, too.
|
9
|
+
# Its interface really looks like the LWP::Simple.
|
10
|
+
#
|
11
|
+
# # example. 1
|
12
|
+
# $ ruby -rlwr-simple -e 'getprint "http://www.sn.no"'
|
13
|
+
#
|
14
|
+
# # example. 2
|
15
|
+
# $ ruby -rlwr-simple -e 'get("http://www.ruby-lang.org/ja/").scan(/<a.*href="(.+?)"/) {|refs| puts(refs[0])}'
|
16
|
+
#
|
17
|
+
# == FEATURES/PROBLEMS:
|
18
|
+
#
|
19
|
+
# See LWR::Simple module's documents.
|
20
|
+
#
|
21
|
+
# == LICENSE:
|
22
|
+
#
|
23
|
+
# Copyright (c) 2008 Hiroki Yagita
|
24
|
+
#
|
25
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
26
|
+
# a copy of this software and associated documentation files (the
|
27
|
+
# 'Software'), to deal in the Software without restriction, including
|
28
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
29
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
30
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
31
|
+
# the following conditions:
|
32
|
+
#
|
33
|
+
# The above copyright notice and this permission notice shall be
|
34
|
+
# included in all copies or substantial portions of the Software.
|
35
|
+
#
|
36
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
37
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
38
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
39
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
40
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
41
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
42
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
43
|
+
#
|
44
|
+
|
45
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
46
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
47
|
+
require "net/http"
|
48
|
+
require "time"
|
49
|
+
require "uri"
|
50
|
+
|
51
|
+
module LWR # :nodoc:
|
52
|
+
|
53
|
+
# This module is extend toplevel.
|
54
|
+
# So, in your application, see below example code.
|
55
|
+
#
|
56
|
+
# puts get("http://www.google.com/")
|
57
|
+
# mirror("http://www.ruby-lang.org/images/logo.gif", "logo.gif") #=> save "logo.gif" as local file.
|
58
|
+
#
|
59
|
+
module Simple
|
60
|
+
VERSION = '0.0.1'
|
61
|
+
|
62
|
+
module_function
|
63
|
+
|
64
|
+
# Fetch a resource by the given +url+, and return the resource as String.
|
65
|
+
def get url
|
66
|
+
_get(to_uri(url)).body
|
67
|
+
rescue
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get document headers - [+content_type+, +document_length+, +modified_time+, +expires+, +server+]
|
72
|
+
def head url
|
73
|
+
uri = to_uri url
|
74
|
+
req = Net::HTTP::Get.new uri.path
|
75
|
+
res = Net::HTTP.start(uri.host, uri.port) {|http| http.request(req) }
|
76
|
+
|
77
|
+
# +modified_time+ value is provisional it using +Date+ header.
|
78
|
+
[res.content_type, res.content_length, res["date"], res["expires"], res["server"]]
|
79
|
+
rescue
|
80
|
+
[]
|
81
|
+
end
|
82
|
+
|
83
|
+
# Fetch and print a resource by the given +url+.
|
84
|
+
def getprint url
|
85
|
+
uri = to_uri url
|
86
|
+
res = _get uri
|
87
|
+
puts res.body
|
88
|
+
res.code.to_i
|
89
|
+
rescue
|
90
|
+
code = 404
|
91
|
+
unless res
|
92
|
+
$stderr.puts "#{url} is bad URL."
|
93
|
+
else
|
94
|
+
code = res.code.to_i
|
95
|
+
$stderr.puts "#{url} is bad URL(#{code})."
|
96
|
+
end
|
97
|
+
code
|
98
|
+
end
|
99
|
+
|
100
|
+
# Fetch a resource by the given +url+ and save to +file+.
|
101
|
+
def getstore url, file
|
102
|
+
uri = to_uri url
|
103
|
+
res = _get uri
|
104
|
+
_store file, res.body
|
105
|
+
res.code.to_i
|
106
|
+
rescue
|
107
|
+
res ? res.code.to_i : 404
|
108
|
+
end
|
109
|
+
|
110
|
+
# Mirror a local file and a remote file method.
|
111
|
+
#
|
112
|
+
# +url+:: request target url as String.
|
113
|
+
# +file+:: mirroring file path as String.
|
114
|
+
#
|
115
|
+
# return value is http responce code.
|
116
|
+
def mirror url, file
|
117
|
+
uri = to_uri url
|
118
|
+
req = Net::HTTP::Get.new uri.path
|
119
|
+
req["If-Modified-Since"] = FileTest.exist?(file) ? File.mtime(file).httpdate : Time.at(0).httpdate
|
120
|
+
res = Net::HTTP.start(uri.host, uri.port) {|http| http.request(req) }
|
121
|
+
|
122
|
+
# if +code+ is +http not modified+, fetch the url resource.
|
123
|
+
code = res.code.to_i
|
124
|
+
_store(file, _get(uri).body) unless code == 304
|
125
|
+
|
126
|
+
code
|
127
|
+
rescue
|
128
|
+
res ? res.code.to_i : 404
|
129
|
+
end
|
130
|
+
|
131
|
+
# only internal use.
|
132
|
+
def to_uri url
|
133
|
+
uri = URI.parse url
|
134
|
+
uri.path = "/" if uri.path.empty?
|
135
|
+
uri
|
136
|
+
end
|
137
|
+
|
138
|
+
# only internal use.
|
139
|
+
def _get uri
|
140
|
+
req = Net::HTTP::Get.new uri.path
|
141
|
+
res = Net::HTTP.start(uri.host, uri.port) {|http| http.request(req) }
|
142
|
+
res
|
143
|
+
end
|
144
|
+
|
145
|
+
# only internal use.
|
146
|
+
def _store path, s
|
147
|
+
File.open(path, "wb") {|f| f.write(s) }
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
# All LWR::Simple's methods extend to Object class.
|
155
|
+
extend LWR::Simple
|
data/lwr-simple.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{lwr-simple}
|
3
|
+
s.version = "0.0.1"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["yagita"]
|
7
|
+
s.cert_chain = ["/home/yagita/.gem/gem-public_cert.pem"]
|
8
|
+
s.date = %q{2009-01-03}
|
9
|
+
s.description = %q{It is an interface that assumes the scene to which LWR::Simple is taken an active part by the one liner like begin so LWP::Simple, too. Its interface really looks like the LWP::Simple.}
|
10
|
+
s.email = ["yagihiro@gmail.com"]
|
11
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
12
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/lwr-simple.rb", "lwr-simple.gemspec", "script/console", "script/destroy", "script/generate", "spec/lwr-simple_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
13
|
+
s.has_rdoc = true
|
14
|
+
s.homepage = %q{http://github.com/yagihiro/lwr-simple/tree/master}
|
15
|
+
s.post_install_message = %q{PostInstall.txt}
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{lwr-simple}
|
19
|
+
s.rubygems_version = %q{1.2.0}
|
20
|
+
s.signing_key = %q{/home/yagita/.gem/gem-private_key.pem}
|
21
|
+
s.summary = %q{LWR::Simple library is yet another LWP::Simple library for ruby.}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 2
|
26
|
+
|
27
|
+
if current_version >= 3 then
|
28
|
+
s.add_development_dependency(%q<newgem>, [">= 1.2.1"])
|
29
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<newgem>, [">= 1.2.1"])
|
32
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<newgem>, [">= 1.2.1"])
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
37
|
+
end
|
38
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/lwr-simple.rb'}"
|
9
|
+
puts "Loading lwr-simple gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
def successed? code
|
4
|
+
200 <= code and code < 400
|
5
|
+
end
|
6
|
+
|
7
|
+
# This spec quotes from the LWP::Simple documents.
|
8
|
+
describe LWR::Simple do
|
9
|
+
|
10
|
+
describe "get()" do
|
11
|
+
it "should be going to fetch the document identified by the given URL and return it." do
|
12
|
+
doc = LWR::Simple.get("http://www.google.com/")
|
13
|
+
doc.should_not be_nil
|
14
|
+
doc.should_not be_empty
|
15
|
+
doc.should be_an_instance_of(String)
|
16
|
+
doc.should match(/google/)
|
17
|
+
end
|
18
|
+
it "should nil if this method fails." do
|
19
|
+
LWR::Simple.get("http://www.notexists.com/").should be_nil
|
20
|
+
end
|
21
|
+
it "should URL argument can be either a String's instance." do
|
22
|
+
LWR::Simple.get(nil).should be_nil
|
23
|
+
LWR::Simple.get(URI("http://www.google.com/")).should be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "head()" do
|
28
|
+
it "should get document headers. Returns the following 5 values if successful: ($content_type, $document_length, $modified_time, $expires, $server)" do
|
29
|
+
h = LWR::Simple.head("http://www.google.com/")
|
30
|
+
h.should_not be_nil
|
31
|
+
h.should_not be_empty
|
32
|
+
h.should be_an_instance_of(Array)
|
33
|
+
h.should have(5).items
|
34
|
+
end
|
35
|
+
it "should returns an empty list if this method fails." do
|
36
|
+
LWR::Simple.head("http://www.notexists.com/").should have(0).items
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "getprint()" do
|
41
|
+
before do
|
42
|
+
@stdout = $>
|
43
|
+
@stderr = $stderr
|
44
|
+
end
|
45
|
+
after do
|
46
|
+
$> = @stdout
|
47
|
+
$stderr = @stderr
|
48
|
+
end
|
49
|
+
it "should get and print a document identified by a URL. The document is printed to the selected default filehandle for output (normally STDOUT) as data is received from the network." do
|
50
|
+
m = mock("out")
|
51
|
+
m.should_receive(:write) do |arg|
|
52
|
+
# +arg+ is printed a document as String instance.
|
53
|
+
arg.should be_an_instance_of(String)
|
54
|
+
arg.should_not be_empty
|
55
|
+
end
|
56
|
+
$> = m
|
57
|
+
code = LWR::Simple.getprint("http://www.google.com/")
|
58
|
+
successed?(code).should be_true
|
59
|
+
end
|
60
|
+
it "should if the request fails, then the status code and message are printed on STDERR. The return value is the HTTP response code." do
|
61
|
+
m = mock("err")
|
62
|
+
m.should_receive(:write).any_number_of_times # $stderr object requires #write method. (In fact, it is not called.)
|
63
|
+
m.should_receive(:puts) do |arg|
|
64
|
+
# +arg+ is printed a document as String instance.
|
65
|
+
arg.should be_an_instance_of(String)
|
66
|
+
arg.should_not be_empty
|
67
|
+
end
|
68
|
+
$stderr = m
|
69
|
+
LWR::Simple.getprint("http://www.notexists.com/").should == 404
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "getstore()" do
|
74
|
+
after do
|
75
|
+
File.delete("g.html") if FileTest.exist?("g.html")
|
76
|
+
end
|
77
|
+
it "should gets a document identified by a URL and stores it in the file. The return value is the HTTP response code." do
|
78
|
+
code = LWR::Simple.getstore("http://www.google.com/", "g.html")
|
79
|
+
File.open("g.html") {|f| f.read.should match(/google/) }
|
80
|
+
successed?(code).should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "mirror()" do
|
85
|
+
after do
|
86
|
+
File.delete("logo.gif") if FileTest.exist?("logo.gif")
|
87
|
+
end
|
88
|
+
it "should get and store a document identified by a URL, using If-modified-since, and checking the Content-Length. Returns the HTTP response code." do
|
89
|
+
code = LWR::Simple.mirror("http://www.ruby-lang.org/images/logo.gif", "logo.gif")
|
90
|
+
FileTest.exist?("logo.gif").should be_true
|
91
|
+
successed?(code).should be_true
|
92
|
+
code = LWR::Simple.mirror("http://www.ruby-lang.org/images/logo.gif", "logo.gif")
|
93
|
+
FileTest.exist?("logo.gif").should be_true
|
94
|
+
successed?(code).should be_true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lwr-simple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yagita
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-03 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
35
|
+
description: ""
|
36
|
+
email:
|
37
|
+
- yagihiro@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- PostInstall.txt
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- History.txt
|
49
|
+
- Manifest.txt
|
50
|
+
- PostInstall.txt
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- lib/lwr-simple.rb
|
54
|
+
- lwr-simple.gemspec
|
55
|
+
- script/console
|
56
|
+
- script/destroy
|
57
|
+
- script/generate
|
58
|
+
- spec/lwr-simple_spec.rb
|
59
|
+
- spec/spec.opts
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- tasks/rspec.rake
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: LWR::Simple library is yet another LWP::Simple library for ruby.
|
64
|
+
post_install_message: PostInstall.txt
|
65
|
+
rdoc_options:
|
66
|
+
- --main
|
67
|
+
- README.rdoc
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: lwr-simple
|
85
|
+
rubygems_version: 1.2.0
|
86
|
+
signing_key:
|
87
|
+
specification_version: 2
|
88
|
+
summary: ""
|
89
|
+
test_files: []
|
90
|
+
|