pupil 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
17
17
  gem.name = "pupil"
18
18
  gem.homepage = "http://github.com/oame/pupil"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{The Twitter API Wrapper for Ruby}
21
- gem.description = %Q{The "Lazy" Twitter API wrapper for Ruby. It was made for Kbot library.}
20
+ gem.summary = %Q{The "Lazy" Twitter API Wrapper for Ruby}
21
+ gem.description = %Q{The "Lazy" Twitter API Wrapper for Ruby 1.9.2}
22
22
  gem.email = "oame@oameya.com"
23
23
  gem.authors = ["Oame"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/pupil.rb CHANGED
@@ -12,7 +12,6 @@ require 'pupil/keygen'
12
12
 
13
13
  class Pupil
14
14
  attr_reader :screen_name
15
-
16
15
  class UnsupportedParameter < StandardError; end
17
16
 
18
17
  # @param [Hash] pupil_key
@@ -33,7 +32,7 @@ class Pupil
33
32
  end
34
33
 
35
34
  # @param [Hash] parameter
36
- # @return [String] serialized parameters
35
+ # @return [String] URL Serialized parameters
37
36
  def param_serializer parameter
38
37
  ant = Hash.new
39
38
  parameter.each do |key, value|
@@ -81,7 +80,7 @@ class Pupil
81
80
 
82
81
  public
83
82
 
84
- # @return [Hash] user profile
83
+ # @return [Hash] User credentials
85
84
  def verify_credentials
86
85
  response = @access_token.get('/account/verify_credentials.xml')
87
86
  doc = REXML::Document.new(response.body)
@@ -90,8 +89,9 @@ class Pupil
90
89
  return user
91
90
  end
92
91
 
92
+ # Alias to Pupil#home_timeline
93
93
  # @param [Hash] param
94
- # @return [Hash] alias to Pupil#home_timeline
94
+ # @return [Array] Timeline
95
95
  # @deprecated Use {#home_timeline} instead of this method because
96
96
  # is was obsoleted.
97
97
  def friends_timeline(param = {})
@@ -114,7 +114,7 @@ class Pupil
114
114
  end
115
115
 
116
116
  # @param [Hash] param
117
- # @return [Array] timeline
117
+ # @return [Array] Timeline
118
118
  def home_timeline(param = {})
119
119
  param_s = param_serializer(param)
120
120
  begin
@@ -132,6 +132,7 @@ class Pupil
132
132
  return statuses
133
133
  end
134
134
 
135
+ # Returning user timeline
135
136
  # @param [Hash] param
136
137
  # @return [Hash] timeline
137
138
  # @option param [Fixnum] :user_id The ID of user
@@ -141,12 +142,12 @@ class Pupil
141
142
  # @option param [Fixnum] :count
142
143
  # @option param [Fixnum] :page Specifies
143
144
  # @option param [Symbol] :trim_user
144
- # @option param [Symbol] :include => :rts
145
- # @option param [Symbol] :exclude => :replies
145
+ # @option param [Symbol] :include #=> [:rts]
146
+ # @option param [Symbol] :exclude #=> [:replies]
146
147
  # @option param [Symbol] :contributor_details
147
148
  # @example
148
149
  # twitter = Pupil.new PUPIL_KEY
149
- # twitter.user_timeline(:screen_name => 'o_ame', :exclude_replies => :true).each do |status|
150
+ # twitter.user_timeline(:screen_name => 'o_ame', :exclude => :replies).each do |status|
150
151
  # puts "#{status.user.screen_name}: #{status.text}"
151
152
  # end
152
153
  def user_timeline(param = {})
@@ -187,6 +188,7 @@ class Pupil
187
188
  return statuses
188
189
  end
189
190
 
191
+ # Returning direct messages
190
192
  # @param [Hash] param
191
193
  # @return [Hash] directmessages
192
194
  def dm(param = {})
@@ -208,6 +210,7 @@ class Pupil
208
210
  return directmessages
209
211
  end
210
212
 
213
+ # Returning direct messages you sent
211
214
  # @param [Hash] param
212
215
  # @return [Hash] directmessage you sent
213
216
  def dm_sent(param = {})
@@ -229,6 +232,7 @@ class Pupil
229
232
  return directmessages
230
233
  end
231
234
 
235
+ # Delete direct message
232
236
  # @param [Fixnum] dm_id message id that you want to delete
233
237
  # @return [Hash] response
234
238
  def dm_destroy(dm_id)
@@ -240,6 +244,7 @@ class Pupil
240
244
  return response
241
245
  end
242
246
 
247
+ # Check friendships
243
248
  # @param [String] src source user
244
249
  # @param [String] dst destination user
245
250
  # @return [Boolean] return true if paired users have friendship, or ruturn false
@@ -258,6 +263,7 @@ class Pupil
258
263
  end
259
264
  end
260
265
 
266
+ # Follow user for screen_name
261
267
  # @param [String] name screen_name
262
268
  # @return [Hash] response
263
269
  def follow name
@@ -269,6 +275,7 @@ class Pupil
269
275
  return response
270
276
  end
271
277
 
278
+ # Unfollow user for screen_name
272
279
  # @param [String] name screen_name
273
280
  # @return [Hash] response
274
281
  def unfollow name
data/lib/pupil/keygen.rb CHANGED
@@ -2,8 +2,12 @@
2
2
 
3
3
  class Pupil
4
4
  class Keygen
5
- class MissingRequiedTokens < StandardError; end
6
-
5
+ attr_reader :con_key
6
+ attr_reader :con_sec
7
+ attr_reader :act_key
8
+ attr_reader :act_sec
9
+ class MissingRequiredTokens < StandardError; end
10
+
7
11
  def initialize opts={}
8
12
  @con_key = opts[:consumer_key] rescue nil
9
13
  @con_sec = opts[:consumer_secret] rescue nil
@@ -11,20 +15,30 @@ class Pupil
11
15
  @act_sec = opts[:access_token_secret] rescue nil
12
16
  end
13
17
 
14
- def access_token
15
- raise MissingRequiedTokens, "Keygen#access_token require consumer_key and consumer_secret" unless @con_key && @con_sec
18
+ def get_auth_url
19
+ raise MissingRequiredTokens, "Pupil::Keygen#get_auth_url require consumer_key and consumer_secret when initialized" unless @con_key || @con_sec
20
+ consumer = OAuth::Consumer.new(@con_key, @con_sec, :site => 'http://twitter.com')
21
+ request_token = consumer.get_request_token
22
+ return request_token.authorize_url
16
23
  end
17
24
 
18
- def interactive
19
- print "Enter OAuth Consumer_Key: "
20
- oauth_consumer_key = gets.chomp.strip
21
- print "Enter OAuth Consumer_Secret: "
22
- oauth_consumer_secret = gets.chomp.strip
25
+ def issue_token verifier
26
+ raise MissingRequiredTokens, "Pupil::Keygen#get_auth_url require consumer_key and consumer_secret when initialized" unless @con_key || @con_sec
27
+ consumer = OAuth::Consumer.new(@con_key, @con_sec, :site => 'http://twitter.com')
28
+ request_token = consumer.get_request_token
29
+ access_token = request_token.get_access_token(:oauth_verifier => verifier)
30
+ @act_key = access_token.token
31
+ @act_sec = access_token.secret
32
+ return {:access_token => access_token.token, :access_token_secret => access_token.secret}
33
+ end
23
34
 
24
- CONSUMER_KEY = oauth_consumer_key
25
- CONSUMER_SECRET = oauth_consumer_secret
35
+ def interactive
36
+ print "Enter OAuth Consumer Key: " unless @con_key
37
+ @con_key = gets.chomp.strip unless @con_key
38
+ print "Enter OAuth Consumer Secret: " unless @con_sec
39
+ @con_sec = gets.chomp.strip unless @con_sec
26
40
 
27
- consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => 'http://twitter.com')
41
+ consumer = OAuth::Consumer.new(@con_key, @con_sec, :site => 'http://twitter.com')
28
42
 
