datasift 1.5.0 → 2.0.0

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.
Files changed (47) hide show
  1. data/.gitignore +1 -0
  2. data/LICENSE +1 -1
  3. data/README.md +6 -4
  4. data/VERSION +1 -1
  5. data/config.yml +2 -2
  6. data/datasift.gemspec +11 -11
  7. data/examples/historics.sh +2 -0
  8. data/examples/historics/create-from-csdl.rb +71 -0
  9. data/examples/historics/create-from-hash.rb +65 -0
  10. data/examples/historics/delete.rb +30 -0
  11. data/examples/historics/env.rb +37 -0
  12. data/examples/historics/list.rb +30 -0
  13. data/examples/historics/start.rb +30 -0
  14. data/examples/historics/stop.rb +30 -0
  15. data/examples/historics/view.rb +28 -0
  16. data/examples/push.sh +2 -0
  17. data/examples/push/delete.rb +33 -0
  18. data/examples/push/env.rb +53 -0
  19. data/examples/push/list.rb +30 -0
  20. data/examples/push/pause.rb +33 -0
  21. data/examples/push/push-from-hash.rb +72 -0
  22. data/examples/push/push-historic-from-csdl.rb +98 -0
  23. data/examples/push/push-stream-from-csdl.rb +70 -0
  24. data/examples/push/resume.rb +33 -0
  25. data/examples/push/stop.rb +33 -0
  26. data/examples/push/view-log.rb +45 -0
  27. data/examples/push/view.rb +31 -0
  28. data/lib/DataSift/apiclient.rb +20 -25
  29. data/lib/DataSift/definition.rb +97 -57
  30. data/lib/DataSift/exceptions.rb +25 -8
  31. data/lib/DataSift/historic.rb +321 -0
  32. data/lib/DataSift/mockapiclient.rb +23 -34
  33. data/lib/DataSift/push_definition.rb +115 -0
  34. data/lib/DataSift/push_subscription.rb +330 -0
  35. data/lib/DataSift/stream_consumer.rb +53 -70
  36. data/lib/DataSift/stream_consumer_http.rb +11 -15
  37. data/lib/DataSift/user.rb +189 -61
  38. data/lib/datasift.rb +5 -10
  39. data/test/helper.rb +80 -6
  40. data/test/test_definition.rb +0 -9
  41. data/test/test_historics.rb +233 -0
  42. data/test/test_pushdefinition.rb +92 -0
  43. data/test/test_pushsubscription.rb +17 -0
  44. data/test/test_user.rb +0 -6
  45. data/test/testdata.yml +26 -0
  46. metadata +38 -23
  47. data/test/test_live_api.rb +0 -100
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class TestPushSubscription < Test::Unit::TestCase
4
+ context "Given a new PushSubsription object" do
5
+ setup do
6
+ init()
7
+ # Get a subscription from the API
8
+ setResponseToASingleSubscription()
9
+ @subscription = @user.getPushSubscription(@testdata['push_id'])
10
+ end
11
+
12
+ should "be of the right type" do
13
+ assert_not_nil @subscription
14
+ assert @subscription.kind_of?(DataSift::PushSubscription)
15
+ end
16
+ end
17
+ end
data/test/test_user.rb CHANGED
@@ -4,7 +4,6 @@ class TestUser < Test::Unit::TestCase
4
4
  context "Given a new User object" do
5
5
  setup do
6
6
  init()
7
- initUser()
8
7
  end
9
8
 
10
9
  should "have the correct username" do
@@ -43,7 +42,6 @@ class TestUser < Test::Unit::TestCase
43
42
  context "Given an empty definition from the User factory" do
44
43
  setup do
45
44
  init()
46
- initUser()
47
45
  @definition = @user.createDefinition()
48
46
  end
49
47
 
@@ -56,7 +54,6 @@ class TestUser < Test::Unit::TestCase
56
54
  context "Given an new definition from the User factory" do
57
55
  setup do
58
56
  init()
59
- initUser()
60
57
  @definition = @user.createDefinition(" " + @testdata['definition'])
61
58
  end
62
59
 
@@ -69,7 +66,6 @@ class TestUser < Test::Unit::TestCase
69
66
  context "#getBalance" do
70
67
  setup do
71
68
  init()
