Skip to content

Instantly share code, notes, and snippets.

@lei-clearsky
Created September 26, 2013 14:31
Show Gist options
  • Select an option

  • Save lei-clearsky/6715041 to your computer and use it in GitHub Desktop.

Select an option

Save lei-clearsky/6715041 to your computer and use it in GitHub Desktop.

Revisions

  1. lei-clearsky created this gist Sep 26, 2013.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    def get_from_digg
    res = JSON.load(RestClient.get('http://digg.com/api/news/popular.json'))
    res["data"]["feed"].map do |story|
    s = {}
    tags = []
    s[:title] = story["content"]["title"]
    story["content"]["tags"].map do |tag|
    tags << tag["display"]
    end
    s[:category] = tags.join(", ")
    calculate_upvotes s
    puts show_new_story(s)
    end
    end