tweetlr 0.1.7pre → 0.1.7pre4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
- data/README.md +3 -2
- data/bin/tweetlr +12 -30
- data/config/tweetlr.yml +3 -2
- data/lib/combinators/twitter_tumblr.rb +54 -0
- data/lib/log_aware.rb +3 -2
- data/lib/processors/http.rb +45 -0
- data/lib/processors/photo_service.rb +126 -0
- data/lib/processors/tumblr.rb +46 -0
- data/lib/processors/twitter.rb +44 -0
- data/lib/tweetlr.rb +49 -95
- data/spec/combinators/twitter_tumblr_combinator_spec.rb +93 -0
- data/spec/{photo_services_processor_spec.rb → processors/photo_services_processor_spec.rb} +5 -5
- data/spec/{twitter_processor_spec.rb → processors/twitter_processor_spec.rb} +17 -3
- data/spec/spec_helper.rb +24 -2
- data/spec/tweetlr_spec.rb +21 -107
- data/tweetlr.gemspec +2 -2
- metadata +29 -26
- data/lib/http_processor.rb +0 -42
- data/lib/photo_service_processor.rb +0 -122
- data/lib/tumblr_processor.rb +0 -3
- data/lib/twitter_processor.rb +0 -39
data/lib/tumblr_processor.rb
DELETED
data/lib/twitter_processor.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'http_processor'
|
2
|
-
|
3
|
-
module TwitterProcessor
|
4
|
-
|
5
|
-
#checks if the message is a retweet
|
6
|
-
def self.retweet?(message)
|
7
|
-
message.index('RT @') || message.index(%{"@}) || message.index("\u201c@") #detect retweets
|
8
|
-
end
|
9
|
-
|
10
|
-
#extract the links from a given tweet
|
11
|
-
def self.extract_links(tweet)
|
12
|
-
if tweet
|
13
|
-
text = tweet['text']
|
14
|
-
text.gsub(/https?:\/\/[\S]+/).to_a if text
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
#fire a new search
|
19
|
-
def self.search(config)
|
20
|
-
search_call = "#{config[:api_endpoint_twitter]}?ors=#{config[:search_term]}&result_type=#{config[:result_type]}&rpp=#{config[:results_per_page]}"
|
21
|
-
HttpProcessor::http_get search_call
|
22
|
-
end
|
23
|
-
|
24
|
-
# lazy update - search for a term or refresh the search if a response is available already
|
25
|
-
def self.lazy_search(config)
|
26
|
-
result = nil
|
27
|
-
refresh_url = config[:refresh_url]
|
28
|
-
log = config[:logger]
|
29
|
-
if refresh_url
|
30
|
-
search_url = "#{config[:api_endpoint_twitter]}#{refresh_url}&result_type=#{config[:result_type]}&rpp=#{config[:results_per_page]}"
|
31
|
-
log.info "lazy search using '#{search_url}'" if log
|
32
|
-
result = HttpProcessor::http_get search_url
|
33
|
-
else
|
34
|
-
log.debug "regular search using '#{config[:search_term]}'" if log
|
35
|
-
result = search(config)
|
36
|
-
end
|
37
|
-
result
|
38
|
-
end
|
39
|
-
end
|