tweetlr 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/Rakefile +1 -1
- data/bin/tweetlr +19 -18
- data/lib/tweetlr.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -27,9 +27,11 @@ It's essential that you have a directory called `config` in the directory you ar
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
Make sure you put the configuration file in it's proper place as
|
30
|
+
Make sure you put the configuration file in it's proper place as mentioned above, then:
|
31
31
|
|
32
32
|
start/stop tweetlr using `tweetlr start`/`tweetlr stop`. Run `tweetlr` without arguments for a list of options concerning the daemon's options.
|
33
33
|
|
34
|
-
|
34
|
+
For further details on the configuration part, check out the [tweetlr_demo](http://github.com/5v3n/tweetlr_demo).
|
35
|
+
|
36
|
+
Enjoy!
|
35
37
|
|
data/Rakefile
CHANGED
data/bin/tweetlr
CHANGED
@@ -8,40 +8,41 @@ require_relative '../lib/tweetlr.rb'
|
|
8
8
|
|
9
9
|
begin
|
10
10
|
config_file = File.join( Dir.pwd, 'config', 'tweetlr.yml')
|
11
|
+
@log_file = File.join( Dir.pwd, 'tweetlr.log')
|
11
12
|
CONFIG = YAML.load_file(config_file)
|
12
13
|
TERM = CONFIG['search_term']
|
13
14
|
USER = CONFIG['tumblr_username']
|
14
15
|
PW = CONFIG['tumblr_password']
|
15
16
|
TIMESTAMP = CONFIG['twitter_timestamp']
|
16
17
|
UPDATE_PERIOD = CONFIG['update_period']
|
18
|
+
@tweetlr = Tweetlr.new(USER, PW, nil, TIMESTAMP, TERM, config_file)
|
17
19
|
rescue SystemCallError
|
18
20
|
$stderr.puts "Ooops - looks like there is no ./config/tweetlr.yml found. I'm affraid tweetlr won't work properly until you introduced that configuration file."
|
19
21
|
exit(1)
|
20
22
|
end
|
21
23
|
|
22
24
|
Daemons.run_proc('tweetlr') do
|
23
|
-
@log = Logger.new(
|
25
|
+
@log = Logger.new(@log_file)
|
24
26
|
@log.info('starting tweetlr daemon...')
|
25
|
-
@log.info "
|
27
|
+
@log.info "creating a new tweetlr instance using this config: #{CONFIG.inspect}"
|
26
28
|
EventMachine::run {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@log.debug tweetlr.post_to_tumblr tumblr_post
|
40
|
-
end
|
29
|
+
EventMachine::add_periodic_timer( UPDATE_PERIOD ) {
|
30
|
+
@log.info('starting tweetlr crawl...')
|
31
|
+
response = @tweetlr.lazy_search_twitter
|
32
|
+
tweets = response.parsed_response['results']
|
33
|
+
if tweets
|
34
|
+
tweets.each do |tweet|
|
35
|
+
tumblr_post = @tweetlr.generate_tumblr_photo_post tweet
|
36
|
+
if tumblr_post.nil? || tumblr_post[:source].nil?
|
37
|
+
@log.error "could not get image source: #{tumblr_post.inspect}"
|
38
|
+
else
|
39
|
+
@log.debug tumblr_post
|
40
|
+
@log.debug @tweetlr.post_to_tumblr tumblr_post
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
|
43
|
+
end
|
44
|
+
@log.info('finished tweetlr crawl.')
|
45
|
+
}
|
45
46
|
}
|
46
47
|
|
47
48
|
end
|
data/lib/tweetlr.rb
CHANGED
@@ -8,7 +8,7 @@ class Tweetlr
|
|
8
8
|
GENERATOR = %{tweetlr - http://github.com/5v3n/tweetlr}
|
9
9
|
|
10
10
|
def initialize(email, password, cookie=nil, since_id=nil, term=nil, config_file) #TODO use a hash or sth more elegant here...
|
11
|
-
@log = Logger.new('tweetlr.log')
|
11
|
+
@log = Logger.new(File.join( Dir.pwd, 'tweetlr.log'))
|
12
12
|
config = YAML.load_file(config_file)
|
13
13
|
@results_per_page = config['results_per_page']
|
14
14
|
@result_type = config['result_type']
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tweetlr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sven Kraeuter
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-25 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: daemons
|