pupil 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,20 @@
1
+ 0.2.2
2
+ ----------------
3
+
4
+ * New method Pupil#timeline is the some as Pupil#home_timeline
5
+ * New method Pupil#timeline_for is the some as Pupil#user_timeline
6
+ * Not necessary to give @screen_name parameter when Pupil.new . It is now on optionally parameter.
7
+ * Pupil#followers_ids and Pupil#friends_ids returns Array of ids
8
+
9
+ 0.2.1
10
+ ----------------
11
+
12
+ * Some bug fixed.
13
+
1
14
  0.2.0
2
15
  ----------------
3
16
 
4
- * Fixed bug what :include(and :exclude) parameter had not worked.
17
+ * Fixed bug that :include(and :exclude) parameter had not worked.
5
18
  * New form are supported.<br/>
6
19
  Classic form:<br/>
7
20
  `pupil = Pupil.new(…)`<br/>
data/README.md CHANGED
@@ -1,16 +1,20 @@
1
- pupil
1
+ Pupil
2
2
  =============
3
3
 
4
4
  Pupil is "Lazy" Twitter API Library for Ruby 1.9.x.
5
- Easy to use.
6
5
 
7
- Features / Problems
6
+ Features
8
7
  -------------
9
8
 
10
9
  * Almost Twitter REST API are wrapped. However, some API does not support yet.
11
10
  * Twitter Streaming API are supported experimentally.
12
11
  * Intuitive syntax.
13
12
 
13
+ Problems
14
+ -------------
15
+
16
+ * Some REST API are not supported.
17
+
14
18
  Requirement
15
19
  -------------
16
20
 
@@ -26,23 +30,17 @@ Examples
26
30
  -------------
27
31
  require "pupil"
28
32
 
29
- CONSUMER = {
30
- :app_name => "Web Service", # Optional
31
- :app_author => "o_ame", # Optional
32
- :consumer_key => "something", # Required
33
- :consumer_secret => "something" # Required
34
- }
35
-
36
- pupil_key = {
37
- :screen_name => "o_ame", # Required
33
+ oauth_key = {
34
+ :consumer_key => "something", # Required
35
+ :consumer_secret => "something", # Required
38
36
  :access_token => "something", # Required
39
37
  :access_token_secret => "something" # Required
40
- }.update CONSUMER
38
+ }
41
39
 
42
- pupil = Pupil.new pupil_key
40
+ pupil = Pupil.new oauth_key
43
41
 
44
42
  # Get timeline statuses without replies
45
- pupil.home_timeline :count => 50, :exclude => :replies
43
+ pupil.timeline :count => 50, :exclude => :replies
46
44
 
47
45
  # Follow User
48
46
  pupil.follow :twitterapi
@@ -54,32 +52,25 @@ Using Streaming API
54
52
 
55
53
  require "pupil/stream"
56
54
 
57
- CONSUMER = {
58
- :app_name => "Web Service",
59
- :app_author => "o_ame",
55
+ oauth_key = {
60
56
  :consumer_key => "something",
61
- :consumer_secret => "something"
62
- }
63
-
64
- pupil_key = {
65
- :screen_name => "o_ame",
57
+ :consumer_secret => "something",
66
58
  :access_token => "something",
67
59
  :access_token_secret => "something"
68
- }.update CONSUMER
60
+ }
69
61
 
70
- stream = Pupil::Stream.new pupil_key
62
+ stream = Pupil::Stream.new oauth_key
71
63
 
72
64
  # Userstream
73
65
  stream.start :userstream do |status|
74
- puts status.event #=> Show type of event
75
66
  if status.event == :retweeted
76
- puts "#{status.user.screen_name}: #{status.text}"
67
+ puts "This is retweeted status! => #{status.text}"
77
68
  end
78
69
  end
79
70
 
80
71
  # Search stream
81
72
  stream.start :search, :track => "#MerryChristmas" do |status|
82
- puts "#{status.user.screen_name}: #{status.text}"
73
+ puts "Merry christmas, #{status.user.screen_name}!"
83
74
  end
84
75
 
85
76
  Making `pupil_key`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -2,10 +2,12 @@ class Pupil
2
2
  # Verify credentials
3
3
  # @return [Pupil::User] User credentials
4
4
  def verify_credentials
5
- response = self.get("/account/verify_credentials.json")
5
+ response = self.get("/1/account/verify_credentials.json")
6
6
  user = User.new response
7
7
  return user
8
8
  end
9
+
10
+ alias_method :profile, :verify_credentials
9
11
 
10
12
  # Rate limit statuses
11
13
  # @return [Hash] Rate limit statuses
@@ -12,17 +12,17 @@ class Pupil
12
12
 
13
13
  # @param [Hash] pupil_key
14
14
  def initialize key
15
- @screen_name = key[:screen_name]
16
-
15
+ @screen_name = key[:screen_name] || nil
16
+
17
17
  @consumer = OAuth::Consumer.new(
18
- key[:consumer_key],
19
- key[:consumer_secret],
20
- :site => TWITTER_API_URL
18
+ key[:consumer_key],
19
+ key[:consumer_secret],
20
+ :site => TWITTER_API_URL
21
21
  )
22
22
  @access_token = OAuth::AccessToken.new(
23
- @consumer,
24
- key[:access_token],
25
- key[:access_token_secret]
23
+ @consumer,
24
+ key[:access_token],
25
+ key[:access_token_secret]
26
26
  )
27
27
  end
28
28
 
@@ -1,19 +1,21 @@
1
1
  class Pupil
2
2
  def friends_ids(name=@screen_name)
3
- response = self.get("/1/friends/ids/#{name}.json")
3
+ name ||= self.profile.screen_name
4
+ response = self.get("/1/friends/ids.json", {guess_parameter(name) => name})
4
5
  return false unless response
5
6
  ids = []
6
- response.each do |element|
7
+ response["ids"].each do |element|
7
8
  ids << element
8
9
  end
9
10
  return ids
10
11
  end
11
12
 
12
13
  def followers_ids(name=@screen_name)
13
- response = self.get("/1/followers/ids/#{name}.json")
14
+ name ||= self.profile.screen_name
15
+ response = self.get("/1/followers/ids.json", {guess_parameter(name) => name})
14
16
  return false unless response
15
17
  ids = []
16
- response.each do |element|
18
+ response["ids"].each do |element|
17
19
  ids << element
18
20
  end
19
21
  return ids
@@ -25,7 +27,7 @@ class Pupil
25
27
  # @return [Boolean] return true if paired users have friendship, or ruturn false
26
28
  def friendship?(src, dst)
27
29
  param = {"source_#{guess_parameter(src)}" => src, "target_#{guess_parameter(dst)}" => dst}
28
- response = self.get("/friendships/show.json", param)
30
+ response = self.get("/1/friendships/show.json", param)
29
31
  return nil unless response
30
32
  if response["relationship"]["source"]["following"] == true && response["relationship"]["target"]["following"] == true then
31
33
  return true
@@ -41,7 +43,7 @@ class Pupil
41
43
  # @param [String] name screen_name
42
44
  # @return [Hash] response
43
45
  def follow(param)
44
- response = self.post("/friendships/create.json", {guess_parameter(param) => param})
46
+ response = self.post("/1/friendships/create.json", {guess_parameter(param) => param})
45
47
  return false unless response
46
48
  User.new(response, @access_token)
47
49
  end
@@ -50,7 +52,7 @@ class Pupil
50
52
  # @param [String] name screen_name
51
53
  # @return [Hash] response
52
54
  def unfollow(param)
53
- response = self.post("/friendships/destroy.json", {guess_parameter(param) => param})
55
+ response = self.post("/1/friendships/destroy.json", {guess_parameter(param) => param})
54
56
  return false unless response
55
57
  User.new response
56
58
  end
@@ -9,7 +9,7 @@ class Pupil
9
9
  # @option param [Symbol] :include #=> [:rts]
10
10
  # @option param [Symbol] :exclude #=> [:replies]
11
11
  # @option param [Symbol] :contributor_details
12
- def home_timeline(param={})
12
+ def timeline(param={})
13
13
  response = self.get("/1/statuses/home_timeline.json", param)
14
14
  return false unless response
15
15
  statuses = []
@@ -20,6 +20,8 @@ class Pupil
20
20
  return statuses
21
21
  end
22
22
 
23
+ alias_method :home_timeline, :timeline
24
+
23
25
  # @return [Array] Mention
24
26
  # @param [Hash] param
25
27
  def mentions(param={})
@@ -61,6 +63,9 @@ class Pupil
61
63
  end
62
64
  return statuses
63
65
  end
66
+
67
+ alias_method :timeline_for, :user_timeline
68
+
64
69
  # Returning public timeline
65
70
  # @return [Array] Timeline
66
71
  # @param [Hash] param
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pupil"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oame"]
12
- s.date = "2012-04-05"
12
+ s.date = "2012-04-07"
13
13
  s.description = "The \"Lazy\" Twitter API Library for Ruby 1.9.x. Easy to use."
14
14
  s.email = "oame@oameya.com"
15
15
  s.extra_rdoc_files = [
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.2.1
4
+ version: 0.2.2
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: 2012-04-05 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &2166323140 !ruby/object:Gem::Requirement
16
+ requirement: &2154946820 !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: *2166323140
24
+ version_requirements: *2154946820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &2166322640 !ruby/object:Gem::Requirement
27
+ requirement: &2154997020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2166322640
35
+ version_requirements: *2154997020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2166322120 !ruby/object:Gem::Requirement
38
+ requirement: &2154995640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.3.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2166322120
46
+ version_requirements: *2154995640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &2166321460 !ruby/object:Gem::Requirement
49
+ requirement: &2154994360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2166321460
57
+ version_requirements: *2154994360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &2166320780 !ruby/object:Gem::Requirement
60
+ requirement: &2154993340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2166320780
68
+ version_requirements: *2154993340
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &2165760740 !ruby/object:Gem::Requirement
71
+ requirement: &2154992520 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2165760740
79
+ version_requirements: *2154992520
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &2165760060 !ruby/object:Gem::Requirement
82
+ requirement: &2154991960 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2165760060
90
+ version_requirements: *2154991960
91
91
  description: The "Lazy" Twitter API Library for Ruby 1.9.x. Easy to use.
92
92
  email: oame@oameya.com
93
93
  executables: []