Skip to content

Commit

Permalink
New timeline spec based on S-expression is introduced.
Browse files Browse the repository at this point in the history
  • Loading branch information
cvmat committed Jan 3, 2010
1 parent b6b4d81 commit 03db7c3
Show file tree
Hide file tree
Showing 3 changed files with 369 additions and 131 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
Expand Up @@ -11,6 +11,31 @@
receive its value and `twittering-new-tweets-hook' works
correctly.

2010-01-03 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el, test/test-twittering-mode.el: rebase the
`timeline-spec' branch. The new timeline spec based on
S-expression is introduced.

* twittering-mode.el (twittering-timeline-spec-to-string): add.
(twittering-extract-timeline-spec): add.
(twittering-string-to-timeline-spec): add.
(twittering-timeline-spec-singlep): add.
(twittering-timeline-spec-to-host-method): add.
(twittering-host-method-to-timeline-spec): add.
(twittering-last-timeline-spec): add.
(twittering-last-timeline-spec-string)
(twittering-add-timeline-history): modified for new timeline spec.
(twittering-update-mode-line): modified for new timeline spec.
(twittering-get-twits-with-timeline-spec): modified for new
timeline spec.
(twittering-read-timeline-spec-string-with-completion): add.
(twittering-read-timeline-spec-with-completion): modified for new
timeline spec.

* test/test-twittering-mode.el (timeline-spec): add tests for new
timeline spec.

2010-01-02 Satoshi Yatagawa <yata_github@y.hauN.org>

* twittering-mode.el (twittering-use-show-minibuffer-length): New
Expand Down
106 changes: 48 additions & 58 deletions test/test-twittering-mode.el
Expand Up @@ -147,65 +147,55 @@
'(("%" . "\n"))))
)

(defun test-restore-timeline-spec(spec-str spec)
(let ((normalized-spec
(twittering-string-to-timeline-spec
(twittering-timeline-spec-to-string spec)))
(spec-from-str
(twittering-string-to-timeline-spec spec-str)))
(equal normalized-spec spec-from-str)))

(defcase timeline-spec nil nil
(defun test-restore-timeline-spec(spec)
(string-equal
spec
(apply 'twittering-get-timeline-spec
(twittering-get-host-method-from-timeline-spec spec))))
(defun test-restore-host-method(host method)
(equal (list host method)
(twittering-get-host-method-from-timeline-spec
(twittering-get-timeline-spec host method))))
(test-assert-ok (test-restore-timeline-spec "~"))
(test-assert-ok (test-restore-timeline-spec "@"))
(test-assert-ok (test-restore-timeline-spec "M"))
(test-assert-ok (test-restore-timeline-spec "-"))
(test-assert-ok (test-restore-timeline-spec "USER"))
(test-assert-ok (test-restore-timeline-spec "USER/LISTNAME"))
(test-assert-ok (test-restore-timeline-spec "H"))
(test-assert-ok (test-restore-timeline-spec "B"))
(test-assert-ok (test-restore-timeline-spec "T"))
(test-assert-ok (test-restore-timeline-spec "O"))

(test-assert-eq nil (twittering-get-host-method-from-timeline-spec ""))

(test-assert-ok
(test-restore-host-method
"twitter.com" "statuses/friends_timeline"))
(test-assert-ok
(test-restore-host-method
"twitter.com" "statuses/replies"))
(test-assert-ok
(test-restore-host-method
"twitter.com" "statuses/mentions"))
(test-assert-ok
(test-restore-host-method
"twitter.com" "statuses/public_timeline"))
(test-assert-ok
(test-restore-host-method
"twitter.com" "statuses/user_timeline/USER"))
(test-assert-ok
(test-restore-host-method
"api.twitter.com" "1/USER/lists/LISTNAME/statuses"))
(test-assert-ok
(test-restore-host-method
"api.twitter.com" "1/statuses/home_timeline"))
(test-assert-ok
(test-restore-host-method
"api.twitter.com" "1/statuses/retweeted_by_me"))
(test-assert-ok
(test-restore-host-method
"api.twitter.com" "1/statuses/retweeted_to_me"))
(test-assert-ok
(test-restore-host-method
"api.twitter.com" "1/statuses/retweets_of_me"))

(test-assert-string-equal
"USERNAME"
(let ((twittering-username-active "USERNAME"))
(twittering-get-timeline-spec
"twitter.com" "statuses/user_timeline")))
(test-assert-equal
(test-restore-timeline-spec
"(user+(user/mylist+(@))+:filter/WORD/(USER2+:mentions))"
'(merge (user "user")
(merge (list "user" "mylist")
(merge (replies)))
(filter "WORD" (merge (user "USER2")
(mentions)))))
t)
(test-assert-equal
(test-restore-timeline-spec
"(user-A+~+((user-B))+(:filter/R+/user-C+(:filter/R3\\//USER-D+:public)))"
'(merge (user "user-A")
(home)
(merge (user "user-B")
(filter "R+" (user "user-C")))
(filter "R3/" (user "USER-D"))
(public)))
t)

(test-assert-equal
(test-restore-timeline-spec
":filter/ABC/user/mylist"
'(filter "ABC" (list "user" "mylist")))
t)
(test-assert-equal
(test-restore-timeline-spec
":filter/ABC\\/user/mylist"
'(filter "ABC/user" (user "mylist")))
t)

(test-assert-equal
(test-restore-timeline-spec ":retweeted_by_me" '(retweeted_by_me))
t)
(test-assert-equal
(test-restore-timeline-spec ":retweeted_to_me" '(retweeted_to_me))
t)
(test-assert-equal
(test-restore-timeline-spec ":retweets_of_me" '(retweets_of_me))
t)
)

(lexical-let ((status (car (get-fixture 'timeline-data))))
Expand Down

0 comments on commit 03db7c3

Please sign in to comment.