gnip_api 0.0.6 → 0.0.7

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: 0ace6a737270b54933d3a565107f177695ccc5fc
4
- data.tar.gz: a5ff0135422ebbfb589e6caaa75fa78d394b5e61
3
+ metadata.gz: d0ae4c94718a2de90323b7511592b9d1320ef80e
4
+ data.tar.gz: f5b6ea9aee615af882e27555b4705774d7bbc206
5
5
  SHA512:
6
- metadata.gz: 9d5b61329486ff45318975b4b6d2ee844b110a262fd1fa69b4c213bd4ac509cdb628f14815745cc1d9ce3eb1dcdf5c009fd2b4709f05721bbd5bee0ab591ecd6
7
- data.tar.gz: 921dc1e0a35fbc0377a56fddbfe84e306a6508aef39462405296cc08ccd2d6a237f2f0bed95cdc0158477cca4125468dd930040123b8f92b9c7c4ea7f85c7cea
6
+ metadata.gz: 22b94334a96c94518ca52ae883ef98e04c98489ecbf5e6da4b70f6a70fb6017e982a97a395a32621e094f46dc3dfd017d5a00f8e4dc12bda3e8cc92ee3a814c1
7
+ data.tar.gz: 65205a747d6622d441960996fb597ebf79fb53adff213147ad4e225c1a948cd503d4cc865ccf1018d8cdcebf8f8c458a287beb602396ab376697a77646e7c967
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gnip_api (0.0.6)
4
+ gnip_api (0.0.7)
5
5
  activesupport
6
6
  addressable
7
7
  httparty
data/README.md CHANGED
@@ -6,6 +6,7 @@ Connect with different Gnip APIs and get data from streams.
6
6
 
7
7
  ## Recent Changes
8
8
 
9
+ - Timeout for requests added to fail if API is non responsive, time can be configured
9
10
  - Search API returns parsed data either for counts or activities, which also makes Search API usable to get activities now
10
11
  - Removed unused RateLimiter
11
12
  - Removed unused Mutex
@@ -49,6 +50,7 @@ GnipApi.configure |config|
49
50
  config.logger = Logger.new('myLog.log') # You can also provide a custom logger
50
51
  config.source = 'twitter' # General source, if none defined when quering, this will be used
51
52
  config.label = 'mystream' # General stream label, if none defined when quering, this will be used
53
+ config.request_timeout = 120 # Default time out on all requests, defaults to 60
52
54
  end
53
55
  ```
54
56
 
@@ -88,10 +90,10 @@ results = GnipApi::Apis::Search.new.counts :rule => rule, :from_date => DateTime
88
90
  For activities, there are a few extra considerations:
89
91
 
90
92
  - A param ```:max_results``` indicates how many activities to return on a response, valid values are from 10 to 500, default is 100, this param does not work on counts.
91
- - As you noticed, you pass a ```GnipApi::Apis::PowerTrack::Rule``` object to the search endpoint, and as you may also know, these objects have mostly 2 thigs: value (actual rule), and tag. When querying activities on the Search API, you can optionally use a tag that is returned on the activity, along with the rule. This tag is deduced from the rule object you pass, in other words, if you want a tag, add it on the ```GnipApi::Apis::PowerTrack::Rule``` object, it's not a valid param for the method.
93
+ - As you noticed, you pass a ```GnipApi::Apis::PowerTrack::Rule``` object to the search endpoint, and as you may also know, these objects have mostly 2 things: value (actual rule), and tag. When querying activities on the Search API, you can optionally use a tag that is returned on the activity, along with the rule. This tag is deduced from the rule object you pass, in other words, if you want a tag, add it on the ```GnipApi::Apis::PowerTrack::Rule``` object, it's not a valid param for the method.
92
94
  - The ```:bucket``` option is only for counts.
93
95
 
94
- When you query for more than 30 days or more activities than ```:max_activities```, the results will include a ```:next``` token to iterate over the remaining pages. You can instantly feed this token to a following request with same parameters:
96
+ When you query for more than 30 days or more activities than ```:max_results```, the results will include a ```:next``` token to iterate over the remaining pages. You can instantly feed this token to a following request with same parameters:
95
97
 
96
98
  ```ruby
97
99
  results = GnipApi::Apis::Search.new.counts :rule => rule, :from_date => DateTime.parse('2016-01-01 00:00'), :to_date => DateTime.parse('2016-05-01 22:00'), :bucket => 'day', :next_token => 'token_from_previous_request'
@@ -50,6 +50,10 @@ module GnipApi
50
50
  def password
51
51
  GnipApi.configuration.password
52
52
  end
53
+
54
+ def default_timeout
55
+ GnipApi.configuration.request_timeout
56
+ end
53
57
 
54
58
  def create_response request, status, body, headers
55
59
  GnipApi::Response.new request, status, body, headers
@@ -2,17 +2,17 @@ module GnipApi
2
2
  module Adapters
3
3
  class HTTPartyAdapter < GnipApi::Adapters::BaseAdapter
4
4
  def post request
5
- data = HTTParty.post request.uri, :basic_auth => auth, :body => request.payload
5
+ data = HTTParty.post request.uri, :basic_auth => auth, :body => request.payload, :timeout => default_timeout
6
6
  return response(request, data)
7
7
  end
8
8
 
9
9
  def delete request
10
- data = HTTParty.delete request.uri, :basic_auth => auth, :body => request.payload
10
+ data = HTTParty.delete request.uri, :basic_auth => auth, :body => request.payload, :timeout => default_timeout
11
11
  return response(request, data)
12
12
  end
13
13
 
14
14
  def get request
15
- data = HTTParty.get request.uri, :basic_auth => auth
15
+ data = HTTParty.get request.uri, :basic_auth => auth, :timeout => default_timeout
16
16
  return response(request, data)
17
17
  end
18
18
 
@@ -1,10 +1,11 @@
1
1
  module GnipApi
2
2
  class Configuration
3
- attr_accessor :user, :password, :adapter_class, :account, :logger, :source, :label
3
+ attr_accessor :user, :password, :adapter_class, :account, :logger, :source, :label, :request_timeout
4
4
 
5
5
  def initialize
6
6
  @adapter_class = GnipApi::Adapters::HTTPartyAdapter
7
7
  @logger = Logger.new('tmp/gnip_api.log')
8
+ @request_timeout = 60
8
9
  end
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module GnipApi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnip_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rayko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler