Last active
August 29, 2015 14:10
-
-
Save kyonmm/04d76fdff0e097509982 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package org.kyonmm.webapi | |
| import groovy.sql.Sql | |
| import org.junit.Test | |
| import java.sql.Date | |
| class Select { | |
| @Test | |
| void selectFromENEX(){ | |
| def doc = Jsoup.parse(new File("./201411-51.enex").getText("utf-8")) | |
| def contents = [] | |
| for(note in Selector.select("note", doc)){ | |
| contents << note.getElementsByTag("source-url").eq(0).text() | |
| } | |
| println "# 週刊ソフトウェアテスト 2014-${Calendar.instance.get(Calendar.WEEK_OF_YEAR)}" | |
| println "# Summary" | |
| println "\n\n" | |
| println "<!-- more -->" | |
| println "# News" | |
| contents.findAll{!isTwitter(it) && !isAmazon(it) && !isEvent(it) && !isSlide(it)}.sort().each{ println "[${it}:embed]" } | |
| println "\n\n" | |
| println "# Tool, Language" | |
| println "\n\n" | |
| println "# New Books" | |
| contents.findAll{isAmazon(it)}.sort().each{ println "[asin:${it.replaceAll(".+/dp/", "")}:detail]" } | |
| println "\n\n" | |
| println "# Event" | |
| contents.findAll{isEvent(it)}.sort().each{ println "[${it}:embed]" } | |
| println "\n\n" | |
| println "# Slide" | |
| contents.findAll{isSlide(it)}.sort().each{ println "[${it}:embed]" } | |
| println "\n\n" | |
| println "# Twitter" | |
| contents.findAll{isTwitter(it)}.sort().each{ println "[${it}:embed]"} | |
| } | |
| boolean isTwitter(content){ | |
| content.contains("twitter.com") | |
| } | |
| boolean isAmazon(content){ | |
| content.contains("amazon.co.jp") | |
| } | |
| boolean isEvent(content){ | |
| ["connpass", "doorkeeper", "atnd", "kokucheese"].any{content.contains(it)} | |
| } | |
| boolean isSlide(content){ | |
| ["slideshare", "speakerdeck"].any{content.contains(it)} | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment