gnip_api 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +60 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/console +10 -0
- data/gnip_api.gemspec +30 -0
- data/lib/gnip_api/adapter.rb +40 -0
- data/lib/gnip_api/adapters/httparty_adapter.rb +6 -0
- data/lib/gnip_api/apis/power_track/buffer.rb +34 -0
- data/lib/gnip_api/apis/power_track/rules.rb +17 -0
- data/lib/gnip_api/apis/power_track/stream.rb +60 -0
- data/lib/gnip_api/configuration.rb +10 -0
- data/lib/gnip_api/endpoints.rb +13 -0
- data/lib/gnip_api/gnip/actor.rb +34 -0
- data/lib/gnip_api/gnip/message.rb +71 -0
- data/lib/gnip_api/version.rb +3 -0
- data/lib/gnip_api.rb +36 -0
- data/spec/gnip_api/apis/power_track/buffer_spec.rb +58 -0
- data/spec/gnip_api/configuration_spec.rb +16 -0
- data/spec/gnip_api/endpoints_spec.rb +56 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/test_spec.rb +7 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dbd9204b40905addd74370eaac461f346a222cdf
|
4
|
+
data.tar.gz: 86b9866f63329adf2e63f82431cb8dec3bf489cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b0a11c8baa694d2e5da35342f7aaa1140386d3fd1f6da1fc9c9d90f4a67546d9d03400b72548315705a8f26e8a4d1889ae60ca7b7fee88ac82741ff5b9c4f56
|
7
|
+
data.tar.gz: de879b08e0fe1c5c7b0f6eed2dff14190c6418fa757b36933c89adee5d8b928791c123458489e6fb21e4aae32a0c594985dbaa2e6dd67ae35e18a3e82b3ddb24
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
.bundle
|
8
|
+
.watchr
|
9
|
+
.redcar
|
10
|
+
.project
|
11
|
+
log/*.log*
|
12
|
+
tmp/*
|
13
|
+
.idea/
|
14
|
+
*~
|
15
|
+
*#*#*
|
16
|
+
.DS_Store
|
17
|
+
coverage/*
|
18
|
+
*.swp
|
19
|
+
*.iml
|
20
|
+
.rvmrc
|
21
|
+
dump.rdb
|
22
|
+
test_env.rb
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gnip_api (0.0.1)
|
5
|
+
activesupport
|
6
|
+
httparty
|
7
|
+
json
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (4.2.1)
|
13
|
+
i18n (~> 0.7)
|
14
|
+
json (~> 1.7, >= 1.7.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
awesome_print (1.2.0)
|
19
|
+
coderay (1.1.0)
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
httparty (0.13.5)
|
22
|
+
json (~> 1.8)
|
23
|
+
multi_xml (>= 0.5.2)
|
24
|
+
i18n (0.7.0)
|
25
|
+
json (1.8.3)
|
26
|
+
method_source (0.8.2)
|
27
|
+
minitest (5.7.0)
|
28
|
+
multi_xml (0.5.5)
|
29
|
+
pry (0.10.1)
|
30
|
+
coderay (~> 1.1.0)
|
31
|
+
method_source (~> 0.8.1)
|
32
|
+
slop (~> 3.4)
|
33
|
+
rake (10.4.2)
|
34
|
+
rspec (3.0.0)
|
35
|
+
rspec-core (~> 3.0.0)
|
36
|
+
rspec-expectations (~> 3.0.0)
|
37
|
+
rspec-mocks (~> 3.0.0)
|
38
|
+
rspec-core (3.0.3)
|
39
|
+
rspec-support (~> 3.0.0)
|
40
|
+
rspec-expectations (3.0.3)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.0.0)
|
43
|
+
rspec-mocks (3.0.3)
|
44
|
+
rspec-support (~> 3.0.0)
|
45
|
+
rspec-support (3.0.3)
|
46
|
+
slop (3.6.0)
|
47
|
+
thread_safe (0.3.5)
|
48
|
+
tzinfo (1.2.2)
|
49
|
+
thread_safe (~> 0.1)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
awesome_print
|
56
|
+
bundler (~> 1.6)
|
57
|
+
gnip_api!
|
58
|
+
pry
|
59
|
+
rake (~> 10.0)
|
60
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Rayko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# GnipApi
|
2
|
+
|
3
|
+
You can connect with Gnip APIs with this gem and operate data. For now there's only a basic set of apis implemented, but I plan to include more in the future.
|
4
|
+
The PowerTrack stream consumer is available as well as the listing of rules. Full rules operation will be included later.
|
5
|
+
Also the gem will support different adapters, currently it's dependent of HTTParty, but I plan to remove this dependency and let the user choose which adapter to use, which can be a custom one of course. You will be able to define your own adapter to handle the http connections.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gnip_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gnip_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/gnip_api/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/console
ADDED
data/gnip_api.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gnip_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gnip_api"
|
8
|
+
spec.version = GnipApi::VERSION
|
9
|
+
spec.authors = ["Rayko"]
|
10
|
+
spec.email = ["rayko.drg@gmail.com"]
|
11
|
+
spec.summary = %q{GnipApi provides exposes all Gnip APIs.}
|
12
|
+
spec.description = %q{GnipApi will allow you to interact with most Gnip APIs and data.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "awesome_print"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
|
27
|
+
spec.add_dependency "httparty"
|
28
|
+
spec.add_dependency "json"
|
29
|
+
spec.add_dependency "activesupport"
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module GnipApi
|
2
|
+
class Adapter
|
3
|
+
attr_reader :adapter
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@adapter = DevAdapter.new # GnipApi.configuration.adapter_class.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def get url
|
10
|
+
DevAdapter.get url
|
11
|
+
end
|
12
|
+
|
13
|
+
def stream_get url
|
14
|
+
DevAdapter.stream_get url do |data|
|
15
|
+
yield(data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class DevAdapter
|
21
|
+
class << self
|
22
|
+
def stream_get url
|
23
|
+
HTTParty.get url, :basic_auth => auth do |data|
|
24
|
+
yield(data)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get url
|
29
|
+
HTTParty.get url, :basic_auth => auth
|
30
|
+
end
|
31
|
+
|
32
|
+
def auth
|
33
|
+
{
|
34
|
+
:username => GnipApi.configuration.user,
|
35
|
+
:password => GnipApi.configuration.password
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module GnipApi
|
2
|
+
module Apis
|
3
|
+
module PowerTrack
|
4
|
+
class Buffer
|
5
|
+
attr_reader :terminator, :data
|
6
|
+
|
7
|
+
def initialize options={}
|
8
|
+
@terminator = options.delete(:terminator) || "\r\n"
|
9
|
+
@data = ""
|
10
|
+
end
|
11
|
+
|
12
|
+
def insert! chunk
|
13
|
+
@data << chunk
|
14
|
+
end
|
15
|
+
|
16
|
+
def read!
|
17
|
+
objects = @data.split(terminator)[0..-2]
|
18
|
+
unless objects.empty?
|
19
|
+
# Get the number of chars to read from buffer, counting
|
20
|
+
# the size of each splited chunk plus the number of chunks by
|
21
|
+
# terminator size, since it's still present in the buffer
|
22
|
+
size = objects.map(&:size).reduce(:+) + objects.size * terminator.size
|
23
|
+
consume!(size)
|
24
|
+
end
|
25
|
+
return objects
|
26
|
+
end
|
27
|
+
|
28
|
+
def consume! chars
|
29
|
+
@data[0..chars-1] = ''
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GnipApi
|
2
|
+
module Apis
|
3
|
+
module PowerTrack
|
4
|
+
class Rules
|
5
|
+
attr_reader :adapter
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@adapter = GnipApi::Adapter.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def list
|
12
|
+
adapter.get GnipApi::Endpoints.powertrack_rules('twitter', 'prod')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module GnipApi
|
2
|
+
module Apis
|
3
|
+
module PowerTrack
|
4
|
+
class Stream
|
5
|
+
attr_reader :system_messages, :adapter
|
6
|
+
|
7
|
+
def initialize params = {}
|
8
|
+
@stream = params[:stream]
|
9
|
+
@source = params[:source]
|
10
|
+
set_config
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
GnipApi.logger
|
15
|
+
end
|
16
|
+
|
17
|
+
def consume
|
18
|
+
adapter.stream_get endpoint do |chunk|
|
19
|
+
@buffer.insert! chunk
|
20
|
+
yield(@buffer.read!)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def set_config
|
27
|
+
@user = GnipApi.configuration.user
|
28
|
+
@password = GnipApi.configuration.password
|
29
|
+
@account = GnipApi.configuration.account
|
30
|
+
@adapter = GnipApi::Adapter.new
|
31
|
+
@buffer = GnipApi::Apis::PowerTrack::Buffer.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle message
|
35
|
+
@system_messages << message if message.system_message?
|
36
|
+
yield message if message.activity?
|
37
|
+
end
|
38
|
+
|
39
|
+
def endpoint
|
40
|
+
GnipApi::Endpoints.powertrack_stream(@source, @stream)
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse data
|
44
|
+
json_parse(extract_messages(data)).map { |hash| Message.build hash }
|
45
|
+
end
|
46
|
+
|
47
|
+
def json_parse messages
|
48
|
+
messages.map do |message|
|
49
|
+
begin
|
50
|
+
JSON.parse message
|
51
|
+
rescue JSON::ParserError
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module GnipApi
|
2
|
+
class Endpoints
|
3
|
+
class << self
|
4
|
+
def powertrack_rules source, label
|
5
|
+
URI("https://api.gnip.com:443/accounts/#{GnipApi.configuration.account}/publishers/#{source}/streams/track/#{label}/rules.json")
|
6
|
+
end
|
7
|
+
|
8
|
+
def powertrack_stream source, label
|
9
|
+
URI("https://stream.gnip.com:443/accounts/#{GnipApi.configuration.account}/publishers/#{source}/streams/track/#{label}.json")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Gnip
|
2
|
+
class Actor
|
3
|
+
attr_accessor :id, :object_type, :link, :display_name, :image, :summary,
|
4
|
+
:location, :friends_count, :followers_count, :statuses_count
|
5
|
+
|
6
|
+
def initialize params = {}
|
7
|
+
@id = params['id']
|
8
|
+
@object_type = params['objectType']
|
9
|
+
@link = params['link']
|
10
|
+
@display_name = params['displayName']
|
11
|
+
@image = params['image']
|
12
|
+
@summary = params['summary']
|
13
|
+
@location = params['location']
|
14
|
+
@friends_count = params['friendsCount']
|
15
|
+
@followers_count = params['followersCount']
|
16
|
+
@statuses_count = params['statusesCount']
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
{
|
21
|
+
:id => @id,
|
22
|
+
:object_type => @object_type,
|
23
|
+
:link => @link,
|
24
|
+
:display_name => @display_name,
|
25
|
+
:image => @image,
|
26
|
+
:summary => @summary,
|
27
|
+
:location => @location,
|
28
|
+
:friends_count => @friends_count,
|
29
|
+
:followers_count => @followers_count,
|
30
|
+
:statuses_count => @statuses_count
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Gnip
|
2
|
+
class Message
|
3
|
+
def self.build params
|
4
|
+
if params['error'] || params['warn'] || params['info']
|
5
|
+
SystemMessage.new params
|
6
|
+
elsif params['id']
|
7
|
+
Activity.new params
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def system_message?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def activity?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class SystemMessage < Message
|
21
|
+
attr_accessor :message, :sent
|
22
|
+
|
23
|
+
def initialize params
|
24
|
+
@message = params['message']
|
25
|
+
@sent = params['sent']
|
26
|
+
end
|
27
|
+
|
28
|
+
def system_message?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Activity < Message
|
34
|
+
attr_accessor :id, :actor, :object_type, :verb, :posted_time, :provider, :link, :body
|
35
|
+
def initialize params = {}
|
36
|
+
@id = params['id']
|
37
|
+
@object_type = params['objectType']
|
38
|
+
@verb = params['verb']
|
39
|
+
@posted_time = params['postedTime']
|
40
|
+
@provider = params['provider']
|
41
|
+
@link = params['link']
|
42
|
+
@body = retweet? ? params['object']['body'] : params['body']
|
43
|
+
@actor = Actor.new params['actor']
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_json
|
47
|
+
{
|
48
|
+
:id => @id,
|
49
|
+
:actor => @actor.to_json,
|
50
|
+
:object_type => @object_type,
|
51
|
+
:verb => @verb,
|
52
|
+
:posted_time => @posted_time,
|
53
|
+
:provider => @provider,
|
54
|
+
:link => @link,
|
55
|
+
:body => @body
|
56
|
+
}.to_json
|
57
|
+
end
|
58
|
+
|
59
|
+
def author
|
60
|
+
actor.display_name
|
61
|
+
end
|
62
|
+
|
63
|
+
def activity?
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
def retweet?
|
68
|
+
verb == 'share'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/gnip_api.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "gnip_api/version"
|
2
|
+
require "gnip_api/configuration"
|
3
|
+
require "gnip_api/endpoints"
|
4
|
+
require "gnip_api/apis/power_track/stream"
|
5
|
+
require "gnip_api/apis/power_track/rules"
|
6
|
+
require "gnip_api/apis/power_track/buffer"
|
7
|
+
require "gnip_api/gnip/message"
|
8
|
+
require "gnip_api/gnip/actor"
|
9
|
+
require "gnip_api/adapter"
|
10
|
+
require "gnip_api/adapters/httparty_adapter"
|
11
|
+
|
12
|
+
# External
|
13
|
+
require 'httparty'
|
14
|
+
require 'json'
|
15
|
+
require 'logger'
|
16
|
+
require 'uri'
|
17
|
+
|
18
|
+
|
19
|
+
module GnipApi
|
20
|
+
class << self
|
21
|
+
attr_reader :configuration
|
22
|
+
|
23
|
+
def configuration
|
24
|
+
@configuration ||= Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def configure
|
28
|
+
yield(configuration)
|
29
|
+
self.configuration
|
30
|
+
end
|
31
|
+
|
32
|
+
def logger
|
33
|
+
self.configuration.logger
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GnipApi::Apis::PowerTrack::Buffer do
|
4
|
+
before do
|
5
|
+
@buffer = GnipApi::Apis::PowerTrack::Buffer.new(:terminator => '--')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'has "--" as terminator char' do
|
9
|
+
expect(@buffer.terminator).to eq('--')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'stores string data' do
|
13
|
+
expect(@buffer.data.kind_of?(String)).to eq(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#insert!' do
|
17
|
+
it 'apends data at the end' do
|
18
|
+
@buffer.insert! "asd"
|
19
|
+
expect(@buffer.data[-1]).to eq('d')
|
20
|
+
@buffer.insert! 'lol'
|
21
|
+
expect(@buffer.data[-1]).to eq('l')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#read!' do
|
26
|
+
context 'with partial data' do
|
27
|
+
before do
|
28
|
+
@buffer.insert! 'asd--qwe--x'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'gets complete objects' do
|
32
|
+
objects = @buffer.read!
|
33
|
+
expect(objects.empty?).to eq(false)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'consumes data from buffer' do
|
37
|
+
@buffer.read!
|
38
|
+
expect(@buffer.data).to eq('x')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with complete data' do
|
43
|
+
before do
|
44
|
+
@buffer.insert! 'asd--qwe--zxc'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'gets complete objects except for last one' do
|
48
|
+
objects = @buffer.read!
|
49
|
+
expect(objects.size).to eq(2)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'removes the data read' do
|
53
|
+
@buffer.read!
|
54
|
+
expect(@buffer.data.include?('asd')).to eq(false)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GnipApi::Configuration do
|
4
|
+
describe '#new' do
|
5
|
+
it 'has the default values' do
|
6
|
+
config = GnipApi::Configuration.new
|
7
|
+
|
8
|
+
expect(config.user).to eq(nil)
|
9
|
+
expect(config.password).to eq(nil)
|
10
|
+
expect(config.account).to eq(nil)
|
11
|
+
expect(config.adapter_class).to eq(GnipApi::Adapters::HTTPartyAdapter)
|
12
|
+
expect(config.logger).not_to eq(nil)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GnipApi::Endpoints do
|
4
|
+
before do
|
5
|
+
configure_gem
|
6
|
+
@source = 'somewhere'
|
7
|
+
@label = 'stream'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.powertrack_rules' do
|
11
|
+
it 'returns URI object' do
|
12
|
+
expect(GnipApi::Endpoints.powertrack_rules(@source, @label).kind_of?(URI)).to eq(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'URI returned' do
|
16
|
+
before do
|
17
|
+
@uri = GnipApi::Endpoints.powertrack_rules(@source, @label)
|
18
|
+
end
|
19
|
+
it 'contains source in path' do
|
20
|
+
expect(@uri.path.include?(@source)).to eq(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'contains label in path' do
|
24
|
+
expect(@uri.path.include?(@label)).to eq(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'includes account in path' do
|
28
|
+
expect(@uri.path.include?(GnipApi.configuration.account)).to eq(true)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.powertrack_stream' do
|
34
|
+
it 'returns URI object' do
|
35
|
+
expect(GnipApi::Endpoints.powertrack_stream(@source, @label).kind_of?(URI)).to eq(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'URI returned' do
|
39
|
+
before do
|
40
|
+
@uri = GnipApi::Endpoints.powertrack_stream(@source, @label)
|
41
|
+
end
|
42
|
+
it 'contains source in path' do
|
43
|
+
expect(@uri.path.include?(@source)).to eq(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'contains label in path' do
|
47
|
+
expect(@uri.path.include?(@label)).to eq(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'includes account in path' do
|
51
|
+
expect(@uri.path.include?(GnipApi.configuration.account)).to eq(true)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/test_spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gnip_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rayko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: awesome_print
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: httparty
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: GnipApi will allow you to interact with most Gnip APIs and data.
|
126
|
+
email:
|
127
|
+
- rayko.drg@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- Gemfile
|
134
|
+
- Gemfile.lock
|
135
|
+
- LICENSE.txt
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- console
|
139
|
+
- gnip_api.gemspec
|
140
|
+
- lib/gnip_api.rb
|
141
|
+
- lib/gnip_api/adapter.rb
|
142
|
+
- lib/gnip_api/adapters/httparty_adapter.rb
|
143
|
+
- lib/gnip_api/apis/power_track/buffer.rb
|
144
|
+
- lib/gnip_api/apis/power_track/rules.rb
|
145
|
+
- lib/gnip_api/apis/power_track/stream.rb
|
146
|
+
- lib/gnip_api/configuration.rb
|
147
|
+
- lib/gnip_api/endpoints.rb
|
148
|
+
- lib/gnip_api/gnip/actor.rb
|
149
|
+
- lib/gnip_api/gnip/message.rb
|
150
|
+
- lib/gnip_api/version.rb
|
151
|
+
- spec/gnip_api/apis/power_track/buffer_spec.rb
|
152
|
+
- spec/gnip_api/configuration_spec.rb
|
153
|
+
- spec/gnip_api/endpoints_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/test_spec.rb
|
156
|
+
homepage: ''
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.2.1
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: GnipApi provides exposes all Gnip APIs.
|
180
|
+
test_files:
|
181
|
+
- spec/gnip_api/apis/power_track/buffer_spec.rb
|
182
|
+
- spec/gnip_api/configuration_spec.rb
|
183
|
+
- spec/gnip_api/endpoints_spec.rb
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
- spec/test_spec.rb
|