29
43
  request_token = consumer.get_request_token
30
44
 
@@ -34,9 +48,12 @@ class Pupil
34
48
  oauth_verifier = gets.chomp.strip
35
49
 
36
50
  access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
51
+ @act_key = access_token.token
52
+ @act_sec = access_token.secret
37
53
 
38
54
  puts "Process complete!"
39
55
  puts "Access token: #{access_token.token}"
40
56
  puts "Access token secret: #{access_token.secret}"
41
57
  end
58
+ end
42
59
  end
data/pupil.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{pupil}
8
- s.version = "0.0.4"
7
+ s.name = "pupil"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Oame}]
12
- s.date = %q{2011-10-10}
13
- s.description = %q{The "Lazy" Twitter API wrapper for Ruby. It was made for Kbot library.}
14
- s.email = %q{oame@oameya.com}
11
+ s.authors = ["Oame"]
12
+ s.date = "2011-10-22"
13
+ s.description = "The \"Lazy\" Twitter API Wrapper for Ruby 1.9.2"
14
+ s.email = "oame@oameya.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -28,14 +28,15 @@ Gem::Specification.new do |s|
28
28
  "lib/pupil.rb",
29
29
  "lib/pupil/keygen.rb",
30
30
  "pupil.gemspec",
31
+ "samples/generate-key.rb",
31
32
  "spec/pupil_spec.rb",
