twistream 0.3.0 → 0.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/README.md +30 -0
- data/Rakefile +11 -53
- data/VERSION +1 -1
- data/lib/twistream/client.rb +9 -10
- data/lib/twistream/event.rb +1 -1
- data/spec/auth.yml.sample +2 -0
- data/spec/client_spec.rb +7 -9
- data/twistream.gemspec +20 -0
- metadata +47 -39
- data/README.rdoc +0 -5
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
twistream (0.4.0.beta1)
|
5
|
+
yajl-ruby (~> 0.7.8)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.3)
|
11
|
+
rspec (2.6.0)
|
12
|
+
rspec-core (~> 2.6.0)
|
13
|
+
rspec-expectations (~> 2.6.0)
|
14
|
+
rspec-mocks (~> 2.6.0)
|
15
|
+
rspec-core (2.6.4)
|
16
|
+
rspec-expectations (2.6.0)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
rspec-mocks (2.6.0)
|
19
|
+
yajl-ruby (0.7.9)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
rspec (>= 2.4.0)
|
26
|
+
twistream!
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
twistream
|
2
|
+
=========
|
3
|
+
|
4
|
+
twistream is an simple client for hooking up with the twitter streaming api
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
** stable release **
|
10
|
+
|
11
|
+
gem install twistream
|
12
|
+
|
13
|
+
** beta release **
|
14
|
+
|
15
|
+
gem install twistream --pre
|
16
|
+
|
17
|
+
Usage
|
18
|
+
-----
|
19
|
+
|
20
|
+
auth = { :user => 'username', :pass => 'password' }
|
21
|
+
@client = TwiStream::Client.new(auth)
|
22
|
+
@client.sample do |status|
|
23
|
+
puts status
|
24
|
+
end
|
25
|
+
|
26
|
+
Disclaimer
|
27
|
+
----------
|
28
|
+
|
29
|
+
This gem is still very experimental and undocumented.
|
30
|
+
There could be major API changes between future versions
|
data/Rakefile
CHANGED
@@ -1,58 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem.description = %Q{a simple streaming api client for twitter}
|
10
|
-
gem.email = "swessel@gr4yweb.de"
|
11
|
-
gem.homepage = "http://github.com/gr4y/twistream"
|
12
|
-
gem.authors = ["Sascha Wessel"]
|
13
|
-
gem.require_path = 'lib'
|
14
|
-
gem.files = %w( Rakefile ) + Dir.glob("{lib}/**/*") + %w( VERSION )
|
15
|
-
gem.add_runtime_dependency "yajl-ruby", "~> 0.7.8"
|
16
|
-
end
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "generate rdoc"
|
22
|
-
require 'rake/rdoctask'
|
23
|
-
Rake::RDocTask.new do |rdoc|
|
24
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
25
|
-
rdoc.rdoc_dir = 'rdoc'
|
26
|
-
rdoc.title = "twistream #{version}"
|
27
|
-
rdoc.rdoc_files.include('README*')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
4
|
+
desc "generate documentation"
|
5
|
+
require 'yard'
|
6
|
+
YARD::Rake::YardocTask.new do |yard|
|
7
|
+
yard.files = ['lib/**/*.rb']
|
8
|
+
yard.options = ["--no-private"]
|
29
9
|
end
|
30
10
|
|
31
11
|
desc "run all specs"
|
32
|
-
|
33
|
-
|
34
|
-
require 'spec/rake/spectask'
|
35
|
-
Spec::Rake::SpecTask.new do |t|
|
36
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
37
|
-
end
|
38
|
-
rescue LoadError
|
39
|
-
warn "[twistream] rspec is not installed. install it with: gem install rspec --version 1.3.0"
|
40
|
-
end
|
41
|
-
|
42
|
-
require 'rake/rdoctask'
|
43
|
-
Rake::RDocTask.new do |rdoc|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "twistream #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
50
|
-
|
51
|
-
require 'reek/rake/task'
|
52
|
-
Reek::Rake::Task.new do |t|
|
53
|
-
t.fail_on_error = false
|
54
|
-
t.verbose = true
|
55
|
-
end
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
56
14
|
|
57
|
-
task :
|
58
|
-
task :default => [:
|
15
|
+
task :devbuild => [:yard, :build]
|
16
|
+
task :default => [:spec, :devbuild]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0.beta1
|
data/lib/twistream/client.rb
CHANGED
@@ -2,8 +2,8 @@ module TwiStream
|
|
2
2
|
class Client
|
3
3
|
extend TwiStream::EventHandler
|
4
4
|
attr_accessor :realm
|
5
|
-
events :on_error
|
6
|
-
|
5
|
+
events :on_error, :on_start
|
6
|
+
|
7
7
|
def initialize(auth)
|
8
8
|
self.realm = "#{auth[:user]}:#{auth[:pass]}".chomp
|
9
9
|
end
|
@@ -32,25 +32,24 @@ module TwiStream
|
|
32
32
|
start(:filter, :locations => params.join(','), & block)
|
33
33
|
end
|
34
34
|
|
35
|
-
def stop
|
36
|
-
if @
|
37
|
-
@
|
35
|
+
def stop
|
36
|
+
if @stream.alive?
|
37
|
+
@stream.kill
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
def start(api_method, params = {}, & block)
|
43
43
|
url = build_uri(api_method)
|
44
|
-
|
45
|
-
|
44
|
+
begin
|
45
|
+
@stream = Thread.new do
|
46
46
|
::Yajl::HttpStream.post(url, params) do |status|
|
47
47
|
block.call(status)
|
48
48
|
end
|
49
|
-
rescue
|
50
|
-
on_error.trigger($!, $@)
|
51
49
|
end
|
50
|
+
rescue
|
51
|
+
on_error.trigger($!, $@)
|
52
52
|
end
|
53
|
-
@thread.join
|
54
53
|
end
|
55
54
|
|
56
55
|
def build_uri(api_method)
|
data/lib/twistream/event.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -5,19 +5,17 @@ describe TwiStream::Client do
|
|
5
5
|
before :all do
|
6
6
|
auth = YAML.load_file('spec/auth.yml')
|
7
7
|
@client = TwiStream::Client.new(auth)
|
8
|
-
@client.on_error.
|
9
|
-
|
8
|
+
@client.on_error.receive do |msg,tr|
|
9
|
+
raise e
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
context "
|
13
|
+
context "filter by keywords, wait, stop" do
|
14
14
|
it "should start the filter stream" do
|
15
15
|
keywords = "nowplaying", "nowwatching"
|
16
|
-
@
|
17
|
-
|
18
|
-
|
19
|
-
puts status['id']
|
20
|
-
end
|
16
|
+
@client.filter_by_keywords(keywords) do |status|
|
17
|
+
status.should_not == be_nil
|
18
|
+
puts status['id']
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -30,7 +28,7 @@ describe TwiStream::Client do
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
context "
|
31
|
+
context "sample, wait, stop" do
|
34
32
|
it "should start the sample stream" do
|
35
33
|
@thread = Thread.new do
|
36
34
|
@client.sample do |status|
|
data/twistream.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{twistream}
|
3
|
+
s.version = File.read('VERSION')
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.authors = ["Sascha Wessel"]
|
6
|
+
s.email = %q{swessel@gr4yweb.de}
|
7
|
+
s.homepage = %q{http://github.com/gr4y/twistream}
|
8
|
+
s.description = %q{a simple streaming api client for twitter}
|
9
|
+
s.summary = %q{a simple streaming api client for twitter}
|
10
|
+
|
11
|
+
s.rubyforge_project = "twistream"
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
|
17
|
+
s.add_dependency "yajl-ruby", "~> 0.7.8"
|
18
|
+
s.add_development_dependency "rspec", ">= 2.4.0"
|
19
|
+
end
|
20
|
+
|
metadata
CHANGED
@@ -1,75 +1,83 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: twistream
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Sascha Wessel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: yajl-ruby
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70144168678040 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
18
|
+
requirements:
|
22
19
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
20
|
+
- !ruby/object:Gem::Version
|
24
21
|
version: 0.7.8
|
25
22
|
type: :runtime
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70144168678040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70144168676760 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.4.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70144168676760
|
27
36
|
description: a simple streaming api client for twitter
|
28
37
|
email: swessel@gr4yweb.de
|
29
38
|
executables: []
|
30
|
-
|
31
39
|
extensions: []
|
32
|
-
|
33
|
-
|
34
|
-
-
|
35
|
-
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- .gitignore
|
43
|
+
- Gemfile
|
44
|
+
- Gemfile.lock
|
45
|
+
- README.md
|
36
46
|
- Rakefile
|
37
47
|
- VERSION
|
38
48
|
- lib/twistream.rb
|
39
49
|
- lib/twistream/client.rb
|
40
50
|
- lib/twistream/event.rb
|
41
51
|
- lib/twistream/event_handler.rb
|
42
|
-
-
|
52
|
+
- spec/auth.yml.sample
|
43
53
|
- spec/client_spec.rb
|
44
54
|
- spec/spec_helper.rb
|
45
|
-
|
55
|
+
- twistream.gemspec
|
46
56
|
homepage: http://github.com/gr4y/twistream
|
47
57
|
licenses: []
|
48
|
-
|
49
58
|
post_install_message:
|
50
59
|
rdoc_options: []
|
51
|
-
|
52
|
-
require_paths:
|
60
|
+
require_paths:
|
53
61
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
63
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
69
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version:
|
70
|
+
requirements:
|
71
|
+
- - ! '>'
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 1.3.1
|
66
74
|
requirements: []
|
67
|
-
|
68
|
-
|
69
|
-
rubygems_version: 1.5.0
|
75
|
+
rubyforge_project: twistream
|
76
|
+
rubygems_version: 1.8.6
|
70
77
|
signing_key:
|
71
78
|
specification_version: 3
|
72
79
|
summary: a simple streaming api client for twitter
|
73
|
-
test_files:
|
80
|
+
test_files:
|
81
|
+
- spec/auth.yml.sample
|
74
82
|
- spec/client_spec.rb
|
75
83
|
- spec/spec_helper.rb
|