Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for full_text in tweets; resolve #192. #252

Merged
merged 2 commits into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/scala/io/archivesunleashed/util/TweetUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ object TweetUtils {
def createdAt(): String = try { (tweet \ "created_at").extract[String] } catch { case e: Exception => ""}
/** Get the status text. */
def text(): String = try { (tweet \ "text").extract[String] } catch { case e: Exception => ""}
/** Get the full_text. */
def fullText(): String = try { (tweet \ "full_text").extract[String] } catch { case e: Exception => ""}
/** Get the language code (ISO 639-1). */
def lang: String = try { (tweet \ "lang").extract[String] } catch { case e: Exception => ""}
/** Get the username of the user who wrote the status. */
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TweetUtilsTest extends FunSuite {
var tweet:org.json4s.JValue = parse("""{"id_str":"123",
"created_at":"20150702",
"text": "some text",
"full_text": "some full text",
"lang": "en",
"user": {
"screen_name": "twitteruser",
Expand All @@ -42,6 +43,7 @@ class TweetUtilsTest extends FunSuite {
assert(tweet.id() == "123")
assert(tweet.createdAt() == "20150702")
assert(tweet.text() == "some text")
assert(tweet.fullText() == "some full text")
assert(tweet.lang == "en")
assert(tweet.username() == "twitteruser")
assert(tweet.isVerifiedUser())
Expand All @@ -53,6 +55,7 @@ class TweetUtilsTest extends FunSuite {
var tweet:org.json4s.JValue = parse("""{"id_str": null,
"created_at":null,
"text": null,
"full_text": null,
"lang": null,
"user": {
"screen_name": null,
Expand All @@ -64,6 +67,7 @@ class TweetUtilsTest extends FunSuite {
assert(tweet.id() == null)
assert(tweet.createdAt() == null)
assert(tweet.text() == null)
assert(tweet.fullText() == null)
assert(tweet.lang == null)
assert(tweet.username() == null)
assert(!tweet.isVerifiedUser())
Expand Down