twitter_anonymous_client 0.0.1 → 1.0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c64fd6de388ffc764e3c9a69e5e7295013c817fb
4
- data.tar.gz: 7642c5fd5571d16b84aee9387145a882b50e3b51
3
+ metadata.gz: 8390855368ce290ddf4167692a24b1c6f9e58cd6
4
+ data.tar.gz: 2f8e8b9bccb76a0635c01a153c95b860715465bf
5
5
  SHA512:
6
- metadata.gz: c7838adead52bf3180021d1ed083e18c68a160ceb55e6781a4726dd9cd18580e5f52cb603184633d1a3d087ea1270390eb83ce45f527b411baa725c2f0496fe4
7
- data.tar.gz: e50c6fe61856f4547203953862b1787bebbdc5461ad0c919106c7dcb17bd96d09afa8d5409d0639a49bc43baf0e25341816afb24a1d7da414c28b52602fcce42
6
+ metadata.gz: 0039269bf31e0a8f8a80f61fb64b0a0460dbc33fed135f199645e3dfc8808516db25562d5fdf43433a31bc258a2f7350428e690267b473164011a6c55af8f40b
7
+ data.tar.gz: 305cbb70b6d413f8b21c76b52ce5f8f2dcccaca2397c6f4861c0ca30b63081c51d6e9637a76467e15ded31afe69430b7c3af59fa3d41b0446d29ac36978e50ea
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## [In git](https://github.com/elgalu/twitter_anonymous_client/compare/v0.0.1...HEAD)
1
+ ## [In git](https://github.com/elgalu/twitter_anonymous_client/compare/v1.0.0.0...HEAD)
2
2
 
3
3
  ### New Features
4
4
  * n/a
@@ -9,6 +9,18 @@
9
9
  ### Chores
10
10
  * n/a
11
11
 
12
+ ## [v1.0.0.0](https://github.com/elgalu/twitter_anonymous_client/tree/v1.0.0.0)
13
+
14
+ ### New Features
15
+ * n/a
16
+
17
+ ### Bugfixes
18
+ * n/a
19
+
20
+ ### Chores
21
+ * Added documentation. (Leo Gallucci)
22
+ * Changed versioning system: 1.0 for twitter api and 0.0 for this gem version. (Leo Gallucci)
23
+
12
24
  ## [v0.0.1](https://github.com/elgalu/twitter_anonymous_client/tree/v0.0.1)
13
25
 
14
26
  ## First gem release
data/README.md CHANGED
@@ -20,7 +20,7 @@ Twitter public (anonymous) client for old v1.0 API just to retrieve the last N u
20
20
  require 'twitter_anonymous_client'
21
21
 
22
22
  tweets = Twitter::Client.new.user_timeline('elgalu', count: 1)
23
- elgalu = tweets.first #=> #<Twitter::Tweet:0x00.. @id="3076....
23
+ elgalu = tweets.first #=> #<Twitter::Tweet:0x00.. @id="3076....>
24
24
  elgalu.text #=> "Console Ruby debug is easy - Leo Gallucci's blog http://t.co/JUpUdyf5ts"
