Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Script to detect license from TweetCC
Browse files Browse the repository at this point in the history
  • Loading branch information
singpolyma committed Mar 16, 2009
1 parent 17cefed commit 4aaaa33
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tweetcc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/ruby

require 'open-uri'

text = open('http://tweetcc.com/results/?username=' + ARGV[0]).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)
puts 'http://creativecommons.org/licenses/publicdomain/'
exit
end

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

# TWO CLAUSE

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

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

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

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

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

puts 'UNKNOWN LICENSE'

0 comments on commit 4aaaa33

Please sign in to comment.