Created
August 1, 2011 03:07
-
-
Save basicxman/1117509 to your computer and use it in GitHub Desktop.
Monitors a public Google Docs page containing source code and compiles it in C++ every five seconds. Primitive CI.
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
| #!/usr/bin/env ruby | |
| # Andrew Horsman | |
| # Monitors a Google Docs page and continuously compiles the text with Clang++. | |
| require 'net/http' | |
| require 'open-uri' | |
| class Downloader | |
| def initialize(source_url) | |
| @download_url = generate_url(source_url) | |
| @previous_content = "" | |
| puts "Monitoring on #{@download_url}" | |
| end | |
| def generate_url(source_url) | |
| sep = (0...source_url.length).find_all { |i| source_url[i] == "/" } | |
| doc_id =source_url[sep[-2] + 1 ... sep[-1]] | |
| "https://docs.google.com/feeds/download/documents/Export?docID=#{doc_id}&exportFormat=txt&format=txt" | |
| end | |
| def get_content | |
| content = `curl -L -s "#{@download_url}"`.force_encoding("ASCII").to_s[3..-1] | |
| if content != @previous_content | |
| @previous_content = content | |
| File.open("temp_compile.cpp", "w") { |f| f.print content } | |
| return true | |
| end | |
| return false | |
| end | |
| end | |
| d = Downloader.new(ARGV[0]) | |
| loop do | |
| puts "[~] Checking for changes..." | |
| if d.get_content | |
| puts "[+] Compiling..." | |
| `clang++ -stdlib=libc++ temp_compile.cpp` | |
| puts "[+] Done compiling..." | |
| end | |
| sleep(5) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment