datasift 3.0.0.beta4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE +1 -1
- data/MIGRATING_TO_V.3.0.0.md +1 -1
- data/README.md +23 -2
- data/Rakefile +10 -0
- data/VERSION +1 -1
- data/datasift.gemspec +4 -4
- data/examples/auth.rb +14 -10
- data/examples/cli.sh +2 -2
- data/examples/core_api_eg.rb +6 -1
- data/examples/dynamic_list_eg.rb +74 -0
- data/examples/dynamic_list_replace_eg.rb +45 -0
- data/examples/historics_eg.rb +20 -13
- data/examples/historics_preview_eg.rb +5 -4
- data/examples/live_stream_eg.rb +2 -1
- data/examples/managed_source_eg.rb +11 -10
- data/examples/pull.rb +8 -8
- data/examples/push_eg.rb +32 -15
- data/lib/cli.rb +2 -2
- data/lib/datasift.rb +7 -3
- data/lib/dynamic_list.rb +66 -0
- data/lib/dynamic_list_replace.rb +45 -0
- data/lib/historics.rb +17 -0
- data/lib/historics_preview.rb +2 -1
- data/lib/push.rb +10 -17
- data/test/datasift/core_api_test.rb +153 -0
- data/test/datasift/historics_preview_api_test.rb +83 -0
- data/test/datasift/push_api_test.rb +223 -0
- data/test/fixtures/balance.json +1 -0
- data/test/fixtures/compile_csdl_invalid.json +1 -0
- data/test/fixtures/compile_csdl_valid.json +1 -0
- data/test/fixtures/dpu_valid.json +1 -0
- data/test/fixtures/preview_create_valid.json +1 -0
- data/test/fixtures/preview_get_running.json +1 -0
- data/test/fixtures/preview_get_succeeded.json +1 -0
- data/test/fixtures/push_create_valid.json +1 -0
- data/test/fixtures/push_get_list_by_hash_valid.json +1 -0
- data/test/fixtures/push_get_list_by_historics_id_valid.json +1 -0
- data/test/fixtures/push_get_list_valid.json +1 -0
- data/test/fixtures/push_get_valid.json +1 -0
- data/test/fixtures/push_log_valid.json +1 -0
- data/test/fixtures/push_pause_valid.json +1 -0
- data/test/fixtures/push_stop_valid.json +1 -0
- data/test/fixtures/push_validate_valid.json +1 -0
- data/test/fixtures/usage_current.json +1 -0
- data/test/fixtures/validate_csdl_invalid.json +1 -0
- data/test/fixtures/validate_csdl_valid.json +1 -0
- data/test/test_helper.rb +17 -0
- metadata +36 -9
- data/tests/core_api_test.rb +0 -95
@@ -0,0 +1 @@
|
|
1
|
+
{"balance":{"remaining_dpus":-847.8,"cost":0,"plan":"professional","threshold":500}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"error":"We are unable to parse this stream. At line 1 position 21 we were expecting one of: an operator that can act on strings, integers or float types (==, !=, <, >, >=, <=), followed by a text value;\n or the \"substring\" operator, followed by a text value;\n or <predicate.contains_parameters>, followed by a list of comma separated strings;\n or the \"in\" operator for strings, followed by a list of comma separated strings;\n or <predicate.contains_parameters>, followed by a quote (\"), followed by a list of comma separated items in a contains near operator's value, followed by a colon (:), followed by the number of words separation argument in the contains near operator's value, followed by a quote (\");\n or <predicate.contains_parameters>, followed by a text value;\n or the \"in\" operator for dynamic lists, followed by a dynamic list key;\n or <predicate.contains_parameters>, followed by a dynamic list key."}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"hash":"145ea24a4d83a14ecb9077b831f14809","created_at":"2014-05-21 13:53:08","dpu":"0.1"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"dpu":0.1,"detail":{"contains":{"count":1,"dpu":0.1,"targets":{"interaction.content":{"count":1,"dpu":0.1}}}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"created_at":1400772868,"id":"fbd5441ab17a46f2ac200f8cab6bdb79fe8efb31"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"bba2e37958470b56d2a3d7748fd5ad918f7b8b92","name":"preview","progress":43,"status":"running","feeds":"facebook,twitter","sample":1,"end":1398985200,"created_at":1401293969,"start":1398898800,"user":"1","parameters":"language.tag,freqDist,5;interaction.id,targetVol,hour","hash":"145ea24a4d83a14ecb9077b831f14809"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"bba2e37958470b56d2a3d7748fd5ad918f7b8b92","name":"preview","progress":100,"status":"succeeded","feeds":"facebook,twitter","sample":1,"end":1398985200,"created_at":1401293969,"start":1398898800,"user":"1","parameters":"language.tag,freqDist,5;interaction.id,targetVol,hour","hash":"145ea24a4d83a14ecb9077b831f14809","data":[{"target":"language.tag","analysis":"freqDist","output":{"fr":45,"id":49,"en":2720,"es":42,"ms":39},"threshold":5},{"target":"interaction.id","analysis":"targetVol","output":{"2014\/05\/01 21:00:00":108,"2014\/05\/01 08:00:00":76,"2014\/05\/01 09:00:00":204,"2014\/05\/01 12:00:00":133,"2014\/05\/01 00:00:00":118,"2014\/05\/01 18:00:00":104,"2014\/05\/01 06:00:00":90,"2014\/05\/01 02:00:00":181,"2014\/05\/01 03:00:00":119,"2014\/05\/01 22:00:00":105,"2014\/05\/01 15:00:00":162,"2014\/05\/01 07:00:00":95,"2014\/05\/01 05:00:00":87,"2014\/05\/01 14:00:00":137,"2014\/05\/01 10:00:00":124,"2014\/05\/01 20:00:00":99,"2014\/05\/01 01:00:00":154,"2014\/05\/01 17:00:00":131,"2014\/05\/01 04:00:00":142,"2014\/05\/01 11:00:00":101,"2014\/05\/01 19:00:00":105,"2014\/05\/01 16:00:00":161,"2014\/05\/01 13:00:00":158,"2014\/04\/30 23:00:00":116},"interval":"hour","summary":{"count":3010}}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ca7f50126a9e7e837c8b716ac5f7604a","output_type":"http","name":"connectorhttp","created_at":1401295443,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"active","last_request":null,"last_success":null,"remaining_bytes":null,"lost_data":false,"start":1401295443,"end":0}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"subscriptions":[{"id":"7802b84cfe79e50e0a6e3cdac5ce54ab","output_type":"http","name":"connectorhttp","created_at":1401364070,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"active","last_request":1401381810,"last_success":1401381810,"remaining_bytes":null,"lost_data":false,"start":1401364070,"end":null}],"count":1}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"subscriptions":[{"id":"c0d390b3ad76e8d4a977e7c91364688f","output_type":"ftp","name":"Example","created_at":1401866981,"user_id":1,"hash":"5f569d6f99002bfaa483","hash_type":"historic","output_params":{"format":"json_meta","directory":"\/data","port":21,"max_size":10485760,"delivery_frequency":10,"host":"example.datasift.com"},"status":"finished","last_request":null,"last_success":1401870290,"remaining_bytes":null,"lost_data":false,"start":1401866981,"end":1401875424}],"count":1}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"subscriptions":[{"id":"7802b84cfe79e50e0a6e3cdac5ce54ab","output_type":"http","name":"connectorhttp","created_at":1401364070,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"active","last_request":null,"last_success":null,"remaining_bytes":null,"lost_data":false,"start":1401364070,"end":null}],"count":1}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ca7f50126a9e7e837c8b716ac5f7604a","output_type":"http","name":"connectorhttp","created_at":1401295443,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"active","last_request":null,"last_success":1401295476,"remaining_bytes":0,"lost_data":false,"start":1401295443,"end":null}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"success":true,"count":1,"log_entries":[{"request_time":1402413172,"success":true,"subscription_id":"7802b84cfe79e50e0a6e3cdac5ce54ab","message":"Successfully delivered after delivery failure(s)"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ca7f50126a9e7e837c8b716ac5f7604a","output_type":"http","name":"connectorhttp","created_at":1401295443,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"paused","last_request":null,"last_success":1401295476,"remaining_bytes":0,"lost_data":false,"start":1401295443,"end":null}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"7802b84cfe79e50e0a6e3cdac5ce54ab","output_type":"http","name":"connectorhttp","created_at":1401364070,"user_id":1,"hash":"145ea24a4d83a14ecb9077b831f14809","hash_type":"stream","output_params":{"method":"post","url":"http:\/\/example.com\/datasift","compression":"none","delivery_frequency":0,"max_size":10485760,"verify_ssl":"false"},"status":"finishing","last_request":1401451186,"last_success":1401451181,"remaining_bytes":null,"lost_data":false,"start":1401364070,"end":1401451186}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"success":true,"message":"Validated successfully"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"start":"Wed, 21 May 2014 10:00:00 +0000","end":"Wed, 21 May 2014 11:00:00 +0000","streams":{"028eaeff74f186a768cc37107378fb9d":{"licenses":{"gender":2255,"interaction":2753,"klout.score":2155,"language":2677,"links":2723,"salience.sentiment":2663,"trends":44,"twitter":2753},"seconds":3600},"0fc46cdc3afbeb7c903ba5cb2ae73781":{"licenses":[],"seconds":3600},"1561e183f191f9aa0e55cda127a1e80d":{"licenses":[],"seconds":300},"49ab3b3aadf32fb81624ae69b4fa6646":{"licenses":{"facebook_page":1,"gender":1,"instagram":1,"interaction":1,"language":1,"salience.sentiment":1},"seconds":3600},"828dd0f10a8f7d0201c54684390d059d":{"licenses":[],"seconds":3600},"9dbf78769d088c868836a5d4861b9e7a":{"licenses":[],"seconds":300}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"error": "The target interaction.nonsense does not exist"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"created_at": "2014-01-30 10:09:19","dpu": "0.1"}
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require File.expand_path('./../../examples/auth', __FILE__)
|
5
|
+
require 'datasift'
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'webmock/minitest'
|
8
|
+
require 'multi_json'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
def fixture_path
|
12
|
+
File.expand_path('../fixtures', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def fixture(file)
|
16
|
+
File.new(fixture_path + '/' + file)
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datasift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DataSift
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -95,19 +95,19 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.11.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: minitest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '5.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '5.0'
|
111
111
|
description: The official Ruby library for accessing the DataSift API. See http://datasift.com/
|
112
112
|
for full details and to sign up for an account.
|
113
113
|
email:
|
@@ -122,11 +122,14 @@ files:
|
|
122
122
|
- LICENSE
|
123
123
|
- MIGRATING_TO_V.3.0.0.md
|
124
124
|
- README.md
|
125
|
+
- Rakefile
|
125
126
|
- VERSION
|
126
127
|
- datasift.gemspec
|
127
128
|
- examples/auth.rb
|
128
129
|
- examples/cli.sh
|
129
130
|
- examples/core_api_eg.rb
|
131
|
+
- examples/dynamic_list_eg.rb
|
132
|
+
- examples/dynamic_list_replace_eg.rb
|
130
133
|
- examples/historics_eg.rb
|
131
134
|
- examples/historics_preview_eg.rb
|
132
135
|
- examples/live_stream_eg.rb
|
@@ -136,13 +139,37 @@ files:
|
|
136
139
|
- lib/api/api_resource.rb
|
137
140
|
- lib/cli.rb
|
138
141
|
- lib/datasift.rb
|
142
|
+
- lib/dynamic_list.rb
|
143
|
+
- lib/dynamic_list_replace.rb
|
139
144
|
- lib/errors.rb
|
140
145
|
- lib/historics.rb
|
141
146
|
- lib/historics_preview.rb
|
142
147
|
- lib/live_stream.rb
|
143
148
|
- lib/managed_source.rb
|
144
149
|
- lib/push.rb
|
145
|
-
-
|
150
|
+
- test/datasift/core_api_test.rb
|
151
|
+
- test/datasift/historics_preview_api_test.rb
|
152
|
+
- test/datasift/push_api_test.rb
|
153
|
+
- test/fixtures/balance.json
|
154
|
+
- test/fixtures/compile_csdl_invalid.json
|
155
|
+
- test/fixtures/compile_csdl_valid.json
|
156
|
+
- test/fixtures/dpu_valid.json
|
157
|
+
- test/fixtures/preview_create_valid.json
|
158
|
+
- test/fixtures/preview_get_running.json
|
159
|
+
- test/fixtures/preview_get_succeeded.json
|
160
|
+
- test/fixtures/push_create_valid.json
|
161
|
+
- test/fixtures/push_get_list_by_hash_valid.json
|
162
|
+
- test/fixtures/push_get_list_by_historics_id_valid.json
|
163
|
+
- test/fixtures/push_get_list_valid.json
|
164
|
+
- test/fixtures/push_get_valid.json
|
165
|
+
- test/fixtures/push_log_valid.json
|
166
|
+
- test/fixtures/push_pause_valid.json
|
167
|
+
- test/fixtures/push_stop_valid.json
|
168
|
+
- test/fixtures/push_validate_valid.json
|
169
|
+
- test/fixtures/usage_current.json
|
170
|
+
- test/fixtures/validate_csdl_invalid.json
|
171
|
+
- test/fixtures/validate_csdl_valid.json
|
172
|
+
- test/test_helper.rb
|
146
173
|
homepage: https://github.com/datasift/datasift-ruby
|
147
174
|
licenses:
|
148
175
|
- BSD
|
@@ -163,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
190
|
version: 1.3.6
|
164
191
|
requirements: []
|
165
192
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.3.0
|
167
194
|
signing_key:
|
168
195
|
specification_version: 4
|
169
196
|
summary: DataSift is a simple wrapper for the DataSift API.
|
data/tests/core_api_test.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require '../examples/auth'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'webmock/test_unit'
|
4
|
-
require 'multi_json'
|
5
|
-
class CoreApiTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
auth = DataSiftExample.new
|
9
|
-
@datasift = auth.datasift
|
10
|
-
@data = OpenStruct.new
|
11
|
-
@responses = OpenStruct.new
|
12
|
-
@statuses = OpenStruct.new
|
13
|
-
@headers = OpenStruct.new
|
14
|
-
|
15
|
-
@data.valid_csdl = 'interaction.content contains "test"'
|
16
|
-
@data.invalid_csdl = 'interaction.nonsense is not valid'
|
17
|
-
#{"created_at" => "2014-01-30 10:09:19", "dpu" => "0.1"}
|
18
|
-
@responses.valid_csdl = '{"created_at": "2014-01-30 10:09:19","dpu": "0.1"}'
|
19
|
-
@responses.invalid_csdl = '{"error": "The target interaction.nonsense does not exist"}'
|
20
|
-
@responses.valid_stream = OpenStruct.new({:hash => '145ea24a4d83a14ecb9077b831f14809', :created_at => '2014-01-30 17:35:14', :dpu => '0.1'})
|
21
|
-
|
22
|
-
@statuses.valid_csdl = 200
|
23
|
-
@statuses.invalid_csdl = 400
|
24
|
-
|
25
|
-
@headers.valid_csdl = {
|
26
|
-
"date" => "Thu, 30 Jan 2014 10:09:19 GMT", "content-type" => "application/json",
|
27
|
-
"transfer-encoding" => "chunked", "connection" => "close", "x-api-version" => "1",
|
28
|
-
"x-ratelimit-limit" => "10000", "x-ratelimit-remaining" => "10000", "x-ratelimit-cost" => "5"}
|
29
|
-
#valid CSDL
|
30
|
-
stub_request(:post, /api.datasift.com\/.*\/validate/).
|
31
|
-
with(:body => {"csdl" => @data.valid_csdl}).
|
32
|
-
to_return(:status => @statuses.valid_csdl,
|
33
|
-
:body => @responses.valid_csdl,
|
34
|
-
:headers => @headers.valid_csdl)
|
35
|
-
#invalid CSDL
|
36
|
-
stub_request(:post, /api.datasift.com\/.*\/validate/).
|
37
|
-
with(:body => {"csdl" => @data.invalid_csdl}).
|
38
|
-
to_return(:status => @statuses.invalid_csdl,
|
39
|
-
:body => @responses.invalid_csdl,
|
40
|
-
:headers => @headers.valid_csdl)
|
41
|
-
#valid stream compilation
|
42
|
-
stub_request(:post, /api.datasift.com\/.*\/compile/).
|
43
|
-
with(:body => {"csdl" => @data.valid_csdl}).
|
44
|
-
to_return(:status => @statuses.valid_csdl,
|
45
|
-
:body => MultiJson.dump(@responses.valid_stream),
|
46
|
-
:headers => @headers.valid_csdl)
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def teardown
|
52
|
-
# Do nothing
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_csdl_cant_be_nil_when_validating
|
56
|
-
assert_raise InvalidParamError do
|
57
|
-
@datasift.valid?(nil)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_csdl_cant_be_empty_when_validating
|
62
|
-
assert_raise InvalidParamError do
|
63
|
-
@datasift.valid?('')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_if_user_can_get_successful_validation_as_bool
|
68
|
-
assert_boolean @datasift.valid?(@data.valid_csdl), 'Valid must return a bool by default'
|
69
|
-
assert_true @datasift.valid?(@data.valid_csdl), 'This request should have returned true'
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_if_user_can_get_successful_validation_as_hash
|
73
|
-
validation = @datasift.valid?(@data.valid_csdl, false)
|
74
|
-
assert_kind_of Hash, validation, 'Valid should return a hash here'
|
75
|
-
assert_equal @statuses.valid_csdl, validation[:http][:status], "This request should have returned status as #{@statuses.validate_csdl}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_failing_csdl_validation
|
79
|
-
assert_raise BadRequestError do
|
80
|
-
@datasift.valid?(@data.invalid_csdl)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_csdl_cant_be_nil_when_compiling
|
85
|
-
assert_raise InvalidParamError do
|
86
|
-
@datasift.compile(nil)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_csdl_cant_be_empty_when_compiling
|
91
|
-
assert_raise InvalidParamError do
|
92
|
-
@datasift.compile('')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|