Last active
December 18, 2015 00:38
-
-
Save fourdollars/5698033 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require! 'http' | |
url = 'http://ppa.launchpad.net/fourdollars/fglrx/ubuntu/dists/oneiric/main/binary-amd64/Packages' | |
parse = (data) -> | |
lines = data.split "\n" | |
for line in lines | |
if line.match /^Package/ | |
pkg = line.split /\s+/ .[1] | |
else if line.match /^Version/ | |
ver = line.split /\s+/ .[1] | |
else if line.match /^Modaliases/ | |
modaliases = line.split /\s+/ .splice 1 .join '' | |
rePattern = new RegExp /^([^(]*)\((.*)\)$/ | |
arrMatches = modaliases.match rePattern | |
console.log pkg + " " + ver + " " + arrMatches[1] | |
for item in arrMatches[2].split /,/ | |
console.log item | |
http.get url, (res) -> | |
content = '' | |
console.log "statusCode: " res.statusCode | |
res.on 'data' (data) -> | |
content += data | |
.on 'end' -> | |
parse content | |
.on 'error' (err) -> | |
console.log err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment