Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 50 lines (35 sloc) 1.379 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/ruby

require 'open-uri'

def tweetcc(user)

text = open('http://tweetcc.com/results/?username=' + user).read.scan(/<blockquote[^\f]+?<\/blockquote>/)[0]
attribution = text =~ /Attribution/i
sharealike = text =~ /ShareAlike/i
noncommercial = text =~ /NonCommercial/i
noderivs = text =~ /NoDerivs/i
pd = text =~ /Public Domain/i

# ONE CLAUSE

if pd && (!attribution && !sharealike && !noncommercial && !noderivs)
return 'http://creativecommons.org/licenses/publicdomain/'
end

if attribution && (!pd && !sharealike && !noncommercial && !noderivs)
return 'http://creativecommons.org/licenses/by/3.0/'
end

# TWO CLAUSE

if attribution && sharealike && (!pd && !noncommercial && !noderivs)
return 'http://creativecommons.org/licenses/by-sa/3.0/'
end

if attribution && noncommercial && (!pd && !sharealike && !noderivs)
return 'http://creativecommons.org/licenses/by-nc/3.0/'
end

if attribution && noderivs && (!pd && !sharealike && !noncommercial)
return 'http://creativecommons.org/licenses/by-nc/3.0/'
end

# THREE CLAUSE
if attribution && noncommercial && sharealike && (!pd && !noncommercial)
return 'http://creativecommons.org/licenses/by-nc-nd/3.0/'
end

if attribution && noncommercial && noderivs && (!pd && !sharealike)
return 'http://creativecommons.org/licenses/by-nc-nd/3.0/'
end

return 'http://twitter.com/tos'

end
Something went wrong with that request. Please try again.