gazouillis 0.0.4 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,23 +22,31 @@ class Tweets < Gazouillis::Stream
22
22
  end
23
23
 
24
24
  options = {
25
- auth: {
26
- user: 'user',
27
- password: 'password'
25
+ oauth: {
26
+ consumer_key: "consumer_key",
27
+ consumer_secret: "consumer_secret",
28
+ token: "token",
29
+ token_secret: "token_secret"
28
30
  }
29
31
  }
32
+
30
33
  Tweets.new('/1/statuses/sample.json', options).open!
31
34
  ```
32
35
 
33
36
  ## Roadmap
34
37
 
35
- ### 0.1.0
38
+ ### 0.2.0
39
+
40
+ * UserStream, FilterStream and SampleStream
41
+
42
+ ### 0.3.0
36
43
 
37
44
  * Reconnector object.
38
45
 
39
- ### 1.0.0
40
46
 
41
- * Oauth.
47
+ ## Example
48
+
49
+ * [Gazouillis sinatra](https://github.com/chatgris/gazouillis_sinatra)
42
50
 
43
51
  ## Copyright
44
52
 
@@ -2,4 +2,6 @@
2
2
  require 'openssl'
3
3
  require 'celluloid/io'
4
4
  require 'http/parser'
5
+ require 'simple_oauth'
5
6
  require_relative 'gazouillis/stream'
7
+ require_relative 'gazouillis/version'
@@ -4,9 +4,13 @@ module Gazouillis
4
4
  #
5
5
  class Stream
6
6
  include Celluloid::IO
7
+ attr_reader :host, :path, :method
7
8
 
8
9
  def initialize(path, opts)
9
- @options = default_options.merge(opts).merge(path: path)
10
+ @options = default_options.merge(opts)
11
+ @path = path
12
+ @host = opts.fetch(:host, "stream.twitter.com")
13
+ @method = opts.fetch(:method, "GET")
10
14
 
11
15
  socket = TCPSocket.new "stream.twitter.com", 443
12
16
  ssl = OpenSSL::SSL::SSLSocket.new(socket.to_io, OpenSSL::SSL::SSLContext.new)
@@ -55,15 +59,20 @@ module Gazouillis
55
59
  # TODO : a real request object, with nice headers.
56
60
  #
57
61
  def request
58
- request = "GET #{@options[:path]} HTTP/1.1\r\n"
62
+ request = "#{method} #{path} HTTP/1.1\r\n"
59
63
  request << "Host: #{@options[:host]}\r\n"
60
- request << "Authorization: Basic #{basic_auth}\r\n"
64
+ request << "User-Agent: Gazouillis #{Gazouillis::VERSION}\r\n"
65
+ request << "Authorization: #{oauth}\r\n"
61
66
  request << "\r\n"
62
67
  request
63
68
  end
64
69
 
65
- def basic_auth
66
- ["#{@options[:auth][:user]}:#{@options[:auth][:password]}"].pack('m').strip
70
+ def oauth
71
+ SimpleOAuth::Header.new method, full_url, {}, @options[:oauth]
72
+ end
73
+
74
+ def full_url
75
+ "https://#{host}#{path}"
67
76
  end
68
77
 
69
78
  def default_options
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Gazouillis
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazouillis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-24 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid-io
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :runtime
@@ -40,7 +40,23 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: simple_oauth
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
46
62
  description: Twitter stream client.
@@ -64,19 +80,20 @@ require_paths:
64
80
  required_ruby_version: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ! '>='
83
+ - - '>='
68
84
  - !ruby/object:Gem::Version
69
85
  version: '0'
70
86
  required_rubygems_version: !ruby/object:Gem::Requirement
71
87
  none: false
72
88
  requirements:
73
- - - ! '>='
89
+ - - '>='
74
90
  - !ruby/object:Gem::Version
75
91
  version: '0'
76
92
  requirements: []
77
93
  rubyforge_project:
78
- rubygems_version: 1.8.24
94
+ rubygems_version: 1.8.25
79
95
  signing_key:
80
96
  specification_version: 3
81
97
  summary: Twitter stream client.
82
98
  test_files: []
99
+ has_rdoc: