takkaw (owner)

Revisions

gist: 164586 Download_button fork
public
Public Clone URL: git://gist.github.com/164586.git
Embed All Files: show embed
getrfc.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'open-uri'
require 'optparse'
 
url = 'http://www.ietf.org/rfc/'
pager = ENV['PAGER'] || 'less'
force_get = false
 
opts = OptionParser.new
opts.on("-f"){ force_get = true }
opts.parse!(ARGV)
 
rfc = "rfc" + ARGV.shift + ".txt"
 
get = false
get = true unless File.exist? rfc
get = true if force_get
 
if get
  File.open(rfc,'w') { |f|
f.write open(url+rfc,'r').read
  }
end
 
system "#{pager} #{rfc}"