File: fetch_yts.rb

package info (click to toggle)
libyaml-ruby 0.49.1-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 536 kB
  • ctags: 679
  • sloc: ruby: 7,945; makefile: 38; sh: 1
file content (18 lines) | stat: -rw-r--r-- 551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# fetch_yts.rb (assumes Ruby >= 1.7.3)
require 'net/http'
require 'uri' 
require 'cgi'
   
wiki   = 'http://wiki.yaml.org/yamlwiki' 
index  = "#{wiki}/YamlTestingSuiteIndex" 
    
Net::HTTP::get(URI::parse(index)).scan(/"\/yamlwiki\/(Yts.*?)"/) do |yts|
    puts "Fetching #{yts[0]}" 
    data = Net::HTTP::get URI::parse("#{wiki}/#{yts[0]}")
    if data =~ /<pre.*?>(.*?)\n<\/pre>/mi
        File::open(yts[0], 'w'){ |file| file.puts CGI::unescapeHTML( $1 ).gsub( / $/, '' ) } 
    else
        puts "** Invalid content in #{yts[0]} **"
    end
end