Created
December 7, 2011 04:48
-
-
Save osima/1441506 to your computer and use it in GitHub Desktop.
fetch code from gist using groovy
This file contains 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
// | |
// fetch code from gist using groovy | |
// | |
@Grab(group='commons-httpclient', module='commons-httpclient', version='3.1') | |
import org.apache.commons.httpclient.* | |
import org.apache.commons.httpclient.methods.* | |
def encoding = 'UTF-8' | |
def gistId='1174714' | |
def filename='main.xml' | |
def gistUrl="http://gist.github.com/raw/${gistId}/${filename}" | |
def hc = new HttpClient() | |
def method = new GetMethod( gistUrl ) | |
hc.executeMethod( method ) | |
def reader = new InputStreamReader( method.getResponseBodyAsStream(), encoding ) | |
def r = reader.text | |
reader.close() | |
method.releaseConnection() | |
println r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment