streambot 0.2.0 → 0.2.1
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/README.rdoc +1 -1
- data/Rakefile +3 -0
- data/lib/retweet.rb +24 -0
- data/lib/streambot.rb +3 -2
- metadata +6 -9
- data/.gitignore +0 -2
- data/VERSION +0 -1
- data/streambot.gemspec +0 -51
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -10,6 +10,9 @@ begin
|
|
10
10
|
gem.email = "swessel@gr4yweb.de"
|
11
11
|
gem.homepage = "http://github.com/gr4y/streambot"
|
12
12
|
gem.authors = ["Sascha Wessel"]
|
13
|
+
gem.require_path = 'lib'
|
14
|
+
gem.files = %w(Rakefile) + Dir.glob("{lib}/**/*")
|
15
|
+
|
13
16
|
# Dependency for dealing with twitter streaming API
|
14
17
|
gem.add_dependency "tweetstream",">= 1.0.4"
|
15
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/lib/retweet.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class Retweet
|
5
|
+
|
6
|
+
def initialize(auth)
|
7
|
+
return if auth.nil?
|
8
|
+
@auth = auth
|
9
|
+
end
|
10
|
+
|
11
|
+
def retweet(id)
|
12
|
+
url = URI.parse("http://api.twitter.com/1/statuses/retweet/#{id}.json")
|
13
|
+
req = Net::HTTP::Post.new(url.path)
|
14
|
+
req.basic_auth @auth[:username],@auth[:password]
|
15
|
+
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
16
|
+
case res
|
17
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
18
|
+
#OK
|
19
|
+
else
|
20
|
+
res.error!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/streambot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'tweetstream'
|
3
|
-
require
|
3
|
+
require 'retweet'
|
4
4
|
|
5
5
|
class StreamBot
|
6
6
|
|
@@ -12,7 +12,8 @@ class StreamBot
|
|
12
12
|
|
13
13
|
def start
|
14
14
|
@stream.track(@keywords) do |status|
|
15
|
-
|
15
|
+
puts "#{status.text} - #{status.id}"
|
16
|
+
@retweet.retweet(status.id)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sascha Wessel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-09 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -41,14 +41,11 @@ extra_rdoc_files:
|
|
41
41
|
- LICENSE
|
42
42
|
- README.rdoc
|
43
43
|
files:
|
44
|
-
- .gitignore
|
45
|
-
- LICENSE
|
46
|
-
- README.rdoc
|
47
44
|
- Rakefile
|
48
|
-
-
|
45
|
+
- lib/retweet.rb
|
49
46
|
- lib/streambot.rb
|
50
|
-
-
|
51
|
-
-
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
52
49
|
has_rdoc: true
|
53
50
|
homepage: http://github.com/gr4y/streambot
|
54
51
|
licenses: []
|
data/.gitignore
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
data/streambot.gemspec
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{streambot}
|
8
|
-
s.version = "0.2.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Sascha Wessel"]
|
12
|
-
s.date = %q{2010-04-08}
|
13
|
-
s.description = %q{a simple gem that tracks several keywords via twitter streaming api and re-publish it on twitter}
|
14
|
-
s.email = %q{swessel@gr4yweb.de}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"lib/streambot.rb",
|
26
|
-
"streambot.gemspec",
|
27
|
-
"test/test_streambot.rb"
|
28
|
-
]
|
29
|
-
s.homepage = %q{http://github.com/gr4y/streambot}
|
30
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
-
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.6}
|
33
|
-
s.summary = %q{retweeting tweets with specified keywords on twitter}
|
34
|
-
s.test_files = [
|
35
|
-
"test/test_streambot.rb"
|
36
|
-
]
|
37
|
-
|
38
|
-
if s.respond_to? :specification_version then
|
39
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
|
-
s.specification_version = 3
|
41
|
-
|
42
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
43
|
-
s.add_runtime_dependency(%q<tweetstream>, [">= 1.0.4"])
|
44
|
-
else
|
45
|
-
s.add_dependency(%q<tweetstream>, [">= 1.0.4"])
|
46
|
-
end
|
47
|
-
else
|
48
|
-
s.add_dependency(%q<tweetstream>, [">= 1.0.4"])
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|