gazouillis 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gazouillis/stream.rb +41 -0
- data/lib/gazouillis/version.rb +4 -0
- data/lib/gazouillis.rb +4 -0
- metadata +60 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Gazouillis
|
3
|
+
class Stream
|
4
|
+
include Celluloid::IO
|
5
|
+
HOST = "stream.twitter.com"
|
6
|
+
|
7
|
+
def initialize(path, auth)
|
8
|
+
@path = path
|
9
|
+
@auth = auth
|
10
|
+
|
11
|
+
socket = TCPSocket.new "stream.twitter.com", 443
|
12
|
+
ssl = OpenSSL::SSL::SSLSocket.new(socket.to_io, OpenSSL::SSL::SSLContext.new)
|
13
|
+
ssl.sync = true
|
14
|
+
ssl.connect
|
15
|
+
|
16
|
+
@stream = ssl
|
17
|
+
end
|
18
|
+
|
19
|
+
def listen
|
20
|
+
@stream.write request
|
21
|
+
|
22
|
+
@stream.each_line do |line|
|
23
|
+
$stderr.puts line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def request
|
30
|
+
request = "GET #{@path} HTTP/1.1\r\n"
|
31
|
+
request << "Host: #{HOST}\r\n"
|
32
|
+
request << "Authorization: Basic #{basic_auth}\r\n"
|
33
|
+
request << "\r\n"
|
34
|
+
request
|
35
|
+
end
|
36
|
+
|
37
|
+
def basic_auth
|
38
|
+
["#{@auth[:user]}:#{@auth[:passord]}"].pack('m').strip
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/gazouillis.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gazouillis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- chatgris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: celluloid-io
|
16
|
+
version_requirements: &2056 !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
none: false
|
22
|
+
requirement: *2056
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
description: Twitter stream client.
|
26
|
+
email:
|
27
|
+
- jboyer@af83.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- lib/gazouillis.rb
|
33
|
+
- lib/gazouillis/stream.rb
|
34
|
+
- lib/gazouillis/version.rb
|
35
|
+
homepage: https://github.com/chatgris/gazouillis
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
none: false
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
none: false
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.15
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Twitter stream client.
|
59
|
+
test_files: []
|
60
|
+
...
|