pupil 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pupil/keygen.rb +34 -23
- data/pupil.gemspec +2 -1
- data/samples/ff-dumper.rb +19 -0
- metadata +15 -14
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/pupil/keygen.rb
CHANGED
@@ -2,43 +2,53 @@
|
|
2
2
|
|
3
3
|
class Pupil
|
4
4
|
class Keygen
|
5
|
-
attr_reader :
|
6
|
-
attr_reader :
|
7
|
-
attr_reader :
|
8
|
-
attr_reader :
|
5
|
+
attr_reader :consumer_key
|
6
|
+
attr_reader :consumer_secret
|
7
|
+
attr_reader :access_token
|
8
|
+
attr_reader :access_token_secret
|
9
9
|
class MissingRequiredTokens < StandardError; end
|
10
10
|
|
11
11
|
def initialize opts={}
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
12
|
+
@consumer_key = opts[:consumer_key] rescue nil
|
13
|
+
@consumer_secret = opts[:consumer_secret] rescue nil
|
14
|
+
@access_token = opts[:access_token] rescue nil
|
15
|
+
@access_token_secret = opts[:access_token_secret] rescue nil
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
raise MissingRequiredTokens, "Pupil::Keygen#
|
20
|
-
consumer = OAuth::Consumer.new(@
|
18
|
+
def auth_url
|
19
|
+
raise MissingRequiredTokens, "Pupil::Keygen#auth_url require consumer_key and consumer_secret" unless @consumer_key || @consumer_secret
|
20
|
+
consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, :site => 'http://twitter.com')
|
21
21
|
request_token = consumer.get_request_token
|
22
22
|
return request_token.authorize_url
|
23
23
|
end
|
24
24
|
|
25
25
|
def issue_token verifier
|
26
|
-
raise MissingRequiredTokens, "Pupil::Keygen#
|
27
|
-
consumer = OAuth::Consumer.new(@
|
26
|
+
raise MissingRequiredTokens, "Pupil::Keygen#issue_token require consumer_key and consumer_secret" unless @consumer_key || @consumer_secret
|
27
|
+
consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, :site => 'http://twitter.com')
|
28
28
|
request_token = consumer.get_request_token
|
29
29
|
access_token = request_token.get_access_token(:oauth_verifier => verifier)
|
30
|
-
@
|
31
|
-
@
|
30
|
+
@access_token = access_token.token
|
31
|
+
@access_token_secret = access_token.secret
|
32
32
|
return {:access_token => access_token.token, :access_token_secret => access_token.secret}
|
33
33
|
end
|
34
|
+
|
35
|
+
def pupilkey
|
36
|
+
raise MissingRequiredTokens, "Pupil::Keygen#pupilkey require consumer_key, consumer_secret, access_token and access_token_secret" unless @consumer_key || @consumer_secret || @access_token || @access_token_secret
|
37
|
+
return {
|
38
|
+
:consumer_key => @consumer_key,
|
39
|
+
:consumer_secret => @consumer_secret,
|
40
|
+
:access_token => @access_token,
|
41
|
+
:access_token_secret => @access_token_secret
|
42
|
+
}
|
43
|
+
end
|
34
44
|
|
35
45
|
def interactive
|
36
|
-
print "Enter OAuth Consumer Key: " unless @
|
37
|
-
@
|
38
|
-
print "Enter OAuth Consumer Secret: " unless @
|
39
|
-
@
|
46
|
+
print "Enter OAuth Consumer Key: " unless @consumer_key
|
47
|
+
@consumer_key = gets.chomp.strip unless @consumer_key
|
48
|
+
print "Enter OAuth Consumer Secret: " unless @consumer_secret
|
49
|
+
@consumer_secret = gets.chomp.strip unless @consumer_secret
|
40
50
|
|
41
|
-
consumer = OAuth::Consumer.new(@
|
51
|
+
consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, :site => 'http://twitter.com')
|
42
52
|
|
43
53
|
request_token = consumer.get_request_token
|
44
54
|
|
@@ -48,12 +58,13 @@ class Pupil
|
|
48
58
|
oauth_verifier = gets.chomp.strip
|
49
59
|
|
50
60
|
access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
|
51
|
-
@
|
52
|
-
@
|
53
|
-
|
61
|
+
@access_token = access_token.token
|
62
|
+
@access_token_secret = access_token.secret
|
63
|
+
|
54
64
|
puts "Process complete!"
|
55
65
|
puts "Access token: #{access_token.token}"
|
56
66
|
puts "Access token secret: #{access_token.secret}"
|
67
|
+
return {:consumer_key => @consumer_key, :consumer_secret => @consumer_secret, :access_token => access_token.token, :access_token_secret => access_token.secret}
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
data/pupil.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "pupil"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oame"]
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/pupil.rb",
|
29
29
|
"lib/pupil/keygen.rb",
|
30
30
|
"pupil.gemspec",
|
31
|
+
"samples/ff-dumper.rb",
|
31
32
|
"samples/generate-key.rb",
|
32
33
|
"spec/pupil_spec.rb",
|
33
34
|
"spec/spec_helper.rb"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# only 1.9.2
|
4
|
+
|
5
|
+
$LOAD_PATH << File.join(File.dirname(File.expand_path(__FILE__)), "../")
|
6
|
+
require "lib/pupil"
|
7
|
+
require "yaml"
|
8
|
+
|
9
|
+
keygen = Pupil::Keygen.new({:consumer_key => "yIyK3TaGo5VJX7MdkS95g", :consumer_secret => "ukIvD6yqP8SNbFfaIqVNkqg08J33uvRvpGa1ktuRc"})
|
10
|
+
tokens = keygen.interactive
|
11
|
+
|
12
|
+
pupil = Pupil.new tokens
|
13
|
+
user = pupil.verify_credentials
|
14
|
+
friends = pupil.friends_ids user.screen_name
|
15
|
+
followers = pupil.followers_ids user.screen_name
|
16
|
+
|
17
|
+
open("ff.yml", "w") do |f|
|
18
|
+
f.puts({:friends => friends, :followers => followers}.to_yaml)
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &70230268043280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70230268043280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70230268042620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.3.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70230268042620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &70230268042080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70230268042080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70230268041480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70230268041480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70230268040900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70230268040900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &70230268040240 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70230268040240
|
80
80
|
description: The "Lazy" Twitter API Wrapper for Ruby 1.9.2
|
81
81
|
email: oame@oameya.com
|
82
82
|
executables: []
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/pupil.rb
|
97
97
|
- lib/pupil/keygen.rb
|
98
98
|
- pupil.gemspec
|
99
|
+
- samples/ff-dumper.rb
|
99
100
|
- samples/generate-key.rb
|
100
101
|
- spec/pupil_spec.rb
|
101
102
|
- spec/spec_helper.rb
|
@@ -114,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
115
|
version: '0'
|
115
116
|
segments:
|
116
117
|
- 0
|
117
|
-
hash: -
|
118
|
+
hash: -2476195476726471591
|
118
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
120
|
none: false
|
120
121
|
requirements:
|