gnip_api 1.2.2 → 1.2.3
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 +4 -4
- data/Gemfile.lock +24 -3
- data/README.md +70 -33
- data/Rakefile +7 -0
- data/doc/rdoc/classes/Gnip/Activity.html +354 -0
- data/doc/rdoc/classes/Gnip/Actor.html +300 -0
- data/doc/rdoc/classes/Gnip/GnipData.html +154 -0
- data/doc/rdoc/classes/Gnip/Message.html +236 -0
- data/doc/rdoc/classes/Gnip/SystemMessage.html +190 -0
- data/doc/rdoc/classes/Gnip/TwitterComplianceMessage.html +194 -0
- data/doc/rdoc/classes/Gnip/UndefinedMessage.html +83 -0
- data/doc/rdoc/classes/Gnip/Url.html +194 -0
- data/doc/rdoc/classes/Gnip.html +95 -0
- data/doc/rdoc/classes/GnipApi/Adapter.html +287 -0
- data/doc/rdoc/classes/GnipApi/Configuration.html +194 -0
- data/doc/rdoc/classes/GnipApi/Endpoints.html +191 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/GnipSoftwareError.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/RateLimitError.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter/RequestError.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/Adapter.html +66 -0
- data/doc/rdoc/classes/GnipApi/Errors/Configuration/InvalidOutputFormat.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Configuration.html +58 -0
- data/doc/rdoc/classes/GnipApi/Errors/JsonParser/ParseError.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/JsonParser.html +64 -0
- data/doc/rdoc/classes/GnipApi/Errors/MissingAdapter.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/MissingCredentials.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack/MissingRules.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack/StreamDown.html +56 -0
- data/doc/rdoc/classes/GnipApi/Errors/PowerTrack.html +65 -0
- data/doc/rdoc/classes/GnipApi/Errors/Search/MissingParameters.html +83 -0
- data/doc/rdoc/classes/GnipApi/Errors/Search.html +64 -0
- data/doc/rdoc/classes/GnipApi/Errors.html +79 -0
- data/doc/rdoc/classes/GnipApi/JsonParser.html +101 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Buffer.html +237 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Rule.html +196 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Rules.html +188 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack/Stream.html +359 -0
- data/doc/rdoc/classes/GnipApi/PowerTrack.html +73 -0
- data/doc/rdoc/classes/GnipApi/Request.html +216 -0
- data/doc/rdoc/classes/GnipApi/Response.html +232 -0
- data/doc/rdoc/classes/GnipApi/Search.html +101 -0
- data/doc/rdoc/classes/GnipApi.html +252 -0
- data/doc/rdoc/created.rid +24 -0
- data/doc/rdoc/css/style.css +343 -0
- data/doc/rdoc/files/LICENSE_txt.html +73 -0
- data/doc/rdoc/files/README_md.html +299 -0
- data/doc/rdoc/files/lib/gnip_api/adapter_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/configuration_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/endpoints_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/errors_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/activity_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/actor_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/gnip_data_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/system_message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/twitter_compliance_message_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/gnip/url_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/json_parser_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/buffer_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/rule_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/rules_rb.html +55 -0
- data/doc/rdoc/files/lib/gnip_api/power_track/stream_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/request_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/response_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api/search_rb.html +55 -0
- data/doc/rdoc/files/lib/gnip_api/version_rb.html +51 -0
- data/doc/rdoc/files/lib/gnip_api_rb.html +84 -0
- data/doc/rdoc/fr_class_index.html +92 -0
- data/doc/rdoc/fr_file_index.html +41 -0
- data/doc/rdoc/fr_method_index.html +4791 -0
- data/doc/rdoc/index.html +15 -0
- data/gnip_api.gemspec +3 -1
- data/lib/gnip_api/configuration.rb +18 -4
- data/lib/gnip_api/errors.rb +0 -1
- data/lib/gnip_api/power_track/buffer.rb +60 -14
- data/lib/gnip_api/power_track/stream.rb +52 -17
- data/lib/gnip_api/response.rb +3 -2
- data/lib/gnip_api/version.rb +1 -1
- data/spec/gnip_api/power_track/buffer_spec.rb +8 -0
- data/spec/gnip_api/response_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- metadata +97 -2
data/doc/rdoc/index.html
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>RDoc Documentation</title>
|
5
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
6
|
+
</head>
|
7
|
+
<frameset border='1' bordercolor='gray' cols='20%, *' frameborder='1'>
|
8
|
+
<frameset rows='15%, 35%, 50%'>
|
9
|
+
<frame name='Files' src='fr_file_index.html' title='Files'>
|
10
|
+
<frame name='Classes' src='fr_class_index.html'>
|
11
|
+
<frame name='Methods' src='fr_method_index.html'>
|
12
|
+
</frameset>
|
13
|
+
<frame name='docwin' src='files/README_md.html'></frame>
|
14
|
+
</frameset>
|
15
|
+
</html>
|
data/gnip_api.gemspec
CHANGED
@@ -24,7 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "awesome_print"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
26
|
spec.add_development_dependency "timecop"
|
27
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "byebug"
|
28
|
+
spec.add_development_dependency "rdoc"
|
29
|
+
spec.add_development_dependency "hanna-nouveau"
|
28
30
|
|
29
31
|
spec.add_dependency "httparty"
|
30
32
|
spec.add_dependency "yajl-ruby"
|
@@ -1,15 +1,29 @@
|
|
1
1
|
module GnipApi
|
2
|
+
# Configurations for the GnipApi gem.
|
3
|
+
#
|
4
|
+
# Defaults:
|
5
|
+
# - logger: *Logger.new('tmp/gnip_api.log')*
|
6
|
+
# - request_timeout: *60*
|
7
|
+
# - debug: *false*
|
8
|
+
# - enable_gzip: *true*
|
9
|
+
# - log_level: *Logger::WARN*
|
10
|
+
# - buffer_limit: *1000000*
|
2
11
|
class Configuration
|
3
12
|
attr_accessor :user, :password, :account, :logger, :source, :label, :request_timeout, :debug,
|
4
|
-
:enable_gzip, :log_level
|
13
|
+
:enable_gzip, :log_level
|
5
14
|
|
6
15
|
def initialize
|
7
|
-
@logger = Logger.new('tmp/gnip_api.log')
|
8
16
|
@request_timeout = 60
|
9
17
|
@debug = false
|
10
18
|
@enable_gzip = true
|
11
|
-
@log_level = Logger::
|
12
|
-
|
19
|
+
@log_level = Logger::WARN
|
20
|
+
end
|
21
|
+
|
22
|
+
def logger
|
23
|
+
return @logger if @logger
|
24
|
+
@logger = Logger.new('tmp/gnip_api.log')
|
25
|
+
@logger.level = log_level
|
26
|
+
return @logger
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
data/lib/gnip_api/errors.rb
CHANGED
@@ -1,42 +1,88 @@
|
|
1
1
|
module GnipApi
|
2
2
|
module PowerTrack
|
3
|
+
# Collects raw data from the stream received in chunks and splits
|
4
|
+
# it using the '\\r\\n' character to return complete items in JSON
|
5
|
+
# format.
|
3
6
|
class Buffer
|
4
|
-
attr_reader :terminator, :data
|
7
|
+
attr_reader :terminator, :data, :logger
|
5
8
|
|
6
9
|
def initialize options={}
|
7
10
|
@terminator = options.delete(:terminator) || "\r\n"
|
8
11
|
@data = ""
|
9
|
-
@
|
12
|
+
@logger = GnipApi.logger
|
13
|
+
@check_span = 30
|
14
|
+
@last_check = Time.now
|
10
15
|
end
|
11
16
|
|
17
|
+
# Returns the current size of the buffer.
|
12
18
|
def size
|
13
19
|
@data.size
|
14
20
|
end
|
15
21
|
|
22
|
+
# Inserts a +chunk+ into the buffer.
|
16
23
|
def insert! chunk
|
24
|
+
check
|
17
25
|
@data << chunk
|
18
26
|
end
|
19
27
|
|
28
|
+
# Splits the data and gets completed items from the buffer
|
29
|
+
# to remove them from the buffer and return them as an Array
|
30
|
+
# of items.
|
31
|
+
#
|
32
|
+
# +data+ is a simple String object that gets stuff added
|
33
|
+
# and using #read! gets stuff removed. At any moment +data+ can
|
34
|
+
# contain:
|
35
|
+
# - a fragment of an item
|
36
|
+
# - a complete item and a fragment of another
|
37
|
+
# - one or more complete items
|
38
|
+
# - a complete item followed by various terminator chars
|
39
|
+
# In all cases #read! will return complete items only, removing
|
40
|
+
# these from +data+ as it reads it. The way it does this is
|
41
|
+
# by finding the last terminator from right to left. String#rindex
|
42
|
+
# method will return the index (starting at 0) of the first char
|
43
|
+
# of the terminator. To properly read the data, a +1 is added to this
|
44
|
+
# index. Then another +1 is added to make it a count for #consume!
|
45
|
+
# to read. Note that #consume! eats up an amount of characters from
|
46
|
+
# left to right. The cut piece from the buffer is then splitted by
|
47
|
+
# the terminator to return the completed items. In the cut piece
|
48
|
+
# a terminator at the end will always be present, but the Array#split
|
49
|
+
# method already ignores that final one.
|
50
|
+
#
|
51
|
+
# If there's a single incomplete fragment in +data+, the index lookup
|
52
|
+
# will return +nil+ and an empty list will be returned, signaling
|
53
|
+
# nothing to read in the buffer and doing nothing to it until more
|
54
|
+
# chunks are inserted.
|
55
|
+
#
|
56
|
+
# In the case many terminator chars end up in the buffer, after split
|
57
|
+
# these will render as empty strings and removed from the list of
|
58
|
+
# items to return.
|
20
59
|
def read!
|
21
|
-
objects =
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# terminator
|
26
|
-
|
27
|
-
consume!(size)
|
60
|
+
objects = []
|
61
|
+
last_terminator_index = @data.rindex(terminator)
|
62
|
+
if last_terminator_index
|
63
|
+
last_terminator_index += 1 # include the following \n
|
64
|
+
objects = consume!(last_terminator_index + 1) # extract upto las terminator positin, +1 because it's an index
|
65
|
+
objects = objects.split(terminator).delete_if{|item| item.nil? || item.size == 0}
|
28
66
|
end
|
29
67
|
return objects
|
30
68
|
end
|
31
69
|
|
32
|
-
|
33
|
-
|
70
|
+
# Reads +char_count+ characters from +data+ removing them, and
|
71
|
+
# returns the extracted characters.
|
72
|
+
def consume! char_count
|
73
|
+
@data.slice!(0, char_count)
|
34
74
|
end
|
35
75
|
|
36
|
-
|
37
|
-
|
38
|
-
|
76
|
+
private
|
77
|
+
# Logs info about the buffer stats each +check_span+ seconds.
|
78
|
+
def check
|
79
|
+
return unless logger.level <= Logger::INFO
|
80
|
+
if Time.now.to_i > @last_check.to_i + @check_span
|
81
|
+
@last_check = Time.now
|
82
|
+
logger.info "Current buffer size is #{size} bytes"
|
83
|
+
end
|
39
84
|
end
|
85
|
+
|
40
86
|
end
|
41
87
|
end
|
42
88
|
end
|
@@ -1,5 +1,20 @@
|
|
1
1
|
module GnipApi
|
2
2
|
module PowerTrack
|
3
|
+
# Handles a stream connection to PowerTrack to receive the data.
|
4
|
+
#
|
5
|
+
# There are 3 ways to connect and consume the connection provided:
|
6
|
+
# - :common
|
7
|
+
# - :io
|
8
|
+
# - :pty
|
9
|
+
#
|
10
|
+
# Each method uses a different backend. This is a result of experimentation
|
11
|
+
# to mitigate disconnect issues. Each method handles differently the keep-alive
|
12
|
+
# signals and works a bit differently at the low level.
|
13
|
+
# The recommended method is :common, and will in the future become the default
|
14
|
+
# once it's polished enough.
|
15
|
+
#
|
16
|
+
# In addition to the methods above, a third strategy using the :common method
|
17
|
+
# is also offered to detach any processing you do on your end using threads.
|
3
18
|
class Stream
|
4
19
|
def initialize
|
5
20
|
@user = GnipApi.configuration.user
|
@@ -10,6 +25,7 @@ module GnipApi
|
|
10
25
|
@running = false
|
11
26
|
end
|
12
27
|
|
28
|
+
# Returns the configured logger.
|
13
29
|
def logger
|
14
30
|
GnipApi.logger
|
15
31
|
end
|
@@ -17,10 +33,13 @@ module GnipApi
|
|
17
33
|
# Consumes the stream using a streamer thread instead of a simple block.
|
18
34
|
# This way the streamer can fill in the buffer and the block consumes it periodically.
|
19
35
|
def thread_consume
|
36
|
+
@pool = []
|
20
37
|
streamer = Thread.new do
|
21
38
|
logger.info "Starting streamer Thread"
|
22
39
|
begin
|
23
|
-
read_stream
|
40
|
+
read_stream do |items|
|
41
|
+
items.each{|i| @pool << i}
|
42
|
+
end
|
24
43
|
ensure
|
25
44
|
logger.warn "Streamer exited"
|
26
45
|
end
|
@@ -30,8 +49,17 @@ module GnipApi
|
|
30
49
|
loop do
|
31
50
|
logger.warn "Streamer is down" unless streamer.alive?
|
32
51
|
raise GnipApi::Errors::PowerTrack::StreamDown unless streamer.alive?
|
33
|
-
entries =
|
34
|
-
|
52
|
+
entries = []
|
53
|
+
while @pool.any?
|
54
|
+
entries << @pool.shift
|
55
|
+
end
|
56
|
+
if entries.any?
|
57
|
+
processed = process_entries(entries)
|
58
|
+
yield(processed)
|
59
|
+
else
|
60
|
+
sleep(0.1)
|
61
|
+
next
|
62
|
+
end
|
35
63
|
end
|
36
64
|
ensure
|
37
65
|
streamer.kill if streamer.alive?
|
@@ -73,6 +101,9 @@ module GnipApi
|
|
73
101
|
end
|
74
102
|
end
|
75
103
|
|
104
|
+
# Similar to #consume with the difference this one spits out raw JSON
|
105
|
+
# and has no parsing on the data received. Use it for a faster consumtion.
|
106
|
+
# +stream_method+ param accepts the same options as #consume.
|
76
107
|
def consume_raw stream_method=:common
|
77
108
|
raise ArgumentError, "Block required, non given" unless block_given?
|
78
109
|
if stream_method == :common
|
@@ -92,6 +123,9 @@ module GnipApi
|
|
92
123
|
end
|
93
124
|
end
|
94
125
|
|
126
|
+
# Similar to #consume but parses the JSON to Hash with no further
|
127
|
+
# processing. +stream_method+ param accepts the same options as
|
128
|
+
# #consume.
|
95
129
|
def consume_json stream_method=:common
|
96
130
|
raise ArgumentError, "Block required, non given" unless block_given?
|
97
131
|
if stream_method == :common
|
@@ -111,6 +145,8 @@ module GnipApi
|
|
111
145
|
end
|
112
146
|
end
|
113
147
|
|
148
|
+
# Opens the connection to the PowerTrack stream and returns any data
|
149
|
+
# received using CURL IO transfer method.
|
114
150
|
def read_io_stream
|
115
151
|
request = create_request
|
116
152
|
logger.info "Opening PowerTrack parsed stream"
|
@@ -123,6 +159,8 @@ module GnipApi
|
|
123
159
|
end
|
124
160
|
end
|
125
161
|
|
162
|
+
# Opens the connection to the PowerTrack stream and returns any data
|
163
|
+
# received using CURL PTY transfer method.
|
126
164
|
def read_pty_stream
|
127
165
|
request = create_request
|
128
166
|
logger.info "Opening PowerTrack parsed stream"
|
@@ -135,12 +173,14 @@ module GnipApi
|
|
135
173
|
end
|
136
174
|
end
|
137
175
|
|
176
|
+
# Opens the connection to the PowerTrack stream and returns any data
|
177
|
+
# received using HTTParty and standard net/http. The buffer is used
|
178
|
+
# in this case to collect the chunks and later split them into items.
|
138
179
|
def read_stream
|
139
180
|
request = create_request
|
140
181
|
logger.info "Opening PowerTrack parsed stream"
|
141
182
|
begin
|
142
183
|
@adapter.stream_get request do |chunk|
|
143
|
-
stream_running!(@buffer, chunk)
|
144
184
|
@buffer.insert! chunk
|
145
185
|
yield @buffer.read! if block_given?
|
146
186
|
end
|
@@ -150,6 +190,8 @@ module GnipApi
|
|
150
190
|
end
|
151
191
|
end
|
152
192
|
|
193
|
+
# Processes the items received after splitting them up, returning
|
194
|
+
# appropiate Gnip objects.
|
153
195
|
def process_entries entries
|
154
196
|
logger.debug "PowerTrack Stream: #{entries.size} items received"
|
155
197
|
data = entries.map{|e| parse_json(e)}.compact
|
@@ -158,10 +200,12 @@ module GnipApi
|
|
158
200
|
return data
|
159
201
|
end
|
160
202
|
|
203
|
+
# Builds a Gnip::Message object from the item params received.
|
161
204
|
def build_message params
|
162
205
|
Gnip::Message.build(params)
|
163
206
|
end
|
164
207
|
|
208
|
+
# Returns a Hash from a parsed JSON string.
|
165
209
|
def parse_json json
|
166
210
|
begin
|
167
211
|
GnipApi::JsonParser.new.parse json
|
@@ -171,24 +215,15 @@ module GnipApi
|
|
171
215
|
end
|
172
216
|
|
173
217
|
private
|
174
|
-
|
175
|
-
unless @running
|
176
|
-
logger.info "PowerTrack stream open"
|
177
|
-
@running = true
|
178
|
-
end
|
179
|
-
raise GnipApi::Errors::PowerTrack::BufferTooBig if buffer.over_limit?
|
180
|
-
logger.warn "PowerTrack Stream: Buffer size is growing too big (slow consuming)" if buffer.size > 65536
|
181
|
-
logger.debug "PowerTrack Stream: Received chunk of #{chunk.size} bytes" if chunk
|
182
|
-
logger.debug "PowerTrack Stream: #{buffer.size} bytes in buffer" if buffer
|
183
|
-
end
|
184
|
-
|
218
|
+
# Builds a GnipApi::Request with the proper data to use by the adapter.
|
185
219
|
def create_request
|
186
220
|
headers = {}
|
187
|
-
headers['
|
188
|
-
headers['
|
221
|
+
headers['accept-Encoding'] = 'gzip' if GnipApi.config.enable_gzip
|
222
|
+
headers['accept-Encoding'] ||= 'json'
|
189
223
|
GnipApi::Request.new_get(endpoint, headers)
|
190
224
|
end
|
191
225
|
|
226
|
+
# Returns the default endpoint of the stream
|
192
227
|
def endpoint
|
193
228
|
GnipApi::Endpoints.powertrack_stream
|
194
229
|
end
|
data/lib/gnip_api/response.rb
CHANGED
@@ -27,7 +27,9 @@ module GnipApi
|
|
27
27
|
def error_message
|
28
28
|
if @body && !@body.empty?
|
29
29
|
parsed = GnipApi::JsonParser.new.parse(@body)
|
30
|
-
|
30
|
+
message = parsed['error']['message']
|
31
|
+
message += " - TID: #{parsed['error']['transactionId']}" if parsed['error']['transactionId']
|
32
|
+
return message
|
31
33
|
end
|
32
34
|
return nil
|
33
35
|
end
|
@@ -40,7 +42,6 @@ module GnipApi
|
|
40
42
|
GnipApi.logger.debug "Request headers -> #{request.headers.inspect}"
|
41
43
|
GnipApi.logger.debug "Request payload -> #{request.payload.inspect}"
|
42
44
|
else
|
43
|
-
error_message = error_message
|
44
45
|
GnipApi.logger.error "#{request_method} request to #{request_uri} returned with status #{status} FAIL"
|
45
46
|
GnipApi.logger.debug "Headers -> #{headers.inspect}"
|
46
47
|
GnipApi.logger.debug "Body -> #{body.inspect}"
|
data/lib/gnip_api/version.rb
CHANGED
@@ -23,6 +23,14 @@ describe GnipApi::PowerTrack::Buffer do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#read!' do
|
26
|
+
context 'with keep-alive signals' do
|
27
|
+
it 'does not return empty items' do
|
28
|
+
['asd--', '--', 'qwe--', '--', '--'].each{|item| @buffer.insert!(item)}
|
29
|
+
data = @buffer.read!
|
30
|
+
expect(data).to eq(['asd', 'qwe']) # last item is considered incomplete
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
context 'with partial data' do
|
27
35
|
before do
|
28
36
|
@buffer.insert! 'asd--qwe--x'
|
@@ -7,6 +7,22 @@ describe GnipApi::Response do
|
|
7
7
|
expect(Proc.new{GnipApi::Response.new(request, 200, 'body', {:header => 'a header'})}).not_to raise_error
|
8
8
|
end
|
9
9
|
|
10
|
+
describe '#error_message' do
|
11
|
+
context 'when 429' do
|
12
|
+
let(:request) { GnipApi::Response.new(GnipApi::Request.new, 429, "{\"error\":{\"message\":\"Exceeded rate limit\",\"sent\":\"2018-02-06T16:35:03+00:00\",\"transactionId\":\"000ea40b00c3da1e\"}}", {}) }
|
13
|
+
it 'parses the body and returns message' do
|
14
|
+
expect(request.error_message).to eq("Exceeded rate limit - TID: 000ea40b00c3da1e")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when 503' do
|
19
|
+
let(:request) { GnipApi::Response.new(GnipApi::Request.new, 503, "{\"error\":{\"message\":\"Gnip software error\",\"sent\":\"2018-02-06T16:35:03+00:00\",\"transactionId\":\"000ea40b00c3da1e\"}}", {}) }
|
20
|
+
it 'parses the body and returns message' do
|
21
|
+
expect(request.error_message).to eq("Gnip software error - TID: 000ea40b00c3da1e")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
describe 'response data' do
|
11
27
|
before do
|
12
28
|
@status = 100
|
data/spec/spec_helper.rb
CHANGED
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: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rdoc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: hanna-nouveau
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: httparty
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,6 +194,73 @@ files:
|
|
166
194
|
- README.md
|
167
195
|
- Rakefile
|
168
196
|
- console
|
197
|
+
- doc/rdoc/classes/Gnip.html
|
198
|
+
- doc/rdoc/classes/Gnip/Activity.html
|
199
|
+
- doc/rdoc/classes/Gnip/Actor.html
|
200
|
+
- doc/rdoc/classes/Gnip/GnipData.html
|
201
|
+
- doc/rdoc/classes/Gnip/Message.html
|
202
|
+
- doc/rdoc/classes/Gnip/SystemMessage.html
|
203
|
+
- doc/rdoc/classes/Gnip/TwitterComplianceMessage.html
|
204
|
+
- doc/rdoc/classes/Gnip/UndefinedMessage.html
|
205
|
+
- doc/rdoc/classes/Gnip/Url.html
|
206
|
+
- doc/rdoc/classes/GnipApi.html
|
207
|
+
- doc/rdoc/classes/GnipApi/Adapter.html
|
208
|
+
- doc/rdoc/classes/GnipApi/Configuration.html
|
209
|
+
- doc/rdoc/classes/GnipApi/Endpoints.html
|
210
|
+
- doc/rdoc/classes/GnipApi/Errors.html
|
211
|
+
- doc/rdoc/classes/GnipApi/Errors/Adapter.html
|
212
|
+
- doc/rdoc/classes/GnipApi/Errors/Adapter/GnipSoftwareError.html
|
213
|
+
- doc/rdoc/classes/GnipApi/Errors/Adapter/RateLimitError.html
|
214
|
+
- doc/rdoc/classes/GnipApi/Errors/Adapter/RequestError.html
|
215
|
+
- doc/rdoc/classes/GnipApi/Errors/Configuration.html
|
216
|
+
- doc/rdoc/classes/GnipApi/Errors/Configuration/InvalidOutputFormat.html
|
217
|
+
- doc/rdoc/classes/GnipApi/Errors/JsonParser.html
|
218
|
+
- doc/rdoc/classes/GnipApi/Errors/JsonParser/ParseError.html
|
219
|
+
- doc/rdoc/classes/GnipApi/Errors/MissingAdapter.html
|
220
|
+
- doc/rdoc/classes/GnipApi/Errors/MissingCredentials.html
|
221
|
+
- doc/rdoc/classes/GnipApi/Errors/PowerTrack.html
|
222
|
+
- doc/rdoc/classes/GnipApi/Errors/PowerTrack/MissingRules.html
|
223
|
+
- doc/rdoc/classes/GnipApi/Errors/PowerTrack/StreamDown.html
|
224
|
+
- doc/rdoc/classes/GnipApi/Errors/Search.html
|
225
|
+
- doc/rdoc/classes/GnipApi/Errors/Search/MissingParameters.html
|
226
|
+
- doc/rdoc/classes/GnipApi/JsonParser.html
|
227
|
+
- doc/rdoc/classes/GnipApi/PowerTrack.html
|
228
|
+
- doc/rdoc/classes/GnipApi/PowerTrack/Buffer.html
|
229
|
+
- doc/rdoc/classes/GnipApi/PowerTrack/Rule.html
|
230
|
+
- doc/rdoc/classes/GnipApi/PowerTrack/Rules.html
|
231
|
+
- doc/rdoc/classes/GnipApi/PowerTrack/Stream.html
|
232
|
+
- doc/rdoc/classes/GnipApi/Request.html
|
233
|
+
- doc/rdoc/classes/GnipApi/Response.html
|
234
|
+
- doc/rdoc/classes/GnipApi/Search.html
|
235
|
+
- doc/rdoc/created.rid
|
236
|
+
- doc/rdoc/css/style.css
|
237
|
+
- doc/rdoc/files/LICENSE_txt.html
|
238
|
+
- doc/rdoc/files/README_md.html
|
239
|
+
- doc/rdoc/files/lib/gnip_api/adapter_rb.html
|
240
|
+
- doc/rdoc/files/lib/gnip_api/configuration_rb.html
|
241
|
+
- doc/rdoc/files/lib/gnip_api/endpoints_rb.html
|
242
|
+
- doc/rdoc/files/lib/gnip_api/errors_rb.html
|
243
|
+
- doc/rdoc/files/lib/gnip_api/gnip/activity_rb.html
|
244
|
+
- doc/rdoc/files/lib/gnip_api/gnip/actor_rb.html
|
245
|
+
- doc/rdoc/files/lib/gnip_api/gnip/gnip_data_rb.html
|
246
|
+
- doc/rdoc/files/lib/gnip_api/gnip/message_rb.html
|
247
|
+
- doc/rdoc/files/lib/gnip_api/gnip/system_message_rb.html
|
248
|
+
- doc/rdoc/files/lib/gnip_api/gnip/twitter_compliance_message_rb.html
|
249
|
+
- doc/rdoc/files/lib/gnip_api/gnip/url_rb.html
|
250
|
+
- doc/rdoc/files/lib/gnip_api/json_parser_rb.html
|
251
|
+
- doc/rdoc/files/lib/gnip_api/power_track/buffer_rb.html
|
252
|
+
- doc/rdoc/files/lib/gnip_api/power_track/rule_rb.html
|
253
|
+
- doc/rdoc/files/lib/gnip_api/power_track/rules_rb.html
|
254
|
+
- doc/rdoc/files/lib/gnip_api/power_track/stream_rb.html
|
255
|
+
- doc/rdoc/files/lib/gnip_api/request_rb.html
|
256
|
+
- doc/rdoc/files/lib/gnip_api/response_rb.html
|
257
|
+
- doc/rdoc/files/lib/gnip_api/search_rb.html
|
258
|
+
- doc/rdoc/files/lib/gnip_api/version_rb.html
|
259
|
+
- doc/rdoc/files/lib/gnip_api_rb.html
|
260
|
+
- doc/rdoc/fr_class_index.html
|
261
|
+
- doc/rdoc/fr_file_index.html
|
262
|
+
- doc/rdoc/fr_method_index.html
|
263
|
+
- doc/rdoc/index.html
|
169
264
|
- gnip_api.gemspec
|
170
265
|
- lib/gnip_api.rb
|
171
266
|
- lib/gnip_api/adapter.rb
|