Skip to content

Commit cda286b

Browse files
committed
re-organization, private methods
1 parent c86024c commit cda286b

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Clojure-Websockets/src/clj/birdwatch/data.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:gen-class)
33
(require [clojure.pprint :as pp]))
44

5-
(defn rt-status-reducer [sym]
5+
(defn- rt-status-reducer [sym]
66
(fn [acc val]
77
"get map with all items that contain a :retweeted_status. key :id_str value sym called on elem"
88
(let [rt (:retweeted_status val)
@@ -11,7 +11,7 @@
1111
(assoc acc (:id_str rt) (sym rt))
1212
acc))))
1313

14-
(defn reduce-res [f acc coll]
14+
(defn- reduce-res [f acc coll]
1515
"reduce result vector with reducer function f, acc and elem into map"
1616
(reduce f acc coll))
1717

Clojure-Websockets/src/clj/birdwatch/persistence.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"get total count of indexed tweets from ElasticSearch"
2727
(esd/count conn (:es-index conf) "tweet"))
2828

29-
(defn strip-tweet [t]
29+
(defn- strip-tweet [t]
3030
"take only actually needed fields from tweet"
3131
(let [u (:user t)]
3232
{:id_str (:id_str t)
@@ -41,7 +41,7 @@
4141
:profile_image_url (:profile_image_url u)
4242
:screen_name (:screen_name u)}}))
4343

44-
(defn strip-source [val]
44+
(defn- strip-source [val]
4545
"get tweet stripped down to necessary fields"
4646
(let [s (:_source val)
4747
t (strip-tweet s)

Clojure-Websockets/src/clj/birdwatch/twitterclient.clj

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
(:user-access-token conf) (:user-access-token-secret conf)))
2525

2626
;; channels
27-
(def chunk-chan (chan 10000))
28-
(def msg-chan (chan))
27+
(def ^:private chunk-chan (chan 10000))
28+
(def ^:private msg-chan (chan))
2929

3030
;; atoms for keeping track of counts, incomplete chunk and last received timestamp
31-
(def last-received (atom (t/epoch)))
32-
(def chunk-buff (atom ""))
33-
(def counter (atom 0))
31+
(def ^:private last-received (atom (t/epoch)))
32+
(def ^:private chunk-buff (atom ""))
33+
(def ^:private counter (atom 0))
3434

35-
(defn parse [str]
35+
(defn- parse [str]
3636
(try
3737
(let [c @counter
3838
json (json/read-json str)]
@@ -74,9 +74,9 @@
7474

7575
;; streaming connection with Twitter stored in an Atom, can be started and stopped using
7676
;; using the start-twitter-conn! and stop-twitter-conn! functions
77-
(def twitter-conn (atom {}))
77+
(def ^:private twitter-conn (atom {}))
7878

79-
(defn stop-twitter-conn! []
79+
(defn- stop-twitter-conn! []
8080
"stop connection to Twitter Streaming API"
8181
(let [m (meta @twitter-conn)]
8282
(when m

Clojure-Websockets/src/cljs/birdwatch/util.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919
(let [time-string (. (js/moment. date) (fromNow true))]
2020
(if (= time-string "a few seconds") "just now" time-string)))
2121

22-
(defn url-replacer [acc entity]
22+
(defn- url-replacer [acc entity]
2323
"replace URL occurences in tweet texts with HTML (including links)"
2424
(s/replace acc (:url entity)
2525
(str "<a href='" (:url entity) "' target='_blank'>" (:display_url entity) "</a>")))
2626

27-
(defn hashtags-replacer [acc entity]
27+
(defn- hashtags-replacer [acc entity]
2828
"replace hashtags in tweet text with HTML (including links)"
2929
(let [hashtag (:text entity)]
3030
(s/replace acc (str "#" hashtag)
3131
(str "<a href='https://twitter.com/search?q=%23" hashtag "' target='_blank'>#" hashtag "</a>"))))
3232

33-
(defn mentions-replacer [acc entity]
33+
(defn- mentions-replacer [acc entity]
3434
"replace user mentions in tweet text with HTML (including links)"
3535
(let [screen-name (:screen_name entity)]
3636
(s/replace acc (str "@" screen-name)
3737
(str "<a href='http://www.twitter.com/" screen-name "' target='_blank'>@" screen-name "</a>"))))
3838

39-
(defn reducer [text coll fun]
39+
(defn- reducer [text coll fun]
4040
"generic reducer, allowing to call specified function for each item in collection"
4141
(reduce fun text coll))
4242

0 commit comments

Comments
 (0)