Created
May 19, 2014 18:54
-
-
Save 166MMX/9ef61c2685bc6c6dc1c2 to your computer and use it in GitHub Desktop.
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
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1') | |
import groovy.json.JsonSlurper | |
import groovyx.net.http.URIBuilder | |
def url = buildUrl() | |
def firstHashCode = fetch(url) | |
def tenMinutesAsMicroseconds = 10 * 60 * 60 * 1000 | |
for (;firstHashCode == fetch(url);) | |
{ | |
println 'Result unchanged; retrying in 10 minutes' | |
sleep(tenMinutesAsMicroseconds) | |
} | |
println 'Result changed; exiting' | |
static URL buildUrl () | |
{ | |
def builder = new URIBuilder('http://search.maven.org/') | |
builder.path = 'solrsearch/select' | |
builder.query = [ | |
'q': 'g:"org.codehaus.groovy" AND a:"groovy"', | |
'core': 'gav', | |
'rows': 200, | |
'wt': 'json' | |
] | |
builder.toString().toURL() | |
} | |
static int fetch (URL url) | |
{ | |
def data = url.text | |
def json = new JsonSlurper().parseText(data) | |
HashMap response = json.response | |
response.hashCode() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment