gnip-rules 2.1.0 → 2.2.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 +4 -4
- data/VERSION +1 -1
- data/lib/gnip-rules.rb +1 -0
- data/lib/gnip-rules/historical/powertrack.rb +110 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05d1349e67e552fe8e5e994cbe20ef3e510b56d6
|
4
|
+
data.tar.gz: 48e073490fc7862d60985b33c6579e329584d144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64312248df0219686725682352ae5b262f0b8ed53a5de64e6d26b8b453e7149105cd8207a608dda67ef4725bd89ed36340a84307d321f122dd5c9cd139986b04
|
7
|
+
data.tar.gz: 00df795f662a168d51d84f0ee73599218dcbc1df600d3db4585a3a397a3e8300a16e31a434b293b238dc6db2f618aee0ab756c8209ceb875b83ebbfbe1ad0875
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1
|
1
|
+
2.2.1
|
data/lib/gnip-rules.rb
CHANGED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'httparty'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require 'gnip-rules/api'
|
6
|
+
require 'gnip-rules/validation_response'
|
7
|
+
require 'gnip-rules/rule'
|
8
|
+
|
9
|
+
module Gnip
|
10
|
+
module Historical
|
11
|
+
class Powertrack
|
12
|
+
include HTTParty
|
13
|
+
|
14
|
+
headers 'Accept' => 'application/json', 'Content-Type' => 'application/json'
|
15
|
+
format :json
|
16
|
+
|
17
|
+
#debug_output $stdout
|
18
|
+
|
19
|
+
JOB_URL_PATH = "/jobs"
|
20
|
+
JOBS_URL_PATH = "/jobs"
|
21
|
+
|
22
|
+
def initialize( configuration = nil, username = nil, password = nil, uri = nil, timeout = 60 )
|
23
|
+
@configuration_file = configuration
|
24
|
+
unless username && password && uri
|
25
|
+
load_credentials!
|
26
|
+
username = @config["username"]
|
27
|
+
password = @config["password"]
|
28
|
+
uri = uri || @config["historical_powertrack_url"]
|
29
|
+
end
|
30
|
+
|
31
|
+
self.class.basic_auth username , password
|
32
|
+
self.class.base_uri uri
|
33
|
+
self.class.default_timeout timeout
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_timeout(timeout)
|
37
|
+
self.class.default_timeout timeout
|
38
|
+
self.class.default_options
|
39
|
+
end
|
40
|
+
|
41
|
+
def job(uuid)
|
42
|
+
self.class.get "#{JOB_URL_PATH}/#{uuid}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def create(opts)
|
46
|
+
#dataFormat: 'original'
|
47
|
+
#fromDate: 201808280000
|
48
|
+
#toDate: 201808290000
|
49
|
+
#title: 'Spencer Test DO NOT RUN'
|
50
|
+
#rules: []
|
51
|
+
job_opts = ActiveSupport::JSON.encode( opts.merge!({publisher: 'twitter', streamType: 'track_v2', dataFormat: 'activity_streams'}) )
|
52
|
+
self.class.post(JOBS_URL_PATH, body: job_opts)
|
53
|
+
end
|
54
|
+
|
55
|
+
def jobs
|
56
|
+
self.class.get JOBS_URL_PATH
|
57
|
+
end
|
58
|
+
|
59
|
+
def accept(uuid)
|
60
|
+
opts = ActiveSupport::JSON.encode( {status: 'accept'} )
|
61
|
+
self.class.put "#{JOB_URL_PATH}/#{uuid}", body: opts
|
62
|
+
end
|
63
|
+
|
64
|
+
def reject(uuid)
|
65
|
+
opts = ActiveSupport::JSON.encode( {status: 'reject'} )
|
66
|
+
self.class.put "#{JOB_URL_PATH}/#{uuid}", body: opts
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_results(uuid)
|
70
|
+
self.class.get "#{JOB_URL_PATH}/#{uuid}/results"
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def load_credentials!
|
77
|
+
if File.exists?( @configuration_file )
|
78
|
+
@config = YAML.load_file( @configuration_file )[environment.to_s]
|
79
|
+
else
|
80
|
+
raise Exception.new( <<-RUBY
|
81
|
+
You must provide a configuration file at config/gnip.yml
|
82
|
+
|
83
|
+
development: &development
|
84
|
+
username: omg@omg.com
|
85
|
+
password: your_password
|
86
|
+
account: your_account
|
87
|
+
streaming_url: 'https://gnip-stream.twitter.com/stream/powertrack/accounts/YOUR_ACCOUNT/publishers/twitter/Sandbox.json'
|
88
|
+
rules_api: 'https://gnip-api.twitter.com/rules/powertrack/accounts/YOUR_ACCOUNT/publishers/twitter/Sandbox.json'
|
89
|
+
validation_url: 'https://gnip-api.twitter.com/rules/powertrack/accounts/<accountName>/<streamLabel>/validation.json'
|
90
|
+
|
91
|
+
RUBY
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def environment
|
97
|
+
if defined?(Rails)
|
98
|
+
Rails.env
|
99
|
+
elsif defined?(RAILS_ENV)
|
100
|
+
RAILS_ENV
|
101
|
+
elsif defined?(RACK_ENV)
|
102
|
+
RACK_ENV
|
103
|
+
else
|
104
|
+
:development
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnip-rules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spencer Markowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- gnip-rules.gemspec
|
86
86
|
- lib/gnip-rules.rb
|
87
87
|
- lib/gnip-rules/api.rb
|
88
|
+
- lib/gnip-rules/historical/powertrack.rb
|
88
89
|
- lib/gnip-rules/response.rb
|
89
90
|
- lib/gnip-rules/rule.rb
|
90
91
|
- lib/gnip-rules/validation.rb
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: '0'
|
114
115
|
requirements: []
|
115
116
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.6.11
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: A simple wrapper for the Gnip Rules API
|