25
25
  ```
26
26
 
@@ -3,14 +3,18 @@ require 'twitter/tweet'
3
3
 
4
4
  module Twitter
5
5
  module API
6
- # @note Inspired from gems\twitter-4.5.0\spec\twitter\api\timelines_spec.rb
6
+ # @note Inspired from twitter-4.5.0/spec/twitter/api/timelines_spec.rb
7
7
  module Timelines
8
8
 
9
- # Get some user timeline by screen name
9
+ # Get some user timeline by screen name (last statuses)
10
10
  #
11
- # @example
12
- # user_timeline('DolarBlue', count: 1)
11
+ # @param [String] screen_name the twitter user slug
12
+ # @param [Hash] opts the options to retrieve the statuses
13
+ # @option opts [Integer] :count The number of statuses to retrieve
13
14
  #
15
+ # @example
16
+ # Twitter::Client.new.user_timeline('DolarBlue', count: 1)
17
+ # #=> [#<Twitter::Tweet:0x011.. @id="308609..., @text="Dolar Paralelo: $7,84.....
14
18
  def user_timeline(screen_name, opts)
15
19
  # Sanitize arguments
16
20
  count = opts[:count] || 1
@@ -22,6 +26,8 @@ module Twitter
22
26
 
23
27
  private
24
28
 
29
+ # (see #user_timeline)
30
+ # @private
25
31
  def get_user_timeline_results(screen_name, count)
26
32
  path = "statuses/user_timeline.json"
27
33
  qry = []
@@ -6,14 +6,24 @@ require 'uri'
6
6
  require 'json'
7
7
 
8
8
  module Twitter
9
- # @note Inspired from gems\twitter-4.5.0\spec\twitter\tweet_spec.rb
9
+ # @note Inspired from twitter-4.5.0/spec/twitter/tweet_spec.rb
10
10
  class Client
11
11
  ConnectionError = Class.new(StandardError)
12
12
 
13
13
  include Twitter::API::Timelines
14
14
 
15
- # Perform an HTTP GET request
16
- # qry = [['slug', 'élgalu'], ['age', '31']]
15
+ # Perform an HTTP get request against Twitter API then parse the result
16
+ #
17
+ # @param [String] path the relative path to twitter API
18
+ # @param [Array<Array<(String, String)>>] qry a nested array used to build the http query string
19
+ #
20
+ # @return [Array<Hash>] a collection of twitter response object, for example tweets
21
+ #
22
+ # @example
23
+ # path = "statuses/user_timeline.json"
24
+ # qry = [['screen_name', 'elgalu'], ['count', '1']]
25
+ # Twitter::Client.new.get(path, qry)
26
+ # #=> [{"created_at"=>"Fri Mar 01 21:42:19 +0000 2013", "id"=>30760....
17
27
  def get(path, qry=[])
18
28
  uri = build_uri(path, qry)
19
29
  begin
@@ -28,15 +38,30 @@ module Twitter
28
38
 
29
39
  private
30
40
 
41
+ # Builds an URI object out of a path and a query string appending twitter endpoint and api version
42
+ #
43
+ # @param (see #get)
44
+ #
45
+ # @return [URI] parsed ready url
46
+ #
47
+ # @private
31
48
  def build_uri(path, qry=[])
32
49
  query = URI.encode_www_form(qry)
33
50
  path.chomp!('/')
34
51
  path.sub!(/^\//, '')
35
- base = Twitter::Default::ENDPOINT
36
- ver = Twitter::Default::API_VERSION
52
+ base = Twitter::Default.endpoint
53
+ ver = Twitter::Default.api_version
37
54
  URI.parse("#{base}/#{ver}/#{path}?#{query}")
38
55
  end
39
56
 
57
+ # Output connection related errors and terminates execusion
58
+ #
59
+ # @param [URI] uri the uri from which will use the full url
60
+ # @param [String] msg the custom error message
61
+ #
62
+ # @raise [ConnectionError] always, with url and message
63
+ #
64
+ # @private
40
65
  def pute(uri, msg)
41
66
  raise ConnectionError.new("#{msg}\nRequest: #{uri.to_s}\n")
42
67
  end
@@ -4,5 +4,20 @@ module Twitter
4
4
  ENDPOINT = 'http://api.twitter.com'
5
5
  API_VERSION = '1'
6
6
  end
7
+
8
+ class << self
9
+ # @note This is configurable in case you want to use a Twitter-compatible endpoint.
10
+ # @see https://github.com/sferik/twitter/blob/01e2781e4a78137ca4e5e6d3e4faf2552ee9ec76/lib/twitter/default.rb#L78
11
+ # @return [String]
12
+ def endpoint
13
+ ENDPOINT
14
+ end
15
+
16
+ # @note Should be stuck with no-oauth twitter versions (public API)
17
+ # @return [String]
18
+ def api_version
19
+ API_VERSION
20
+ end
21
+ end
7
22
  end
8
23
  end
data/lib/twitter/tweet.rb CHANGED
@@ -3,11 +3,20 @@ require 'strongly_typed'
3
3
  require 'date'
4
4
 
5
5
  module Twitter
6
- # @note Inspired from gems\twitter-4.5.0\lib\twitter\api\timelines.rb
6
+ # @note Inspired from twitter-4.5.0/lib/twitter/api/timelines.rb
7
7
  class Tweet
8
8
  # Class Methods
9
9
  class << self
10
- # Transform json array into a collection of tweets
10
+ # Transform a json array into a collection of tweets
11
+ #
12
+ # @param [Array<Hash>] ary the json twitter results turned into an array of hashes
13
+ #
14
+ # @return [Array<Tweet>] the array of Tweets normalized objects
15
+ #
16
+ # @example
17
+ # ary = [{'created_at'=>'2013-02-28', 'id'=>3, 'text'=>'hello world'}]
18
+ # Twitter::Tweet.build_tweets(ary)
19
+ # #=> [#<Twitter::Tweet:0x07.. @id="3", @text="hello world", @created_at=#<DateTime: 2013-02-27>>]
11
20
  def build_tweets(ary)
12
21
  tweets = ary.map do |tweet|
13
22
  args = { id: tweet['id'],
@@ -1,3 +1,9 @@
1
1
  module TwitterAnonymousClient
2
- VERSION = "0.0.1"
2
+ # Four digits version:
3
+ # "a.b.c.d"
4
+ # The first 2 digits (a,b) are the Twitter API version used, in this case verion 1.
5
+ # The last 2 digits (c,d) are this gem version.
6
+ # c is a major update or any update that breaks this gem API.
7
+ # d is minor or bugfix update.
8
+ VERSION = "1.0.0.0"
3
9
  end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "yard", ">= 0.8.5.2"
34
34
  spec.add_development_dependency "simplecov", ">= 0.7.1"
35
35
  spec.add_development_dependency 'coveralls', '>= 0.5.8'
36
- spec.add_development_dependency 'webmock', '>= 1.10.1'
36
+ spec.add_development_dependency 'webmock', '>= 1.11'
37
37
 
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_anonymous_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Gallucci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-03 00:00:00.000000000 Z
11
+ date: 2013-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: strongly_typed
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - '>='
130
130
  - !ruby/object:Gem::Version
131
- version: 1.10.1
131
+ version: '1.11'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '>='
137
137
  - !ruby/object:Gem::Version
138
- version: 1.10.1
138
+ version: '1.11'
139
139
  description: Twitter public (anonymous) client for old v1.0 API
140
140
  email:
141
141
  - elgalu3@gmail.com