datasift 2.1.1 → 3.0.0.beta
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/.gitignore +1 -0
- data/CHANGELOG.md +100 -0
- data/Gemfile.lock +32 -0
- data/README.md +38 -79
- data/VERSION +1 -1
- data/datasift.gemspec +21 -24
- data/examples/auth.rb +44 -0
- data/examples/core_api_eg.rb +46 -0
- data/examples/historics_eg.rb +50 -0
- data/examples/historics_preview_eg.rb +30 -0
- data/examples/live_stream_eg.rb +89 -0
- data/examples/managed_source_eg.rb +56 -0
- data/examples/pull.rb +44 -0
- data/examples/push_eg.rb +56 -0
- data/lib/api/api_resource.rb +23 -0
- data/lib/datasift.rb +287 -14
- data/lib/errors.rb +59 -0
- data/lib/historics.rb +76 -0
- data/lib/historics_preview.rb +20 -0
- data/lib/live_stream.rb +53 -0
- data/lib/managed_source.rb +57 -0
- data/lib/push.rb +156 -0
- data/tests/core_api_test.rb +42 -0
- metadata +51 -73
- data/Rakefile +0 -34
- data/config.yml +0 -2
- data/examples/consume-stream.rb +0 -63
- data/examples/deletes.rb +0 -52
- data/examples/dpu.rb +0 -115
- data/examples/football-buffered.rb +0 -51
- data/examples/football.rb +0 -53
- data/examples/historics.sh +0 -2
- data/examples/historics/create-from-csdl.rb +0 -71
- data/examples/historics/create-from-hash.rb +0 -65
- data/examples/historics/delete.rb +0 -30
- data/examples/historics/env.rb +0 -37
- data/examples/historics/list.rb +0 -30
- data/examples/historics/start.rb +0 -30
- data/examples/historics/stop.rb +0 -30
- data/examples/historics/view.rb +0 -28
- data/examples/push.sh +0 -2
- data/examples/push/delete.rb +0 -33
- data/examples/push/env.rb +0 -53
- data/examples/push/list.rb +0 -30
- data/examples/push/pause.rb +0 -33
- data/examples/push/push-from-hash.rb +0 -72
- data/examples/push/push-historic-from-csdl.rb +0 -98
- data/examples/push/push-stream-from-csdl.rb +0 -70
- data/examples/push/resume.rb +0 -33
- data/examples/push/stop.rb +0 -33
- data/examples/push/view-log.rb +0 -45
- data/examples/push/view.rb +0 -31
- data/examples/twitter-track.rb +0 -61
- data/lib/DataSift/apiclient.rb +0 -73
- data/lib/DataSift/definition.rb +0 -202
- data/lib/DataSift/exceptions.rb +0 -33
- data/lib/DataSift/historic.rb +0 -316
- data/lib/DataSift/managed_source.rb +0 -263
- data/lib/DataSift/mockapiclient.rb +0 -44
- data/lib/DataSift/push_definition.rb +0 -115
- data/lib/DataSift/push_subscription.rb +0 -330
- data/lib/DataSift/stream_consumer.rb +0 -166
- data/lib/DataSift/stream_consumer_http.rb +0 -188
- data/lib/DataSift/user.rb +0 -311
- data/test/helper.rb +0 -95
- data/test/test_definition.rb +0 -273
- data/test/test_historics.rb +0 -233
- data/test/test_pushdefinition.rb +0 -92
- data/test/test_pushsubscription.rb +0 -17
- data/test/test_user.rb +0 -130
- data/test/testdata.yml +0 -30
@@ -1,51 +0,0 @@
|
|
1
|
-
# This example constructs a DataSift_Definition object with CSDL that looks
|
2
|
-
# for anything containing the word "football". It then sits in a loop,
|
3
|
-
# getting buffered interactions once every 10 seconds until it's retrieved
|
4
|
-
# 10.
|
5
|
-
#
|
6
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
7
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
8
|
-
# exceptions, and production code should catch them. See the documentation
|
9
|
-
# for full details.
|
10
|
-
#
|
11
|
-
|
12
|
-
# Include the DataSift library
|
13
|
-
require './' + File.dirname(__FILE__) + '/../lib/datasift'
|
14
|
-
|
15
|
-
# Include the configuration - put your username and API key in this file
|
16
|
-
require 'yaml'
|
17
|
-
config = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', 'config.yml')))
|
18
|
-
|
19
|
-
# Authenticate
|
20
|
-
puts 'Creating user...'
|
21
|
-
user = DataSift::User.new(config['username'], config['api_key'])
|
22
|
-
|
23
|
-
# Create the definition
|
24
|
-
csdl = 'interaction.content contains "football"'
|
25
|
-
puts 'Creating definition...'
|
26
|
-
puts ' ' + csdl
|
27
|
-
definition = user.createDefinition(csdl)
|
28
|
-
|
29
|
-
# Get buffered interactions until we've had 10
|
30
|
-
puts 'Getting buffered interactions...'
|
31
|
-
puts '--'
|
32
|
-
num = 10
|
33
|
-
from_id = false
|
34
|
-
begin
|
35
|
-
interactions = definition.getBuffered(num, from_id)
|
36
|
-
interactions.each do |interaction|
|
37
|
-
puts 'Type: ' + interaction['interaction']['type']
|
38
|
-
puts 'Content: ' + interaction['interaction']['content']
|
39
|
-
puts '--'
|
40
|
-
num -= 1
|
41
|
-
from_id = interaction['interaction']['id']
|
42
|
-
end
|
43
|
-
|
44
|
-
if num > 0
|
45
|
-
sleep(10)
|
46
|
-
end
|
47
|
-
end while num > 0
|
48
|
-
|
49
|
-
puts
|
50
|
-
puts 'Fetched 10 interactions, we\'re done.'
|
51
|
-
puts
|
data/examples/football.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# This example constructs a DataSift_Definition object with CSDL that looks
|
2
|
-
# for anything containing the word "football". It then gets an HTTP
|
3
|
-
# consumer for that definition and displays matching interactions to the
|
4
|
-
# screen as they come in. It will display 10 interactions and then stop.
|
5
|
-
#
|
6
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
7
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
8
|
-
# exceptions, and production code should catch them. See the documentation
|
9
|
-
# for full details.
|
10
|
-
#
|
11
|
-
|
12
|
-
# Include the DataSift library
|
13
|
-
require './' + File.dirname(__FILE__) + '/../lib/datasift'
|
14
|
-
|
15
|
-
# Include the configuration - put your username and API key in this file
|
16
|
-
require 'yaml'
|
17
|
-
config = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', 'config.yml')))
|
18
|
-
|
19
|
-
# Authenticate
|
20
|
-
puts 'Creating user...'
|
21
|
-
user = DataSift::User.new(config['username'], config['api_key'])
|
22
|
-
|
23
|
-
# Create the definition
|
24
|
-
csdl = 'interaction.content contains "football"'
|
25
|
-
puts 'Creating definition...'
|
26
|
-
puts ' ' + csdl
|
27
|
-
definition = user.createDefinition(csdl)
|
28
|
-
|
29
|
-
# Create the consumer
|
30
|
-
puts 'Getting the consumer...'
|
31
|
-
consumer = definition.getConsumer(DataSift::StreamConsumer::TYPE_HTTP)
|
32
|
-
|
33
|
-
# And start consuming
|
34
|
-
puts 'Consuming...'
|
35
|
-
puts '--'
|
36
|
-
count = 10
|
37
|
-
consumer.consume(true) do |interaction|
|
38
|
-
if interaction
|
39
|
-
puts 'Type: ' + interaction['interaction']['type']
|
40
|
-
puts 'Content: ' + interaction['interaction']['content']
|
41
|
-
puts '--'
|
42
|
-
|
43
|
-
count -= 1
|
44
|
-
if count == 0
|
45
|
-
puts 'Stopping consumer...'
|
46
|
-
consumer.stop()
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
puts
|
52
|
-
puts 'Finished consuming'
|
53
|
-
puts
|
data/examples/historics.sh
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# This script creates a new Historics query from a file containing CSDL.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Function to display usage instructions with an optional error message.
|
10
|
-
def usage(message = '', end_of_story = true)
|
11
|
-
puts message + '\n' unless message.length() == 0
|
12
|
-
puts
|
13
|
-
puts 'Usage: create-from-csdl <username> <api_key> \\'
|
14
|
-
puts ' <csdl_filename> <start> <end> <sources> <sample> <name>'
|
15
|
-
puts
|
16
|
-
puts 'Where: csdl_filename = the stream hash the query should run'
|
17
|
-
puts ' start = the start date for the query (YYYYMMDDHHMMSS)'
|
18
|
-
puts ' end = the end date for the query (YYYYMMDDHHMMSS)'
|
19
|
-
puts ' sources = comma separated list of data sources (e.g. twitter)'
|
20
|
-
puts ' sample = the sample rate'
|
21
|
-
puts ' name = a friendly name for the query'
|
22
|
-
puts
|
23
|
-
puts 'Example'
|
24
|
-
puts ' create-from-csdl csdl.txt 20120101000000 20120101235959 \\'
|
25
|
-
puts ' twitter 100 HistoricsQuery123'
|
26
|
-
puts
|
27
|
-
exit 1 unless not end_of_story
|
28
|
-
end
|
29
|
-
|
30
|
-
# Include the shared Env class
|
31
|
-
require File.dirname(__FILE__) + '/env'
|
32
|
-
|
33
|
-
# Create the env object. This reads the command line arguments, creates the
|
34
|
-
# user object, and provides access to both along with helper functions.
|
35
|
-
env = Env.new()
|
36
|
-
|
37
|
-
# Check that we have enough arguments
|
38
|
-
usage() unless env.args.size() == 6
|
39
|
-
|
40
|
-
# Read the arguments
|
41
|
-
csdl_filename = env.args[0]
|
42
|
-
start_date = env.args[1]
|
43
|
-
end_date = env.args[2]
|
44
|
-
sources = env.args[3].split(',')
|
45
|
-
sample = env.args[4]
|
46
|
-
name = env.args[5]
|
47
|
-
|
48
|
-
# Parse the dates
|
49
|
-
start_date = DateTime.strptime(start_date, '%Y%m%d%H%M%S')
|
50
|
-
end_date = DateTime.strptime(end_date, '%Y%m%d%H%M%S')
|
51
|
-
|
52
|
-
# Read the CSDL
|
53
|
-
csdl = File.open(csdl_filename, 'r').read
|
54
|
-
|
55
|
-
begin
|
56
|
-
# Create the definition
|
57
|
-
definition = env.user.createDefinition(csdl)
|
58
|
-
|
59
|
-
# Create the Historics query
|
60
|
-
historic = definition.createHistoric(start_date, end_date, sources, sample, name)
|
61
|
-
|
62
|
-
# Prepare the query
|
63
|
-
historic.prepare()
|
64
|
-
|
65
|
-
# Display the details
|
66
|
-
env.displayHistoricDetails(historic)
|
67
|
-
|
68
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
69
|
-
rescue DataSift::DataSiftError => err
|
70
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
71
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# This script creates a new Historics query from a stream hash.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Function to display usage instructions with an optional error message.
|
10
|
-
def usage(message = '', end_of_story = true)
|
11
|
-
puts message + '\n' unless message.length() == 0
|
12
|
-
puts
|
13
|
-
puts 'Usage: create-from-hash \\'
|
14
|
-
puts ' <username> <api_key> <hash> <start> <end> <sources> <sample> <name>'
|
15
|
-
puts
|
16
|
-
puts 'Where: hash = the stream hash the query should run'
|
17
|
-
puts ' start = the start date for the query (YYYYMMDDHHMMSS)'
|
18
|
-
puts ' end = the end date for the query (YYYYMMDDHHMMSS)'
|
19
|
-
puts ' sources = comma separated list of data sources (e.g. twitter)'
|
20
|
-
puts ' sample = the sample rate'
|
21
|
-
puts ' name = a friendly name for the query'
|
22
|
-
puts
|
23
|
-
puts 'Example'
|
24
|
-
puts ' create-from-hash <hash> 20120101000000 20120101235959 \\'
|
25
|
-
puts ' twitter 100 HistoricsQuery123'
|
26
|
-
puts
|
27
|
-
exit 1 unless not end_of_story
|
28
|
-
end
|
29
|
-
|
30
|
-
# Include the shared Env class
|
31
|
-
require File.dirname(__FILE__) + '/env'
|
32
|
-
|
33
|
-
# Create the env object. This reads the command line arguments, creates the
|
34
|
-
# user object, and provides access to both along with helper functions.
|
35
|
-
env = Env.new()
|
36
|
-
|
37
|
-
# Check that we have enough arguments
|
38
|
-
usage() unless env.args.size() == 6
|
39
|
-
|
40
|
-
# Read the arguments
|
41
|
-
stream_hash = env.args[0]
|
42
|
-
start_date = env.args[1]
|
43
|
-
end_date = env.args[2]
|
44
|
-
sources = env.args[3].split(',')
|
45
|
-
sample = env.args[4]
|
46
|
-
name = env.args[5]
|
47
|
-
|
48
|
-
# Parse the dates
|
49
|
-
start_date = DateTime.strptime(start_date, '%Y%m%d%H%M%S')
|
50
|
-
end_date = DateTime.strptime(end_date, '%Y%m%d%H%M%S')
|
51
|
-
|
52
|
-
begin
|
53
|
-
# Create the Historics query
|
54
|
-
historic = env.user.createHistoric(stream_hash, start_date, end_date, sources, sample, name)
|
55
|
-
|
56
|
-
# Prepare the query
|
57
|
-
historic.prepare()
|
58
|
-
|
59
|
-
# Display the details
|
60
|
-
env.displayHistoricDetails(historic)
|
61
|
-
|
62
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
63
|
-
rescue DataSift::DataSiftError => err
|
64
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
65
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# This script deletes Historics queries from your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
# Make sure we have something to do
|
17
|
-
abort('Please specify one or more playback IDs') unless env.args.size() > 0
|
18
|
-
|
19
|
-
begin
|
20
|
-
for playback_id in env.args
|
21
|
-
historic = env.user.getHistoric(playback_id)
|
22
|
-
print 'Deleting ' + playback_id + ', "' + historic.name + '"...'
|
23
|
-
historic.delete()
|
24
|
-
puts 'done'
|
25
|
-
end
|
26
|
-
|
27
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
28
|
-
rescue DataSift::DataSiftError => err
|
29
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
30
|
-
end
|
data/examples/historics/env.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# This class is used by the Historics examples to remove the noise of
|
2
|
-
# dealing with command line arguments.
|
3
|
-
#
|
4
|
-
|
5
|
-
# Include the DataSift library
|
6
|
-
require File.dirname(__FILE__) + '/../../lib/datasift'
|
7
|
-
|
8
|
-
class Env
|
9
|
-
attr_reader :user, :args
|
10
|
-
|
11
|
-
def initialize(args = false)
|
12
|
-
if args === false
|
13
|
-
args = ARGV
|
14
|
-
end
|
15
|
-
|
16
|
-
abort('Please specify your DataSift username and API key as the first two command line arguments!') unless args.size() >= 2
|
17
|
-
|
18
|
-
username = args.shift
|
19
|
-
api_key = args.shift
|
20
|
-
@user = DataSift::User.new(username, api_key)
|
21
|
-
|
22
|
-
@args = args
|
23
|
-
end
|
24
|
-
|
25
|
-
def displayHistoricDetails(historic)
|
26
|
-
puts 'Playback ID: ' + historic.hash
|
27
|
-
puts 'Stream hash: ' + historic.stream_hash
|
28
|
-
puts 'Name: ' + historic.name
|
29
|
-
puts 'Start time: ' + historic.start_date.strftime('%Y-%m-%d %H:%M:%S')
|
30
|
-
puts 'End time: ' + historic.end_date.strftime('%Y-%m-%d %H:%M:%S')
|
31
|
-
puts 'Sources: ' + historic.sources.join(', ')
|
32
|
-
puts 'Sample: ' + String(historic.sample)
|
33
|
-
puts 'Created at: ' + (historic.created_at.nil? ? 'None' : historic.created_at.strftime('%Y-%m-%d %H:%M:%S'))
|
34
|
-
puts 'Status: ' + historic.status
|
35
|
-
puts '--'
|
36
|
-
end
|
37
|
-
end
|
data/examples/historics/list.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# This script lists Historics queries in your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
begin
|
17
|
-
historics = env.user.listHistorics()
|
18
|
-
|
19
|
-
if historics['historics'].size() == 0
|
20
|
-
puts 'No Historics queries exist in your account.'
|
21
|
-
else
|
22
|
-
for historic in historics['historics']
|
23
|
-
env.displayHistoricDetails(historic)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
28
|
-
rescue DataSift::DataSiftError => err
|
29
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
30
|
-
end
|
data/examples/historics/start.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# This script starts Historics queries in your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
# Make sure we have something to do
|
17
|
-
abort('Please specify one or more playback IDs') unless env.args.size() > 0
|
18
|
-
|
19
|
-
begin
|
20
|
-
for playback_id in env.args
|
21
|
-
historic = env.user.getHistoric(playback_id)
|
22
|
-
print 'Starting ' + playback_id + ', "' + historic.name + '"...'
|
23
|
-
historic.start()
|
24
|
-
puts 'done'
|
25
|
-
end
|
26
|
-
|
27
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
28
|
-
rescue DataSift::DataSiftError => err
|
29
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
30
|
-
end
|
data/examples/historics/stop.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# This script stops Historics queries in your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
# Make sure we have something to do
|
17
|
-
abort('Please specify one or more playback IDs') unless env.args.size() > 0
|
18
|
-
|
19
|
-
begin
|
20
|
-
for playback_id in env.args
|
21
|
-
historic = env.user.getHistoric(playback_id)
|
22
|
-
print 'Stopping ' + playback_id + ', "' + historic.name + '"...'
|
23
|
-
historic.stop()
|
24
|
-
puts 'done'
|
25
|
-
end
|
26
|
-
|
27
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
28
|
-
rescue DataSift::DataSiftError => err
|
29
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
30
|
-
end
|
data/examples/historics/view.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# This script views Historics queries in your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
# Make sure we have something to do
|
17
|
-
abort('Please specify one or more playback IDs') unless env.args.size() > 0
|
18
|
-
|
19
|
-
begin
|
20
|
-
for playback_id in env.args
|
21
|
-
historic = env.user.getHistoric(playback_id)
|
22
|
-
env.displayHistoricDetails(historic)
|
23
|
-
end
|
24
|
-
|
25
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
26
|
-
rescue DataSift::DataSiftError => err
|
27
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
28
|
-
end
|
data/examples/push.sh
DELETED
data/examples/push/delete.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# This script deletes Push subscriptions from your account.
|
2
|
-
#
|
3
|
-
# NB: Most of the error handling (exception catching) has been removed for
|
4
|
-
# the sake of simplicity. Nearly everything in this library may throw
|
5
|
-
# exceptions, and production code should catch them. See the documentation
|
6
|
-
# for full details.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Include the shared Env class
|
10
|
-
require File.dirname(__FILE__) + '/env'
|
11
|
-
|
12
|
-
# Create the env object. This reads the command line arguments, creates the
|
13
|
-
# user object, and provides access to both along with helper functions.
|
14
|
-
env = Env.new()
|
15
|
-
|
16
|
-
# Make sure we have something to do
|
17
|
-
abort('Please specify one or more subscription IDs') unless env.args.size() > 0
|
18
|
-
|
19
|
-
for sub_id in env.args
|
20
|
-
begin
|
21
|
-
sub = env.user.getPushSubscription(sub_id)
|
22
|
-
print 'Deleting ' + sub_id + ', "' + sub.name + '"...'
|
23
|
-
sub.delete()
|
24
|
-
rescue DataSift::DataSiftError => err
|
25
|
-
puts 'ERR: [' + err.class.name + '] ' + err.message
|
26
|
-
else
|
27
|
-
puts 'done'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if env.user.rate_limit_remaining != -1
|
32
|
-
puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
|
33
|
-
end
|