32
33
  "spec/spec_helper.rb"
33
34
  ]
34
- s.homepage = %q{http://github.com/oame/pupil}
35
- s.licenses = [%q{MIT}]
36
- s.require_paths = [%q{lib}]
37
- s.rubygems_version = %q{1.8.5}
38
- s.summary = %q{The Twitter API Wrapper for Ruby}
35
+ s.homepage = "http://github.com/oame/pupil"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.10"
39
+ s.summary = "The \"Lazy\" Twitter API Wrapper for Ruby"
39
40
 
40
41
  if s.respond_to? :specification_version then
41
42
  s.specification_version = 3
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require "rubygems" if RUBY_VERSION < "1.9.0"
5
+ $LOAD_PATH << File.join(File.dirname(File.expand_path(__FILE__)), "../")
6
+ require "lib/pupil"
7
+
8
+ keygen = Pupil::Keygen.new
9
+ keygen.interactive
data/spec/pupil_spec.rb CHANGED
@@ -16,3 +16,14 @@ describe Pupil, "が #home_timeline を呼ぶ時は" do
16
16
  @home_timeline.class.should == Array
17
17
  end
18
18
  end
19
+
20
+ describe Pupil, "が #mentions を呼ぶ時は" do
21
+ before do
22
+ pupil = Pupil.new PUPIL_TESTKEY
23
+ @mentions = pupil.mentions
24
+ end
25
+
26
+ it "Array型を返すこと" do
27
+ @mentions.class.should == Array
28
+ end
29
+ 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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-10 00:00:00.000000000Z
12
+ date: 2011-10-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &2154343320 !ruby/object:Gem::Requirement
16
+ requirement: &70097782606580 !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: *2154343320
24
+ version_requirements: *70097782606580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2154342740 !ruby/object:Gem::Requirement
27
+ requirement: &70097782605800 !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: *2154342740
35
+ version_requirements: *70097782605800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &2154342160 !ruby/object:Gem::Requirement
38
+ requirement: &70097782605080 !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: *2154342160
46
+ version_requirements: *70097782605080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &2154341560 !ruby/object:Gem::Requirement
49
+ requirement: &70097782604380 !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: *2154341560
57
+ version_requirements: *70097782604380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &2154340980 !ruby/object:Gem::Requirement
60
+ requirement: &70097782603500 !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: *2154340980
68
+ version_requirements: *70097782603500
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rcov
71
- requirement: &2154340400 !ruby/object:Gem::Requirement
71
+ requirement: &70097782602860 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,8 +76,8 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2154340400
80
- description: The "Lazy" Twitter API wrapper for Ruby. It was made for Kbot library.
79
+ version_requirements: *70097782602860
80
+ description: The "Lazy" Twitter API Wrapper for Ruby 1.9.2
81
81
  email: oame@oameya.com
82
82
  executables: []
83
83
  extensions: []
@@ -96,6 +96,7 @@ files:
96
96
  - lib/pupil.rb
97
97
  - lib/pupil/keygen.rb
98
98
  - pupil.gemspec
99
+ - samples/generate-key.rb
99
100
  - spec/pupil_spec.rb
100
101
  - spec/spec_helper.rb
101
102
  homepage: http://github.com/oame/pupil
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
114
  version: '0'
114
115
  segments:
115
116
  - 0
116
- hash: 422837417626133980
117
+ hash: -2681516288239048624
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  none: false
119
120
  requirements:
@@ -122,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
123
  version: '0'
123
124
  requirements: []
124
125
  rubyforge_project:
125
- rubygems_version: 1.8.5
126
+ rubygems_version: 1.8.10
126
127
  signing_key:
127
128
  specification_version: 3
128
- summary: The Twitter API Wrapper for Ruby
129
+ summary: The "Lazy" Twitter API Wrapper for Ruby
129
130
  test_files: []