gnip_api 0.0.8 → 0.0.9
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 +1 -13
- data/README.md +2 -1
- data/gnip_api.gemspec +0 -1
- data/lib/gnip_api/adapters/base_adapter.rb +7 -0
- data/lib/gnip_api/adapters/httparty_adapter.rb +1 -1
- data/lib/gnip_api/apis/power_track/rules.rb +1 -1
- data/lib/gnip_api/apis/power_track/stream.rb +1 -1
- data/lib/gnip_api/apis/search.rb +2 -2
- data/lib/gnip_api/gnip/message.rb +1 -1
- data/lib/gnip_api/json_parser.rb +4 -4
- data/lib/gnip_api/response.rb +1 -1
- data/lib/gnip_api/version.rb +1 -1
- data/spec/gnip_api/json_parser_spec.rb +2 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ef89c6c8f354d532f33e1653c01a5587910985
|
4
|
+
data.tar.gz: 161b4cb6c80ecb1b81b3a3b73c948c0da9e708cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3364b2e6de262b14bc4d252283cedfe7636b65bb59e3ad6f3ab843a7a796dbdec1403607925c4a3cc77af7b7f100ef78232c75cf3a1d3c86d7237d7742afad
|
7
|
+
data.tar.gz: 4a1606261e57d5de690601aa24373e64bee728c23bb978c64b232944d0b9b0384f200f06afca873f7833548c448fcf0c88191e2be9af9876efd15f2662ec7e23
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gnip_api (0.0.
|
5
|
-
activesupport
|
4
|
+
gnip_api (0.0.9)
|
6
5
|
addressable
|
7
6
|
httparty
|
8
7
|
yajl-ruby
|
@@ -10,21 +9,13 @@ PATH
|
|
10
9
|
GEM
|
11
10
|
remote: https://rubygems.org/
|
12
11
|
specs:
|
13
|
-
activesupport (5.0.0.1)
|
14
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (~> 0.7)
|
16
|
-
minitest (~> 5.1)
|
17
|
-
tzinfo (~> 1.1)
|
18
12
|
addressable (2.4.0)
|
19
13
|
awesome_print (1.2.0)
|
20
14
|
coderay (1.1.0)
|
21
|
-
concurrent-ruby (1.0.2)
|
22
15
|
diff-lcs (1.2.5)
|
23
16
|
httparty (0.14.0)
|
24
17
|
multi_xml (>= 0.5.2)
|
25
|
-
i18n (0.7.0)
|
26
18
|
method_source (0.8.2)
|
27
|
-
minitest (5.9.1)
|
28
19
|
multi_xml (0.5.5)
|
29
20
|
pry (0.10.1)
|
30
21
|
coderay (~> 1.1.0)
|
@@ -44,10 +35,7 @@ GEM
|
|
44
35
|
rspec-support (~> 3.0.0)
|
45
36
|
rspec-support (3.0.3)
|
46
37
|
slop (3.6.0)
|
47
|
-
thread_safe (0.3.5)
|
48
38
|
timecop (0.7.1)
|
49
|
-
tzinfo (1.2.2)
|
50
|
-
thread_safe (~> 0.1)
|
51
39
|
yajl-ruby (1.2.1)
|
52
40
|
|
53
41
|
PLATFORMS
|
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
|
+
- Fixed a memory issue with HTTParty
|
9
10
|
- Timeout for requests added to fail if API is non responsive, time can be configured
|
10
11
|
- Search API returns parsed data either for counts or activities, which also makes Search API usable to get activities now
|
11
12
|
- Removed unused RateLimiter
|
@@ -170,4 +171,4 @@ In any case, you were warned about it. Feel free to fill my issues list on Githu
|
|
170
171
|
4. Push to the branch (`git push origin my-new-feature`)
|
171
172
|
5. Create a new Pull Request
|
172
173
|
|
173
|
-
This library was constructed with the help of [Armando Andini](https://github.com/antico5) who provided the basis to connect with the Gnip APIs.
|
174
|
+
This library was constructed with the help of [Armando Andini](https://github.com/antico5) who provided the basis to connect with the Gnip APIs.
|
data/gnip_api.gemspec
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
# other words, this just defines basic methods to provide the
|
5
5
|
# custom adapter with basic data.
|
6
6
|
#
|
7
|
+
# A few requirements to avoid issues for the adapter you want to use:
|
8
|
+
# - Should support chunked read of stream
|
9
|
+
# - Should handle compression (Excon seems to let user handle it)
|
10
|
+
# - Shouldn't store chunked data (memory leak)
|
11
|
+
# - Should allow custom headers
|
12
|
+
# - Should allow block response
|
13
|
+
#
|
7
14
|
# To create a custom adapter, create your class, and implement the
|
8
15
|
# following methods that GnipApi::Adapter will need.
|
9
16
|
#
|
@@ -17,7 +17,7 @@ module GnipApi
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def stream_get request
|
20
|
-
HTTParty.get request.uri, :headers => request.headers, :basic_auth => auth do |data|
|
20
|
+
HTTParty.get request.uri, :headers => request.headers, :stream_body => true, :basic_auth => auth do |data|
|
21
21
|
yield(data)
|
22
22
|
end
|
23
23
|
end
|
@@ -51,7 +51,7 @@ module GnipApi
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def parse_rules data
|
54
|
-
parsed_data = GnipApi::JsonParser.parse(data)
|
54
|
+
parsed_data = GnipApi::JsonParser.new.parse(data)
|
55
55
|
parsed_data['rules'].map{|rule| GnipApi::Apis::PowerTrack::Rule.new(:value => rule['value'], :tag => rule['tag'])}
|
56
56
|
end
|
57
57
|
|
data/lib/gnip_api/apis/search.rb
CHANGED
@@ -52,7 +52,7 @@ module GnipApi
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def parse_counts_response data
|
55
|
-
parsed_data = GnipApi::JsonParser.parse(data)
|
55
|
+
parsed_data = GnipApi::JsonParser.new.parse(data)
|
56
56
|
result_set = parsed_data['results']
|
57
57
|
params = parsed_data['requestParameters']
|
58
58
|
result = {:results => [], :total_count => parsed_data['totalCount'], :next => parsed_data['next'], :request_parameters => {}}
|
@@ -66,7 +66,7 @@ module GnipApi
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def parse_activities_response data
|
69
|
-
parsed_data = GnipApi::JsonParser.parse(data)
|
69
|
+
parsed_data = GnipApi::JsonParser.new.parse(data)
|
70
70
|
result_set = parsed_data['results']
|
71
71
|
params = parsed_data['requestParameters']
|
72
72
|
result = {:results => [], :next => parsed_data['next'], :request_parameters => {}}
|
data/lib/gnip_api/json_parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module GnipApi
|
2
2
|
class JsonParser
|
3
|
-
def
|
3
|
+
def parse data
|
4
4
|
begin
|
5
5
|
return parser.parse(data)
|
6
6
|
rescue Yajl::ParseError => error
|
@@ -8,16 +8,16 @@ module GnipApi
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def encode data
|
12
12
|
return encoder.encode(data)
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
|
-
def
|
16
|
+
def parser
|
17
17
|
Yajl::Parser.new
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def encoder
|
21
21
|
Yajl::Encoder.new
|
22
22
|
end
|
23
23
|
end
|
data/lib/gnip_api/response.rb
CHANGED
data/lib/gnip_api/version.rb
CHANGED
@@ -3,14 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe GnipApi::JsonParser do
|
4
4
|
describe ".parse" do
|
5
5
|
it 'parses a JSON object' do
|
6
|
-
output = GnipApi::JsonParser.parse('{"key":"value","key2":"value2"}')
|
6
|
+
output = GnipApi::JsonParser.new.parse('{"key":"value","key2":"value2"}')
|
7
7
|
expect(output).to eq({'key' => 'value', 'key2' => 'value2'})
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".encode" do
|
12
12
|
it 'generates a JSON object' do
|
13
|
-
output = GnipApi::JsonParser.encode({:key => 'value', :key2 => 'value2'})
|
13
|
+
output = GnipApi::JsonParser.new.encode({:key => 'value', :key2 => 'value2'})
|
14
14
|
expect(output).to eq('{"key":"value","key2":"value2"}')
|
15
15
|
end
|
16
16
|
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.
|
4
|
+
version: 0.0.9
|
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-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: activesupport
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: addressable
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|