user-stream-receiver 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by hitode909 on 2011-1-18.
4
+ # Copyright (c) 2011. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+
9
+ require 'user-stream-receiver'
10
+ require 'json'
11
+
12
+ UserStreamReceiver.new.run{|chunk|
13
+ data = JSON.parse(chunk)
14
+ p data
15
+ }
@@ -1,4 +1,9 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by hitode909 on 2011-1-18.
4
+ # Copyright (c) 2011. All rights reserved.
5
+
6
+ require 'rubygems'
2
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
8
 
4
9
  require 'user-stream-receiver'
@@ -7,6 +7,20 @@ class UserStreamReceiver
7
7
  CONSUMER_TOKEN = 'kHOuxYqXSINzOW3UzEqEcA'
8
8
  CONSUMER_SECRET = 'x6dzx1oFjgDrtJSM2v8YYEYhyN2LnB1zUOeNo9Y'
9
9
 
10
+ attr_accessor :pit_file
11
+
12
+ def initialize(pit_file = 'user-stream-receiver')
13
+ @pit_file = pit_file
14
+ end
15
+
16
+ def new_from_access_token(access_token)
17
+ @access_token = access_token
18
+ end
19
+
20
+ def access_token
21
+ @access_token ||= self.get_access_token(:pit => @pit_file)
22
+ end
23
+
10
24
  def run(&block)
11
25
  loop {
12
26
  begin
@@ -21,10 +35,6 @@ class UserStreamReceiver
21
35
  protected
22
36
  ENDPOINT = URI.parse('https://userstream.twitter.com/2/user.json')
23
37
 
24
- def access_token
25
- @access_token ||= self.get_access_token(:pit => 'user-stream-receiver')
26
- end
27
-
28
38
  def logger
29
39
  @logger ||= Logger.new(STDOUT)
30
40
  @logger.level = Logger::INFO
@@ -4,4 +4,10 @@ describe "UserStreamReceiver" do
4
4
  it "exists" do
5
5
  UserStreamReceiver.new.should be_kind_of UserStreamReceiver
6
6
  end
7
+
8
+ it "has pit_file" do
9
+ UserStreamReceiver.new.pit_file.should == 'user-stream-receiver'
10
+ UserStreamReceiver.new('pit-file-path').pit_file.should == 'pit-file-path'
11
+ end
12
+
7
13
  end
@@ -5,13 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{user-stream-receiver}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hitode909"]
12
12
  s.date = %q{2011-01-18}
13
13
  s.description = %q{User Stream Receiver.}
14
14
  s.email = %q{hitode909@gmail.com}
15
+ s.executables = ["user-stream-receiver", "user-stream-receiver-insert-mongo"]
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE.txt",
17
18
  "README.rdoc"
@@ -25,8 +26,8 @@ Gem::Specification.new do |s|
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
28
  "VERSION",
28
- "example/insert_mongo.rb",
29
- "example/print.rb",
29
+ "bin/user-stream-receiver",
30
+ "bin/user-stream-receiver-insert-mongo",
30
31
  "lib/user-stream-receiver.rb",
31
32
  "spec/spec_helper.rb",
32
33
  "spec/user-stream-receiver_spec.rb",
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - hitode909
@@ -105,8 +105,9 @@ dependencies:
105
105
  version_requirements: *id006
106
106
  description: User Stream Receiver.
107
107
  email: hitode909@gmail.com
108
- executables: []
109
-
108
+ executables:
109
+ - user-stream-receiver
110
+ - user-stream-receiver-insert-mongo
110
111
  extensions: []
111
112
 
112
113
  extra_rdoc_files:
@@ -121,8 +122,8 @@ files:
121
122
  - README.rdoc
122
123
  - Rakefile
123
124
  - VERSION
124
- - example/insert_mongo.rb
125
- - example/print.rb
125
+ - bin/user-stream-receiver
126
+ - bin/user-stream-receiver-insert-mongo
126
127
  - lib/user-stream-receiver.rb
127
128
  - spec/spec_helper.rb
128
129
  - spec/user-stream-receiver_spec.rb
@@ -141,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
- hash: 473998417439686367
145
+ hash: 1007266744008627670
145
146
  segments:
146
147
  - 0
147
148
  version: "0"
data/example/print.rb DELETED
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
-
4
- require 'user-stream-receiver'
5
- require 'json'
6
-
7
- UserStreamReceiver.new.run{|chunk|
8
- p JSON.parse(chunk)
9
- }