72
- initUser()
73
69
  @user.api_client.setResponse(200, {
74
70
  'balance' => {
75
71
  'plan' => 'payg',
@@ -88,7 +84,6 @@ class TestUser < Test::Unit::TestCase
88
84
  context "Given a call has been made to the API" do
89
85
  setup do
90
86
  init()
91
- initUser()
92
87
  @definition = @user.createDefinition(@testdata['definition'])
93
88
  @user.api_client.setResponse(200, {
94
89
  'hash' => @testdata['definition_hash'],
@@ -110,7 +105,6 @@ class TestUser < Test::Unit::TestCase
110
105
  context "The exception raised by the User.getUsage method" do
111
106
  setup do
112
107
  init()
113
- initUser()
114
108
  end
115
109
 
116
110
  should "be APIError given a 400 response" do
data/test/testdata.yml CHANGED
@@ -2,3 +2,29 @@ definition: interaction.content contains "twitter"
2
2
  definition_hash: b76b06db8a679d2b4319e5d06a8b6691
3
3
 
4
4
  invalid_definition: interactin.content contains "twitter"
5
+
6
+ # Historic
7
+ historic_playback_id: 93558e17de15072fa126370c37c5bd8f
8
+ historic_start: 2012-06-01 00:00:00
9
+ historic_end: 2012-06-01 23:59:59
10
+ historic_created_at: 2012-08-01 12:00:00
11
+ historic_sources: twitter
12
+ historic_sample: 10.0
13
+ historic_name: Historic for unit tests
14
+
15
+ # PushSubscription
16
+ push_id: b665761917bbcb7afd3102b4a645b41e
17
+ push_name: Push subscription for unit tests
18
+ push_created_at: 2012-07-20 00:00:00
19
+ push_status: active
20
+ push_hash_type: stream
21
+ push_last_request: 2012-07-20 07:10:00
22
+ push_last_success: 2012-07-20 07:00:00
23
+ push_output_type: http
24
+ push_output_params:
25
+ delivery_frequency: 60
26
+ max_size: 10240
27
+ url: http://www.example.com/push_endpoint
28
+ auth_type: basic
29
+ auth_username: myuser
30
+ auth_password: mypass
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datasift
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
- - 1
8
- - 5
6
+ - 2
7
+ - 0
9
8
  - 0
10
- version: 1.5.0
9
+ version: 2.0.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - DataSift
@@ -15,17 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-05-24 00:00:00 Z
17
+ date: 2012-08-31 00:00:00 +01:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
24
  requirements:
26
25
  - - ~>
27
26
  - !ruby/object:Gem::Version
28
- hash: 9
29
27
  segments:
30
28
  - 1
31
29
  - 6
@@ -37,11 +35,9 @@ dependencies:
37
35
  name: yajl-ruby
38
36
  prerelease: false
39
37
  requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
38
  requirements:
42
39
  - - ~>
43
40
  - !ruby/object:Gem::Version
44
- hash: 19
45
41
  segments:
46
42
  - 1
47
43
  - 1
@@ -53,11 +49,9 @@ dependencies:
53
49
  name: rdoc
54
50
  prerelease: false
55
51
  requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
52
  requirements:
58
53
  - - ">"
59
54
  - !ruby/object:Gem::Version
60
- hash: 3
61
55
  segments:
62
56
  - 0
63
57
  version: "0"
@@ -67,11 +61,9 @@ dependencies:
67
61
  name: shoulda
68
62
  prerelease: false
69
63
  requirement: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
64
  requirements:
72
65
  - - ~>
73
66
  - !ruby/object:Gem::Version
74
- hash: 37
75
67
  segments:
76
68
  - 2
77
69
  - 11
@@ -83,11 +75,9 @@ dependencies:
83
75
  name: rspec
84
76
  prerelease: false
85
77
  requirement: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
78
  requirements:
88
79
  - - ~>
89
80
  - !ruby/object:Gem::Version
90
- hash: 23
91
81
  segments:
92
82
  - 2
93
83
  - 6
@@ -118,20 +108,47 @@ files:
118
108
  - examples/dpu.rb
119
109
  - examples/football-buffered.rb
120
110
  - examples/football.rb
111
+ - examples/historics.sh
112
+ - examples/historics/create-from-csdl.rb
113
+ - examples/historics/create-from-hash.rb
114
+ - examples/historics/delete.rb
115
+ - examples/historics/env.rb
116
+ - examples/historics/list.rb
117
+ - examples/historics/start.rb
118
+ - examples/historics/stop.rb
119
+ - examples/historics/view.rb
120
+ - examples/push.sh
121
+ - examples/push/delete.rb
122
+ - examples/push/env.rb
123
+ - examples/push/list.rb
124
+ - examples/push/pause.rb
125
+ - examples/push/push-from-hash.rb
126
+ - examples/push/push-historic-from-csdl.rb
127
+ - examples/push/push-stream-from-csdl.rb
128
+ - examples/push/resume.rb
129
+ - examples/push/stop.rb
130
+ - examples/push/view-log.rb
131
+ - examples/push/view.rb
121
132
  - examples/twitter-track.rb
122
133
  - lib/DataSift/apiclient.rb
123
134
  - lib/DataSift/definition.rb
124
135
  - lib/DataSift/exceptions.rb
136
+ - lib/DataSift/historic.rb
125
137
  - lib/DataSift/mockapiclient.rb
138
+ - lib/DataSift/push_definition.rb
139
+ - lib/DataSift/push_subscription.rb
126
140
  - lib/DataSift/stream_consumer.rb
127
141
  - lib/DataSift/stream_consumer_http.rb
128
142
  - lib/DataSift/user.rb
129
143
  - lib/datasift.rb
130
144
  - test/helper.rb
131
145
  - test/test_definition.rb
132
- - test/test_live_api.rb
146
+ - test/test_historics.rb
147
+ - test/test_pushdefinition.rb
148
+ - test/test_pushsubscription.rb
133
149
  - test/test_user.rb
134
150
  - test/testdata.yml
151
+ has_rdoc: true
135
152
  homepage: http://github.com/datasift/datasift-ruby
136
153
  licenses: []
137
154
 
@@ -141,20 +158,16 @@ rdoc_options: []
141
158
  require_paths:
142
159
  - lib
143
160
  required_ruby_version: !ruby/object:Gem::Requirement
144
- none: false
145
161
  requirements:
146
162
  - - ">="
147
163
  - !ruby/object:Gem::Version
148
- hash: 3
149
164
  segments:
150
165
  - 0
151
166
  version: "0"
152
167
  required_rubygems_version: !ruby/object:Gem::Requirement
153
- none: false
154
168
  requirements:
155
169
  - - ">="
156
170
  - !ruby/object:Gem::Version
157
- hash: 23
158
171
  segments:
159
172
  - 1
160
173
  - 3
@@ -163,13 +176,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
176
  requirements: []
164
177
 
165
178
  rubyforge_project:
166
- rubygems_version: 1.8.17
179
+ rubygems_version: 1.3.6
167
180
  signing_key:
168
181
  specification_version: 3
169
182
  summary: DataSift is a simple wrapper for the DataSift API.
170
183
  test_files:
171
184
  - test/helper.rb
172
185
  - test/test_definition.rb
173
- - test/test_live_api.rb
186
+ - test/test_historics.rb
187
+ - test/test_pushdefinition.rb
188
+ - test/test_pushsubscription.rb
174
189
  - test/test_user.rb
175
190
  - test/testdata.yml
@@ -1,100 +0,0 @@
1
- require 'helper'
2
-
3
- class TestDefinitionLive < Test::Unit::TestCase
4
- context "Given a Definition object with a valid CSDL" do
5
- setup do
6
- init()
7
- initUser(false)
8
- @user = DataSift::User.new(@config['username'], @config['api_key'])
9
- @definition = @user.createDefinition(@testdata['definition'])
10
- end
11
-
12
- should "compile the definition successfully" do
13
- begin
14
- @definition.compile()
15
- rescue InvalidDataError
16
- assert false, "InvalidDataError"
17
- rescue CompileFailedError
18
- assert false, "CompileFailedError"
19
- rescue APIError
20
- assert false, "APIError"
21
- end
22
- end
23
-
24
- should "have the correct hash" do
25
- @definition.compile()
26
- assert_equal @testdata['definition_hash'], @definition.hash
27
- end
28
-
29
- should "have a positive DPU" do
30
- @definition.compile()
31
- assert @definition.total_dpu > 0
32
- end
33
-
34
- should "have a valid created_at date" do
35
- @definition.compile()
36
- assert @definition.created_at
37
- end
38
- end
39
-
40
- context "Given a Definition object with an invalid CSDL" do
41
- setup do
42
- init()
43
- initUser(false)
44
- @definition = @user.createDefinition(@testdata['invalid_definition'])
45
- end
46
-
47
- should "fail to compile the definition" do
48
- assert_raise(DataSift::CompileFailedError) { @definition.compile() }
49
- end
50
-
51
- should "fail to get the hash" do
52
- assert_raise(DataSift::CompileFailedError) { @definition.compile() }
53
- assert_raise(DataSift::CompileFailedError) { @definition.hash }
54
- end
55
- end
56
-
57
- context "The DPU returned from a valid Definition object" do
58
- setup do
59
- init()
60
- initUser(false)
61
- @definition = @user.createDefinition(@testdata['definition'])
62
- @dpu = @definition.getDPUBreakdown()
63
- end
64
-
65
- should "contain valid DPU data" do
66
- assert @dpu.has_key?('detail')
67
- assert @dpu.has_key?('dpu')
68
- end
69
-
70
- should "have a positive total DPU" do
71
- assert @dpu['dpu'] > 0
72
- end
73
- end
74
-
75
- context "Buffered data returned by a valid Definition object" do
76
- setup do
77
- init()
78
- initUser(false)
79
- @definition = @user.createDefinition(@testdata['definition'])
80
- @interactions = @definition.getBuffered()
81
- end
82
-
83
- should "be valid" do
84
- assert @interactions
85
- end
86
- end
87
-
88
- context "A StreamConsumer object returned by a valid Definition object" do
89
- setup do
90
- init()
91
- initUser(false)
92
- @definition = @user.createDefinition(@testdata['definition'])
93
- @consumer = @definition.getConsumer()
94
- end
95
-
96
- should "be valid" do
97
- assert @consumer.is_a? DataSift::StreamConsumer
98
- end
99
- end
100
- end