Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/3.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dugjason committed Nov 13, 2015
2 parents b49d314 + 9307ce5 commit da74f54
Show file tree
Hide file tree
Showing 70 changed files with 342 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 118
# Configuration parameters: AllowURI, URISchemes.
LineLength:
Max: 90
Max: 100

# Offense count: 33
# Configuration parameters: CountComments.
Expand Down
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
language: ruby
sudo: false
cache: bundler
bundler_args: --without development --retry=3 --jobs=3

rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- ruby-head

matrix:
allow_failures:
- ruby-head
fast_finish: true
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
CHANGELOG
================================
## v.3.5.0 (2015-11-13)
### Added
* Support for the [/account/usage](http://dev.datasift.com/pylon/docs/api/acct-api-endpoints/get-accountusage) API endpoint
* Added explicit support for 412, 415, 503 and 504 HTTP error responses
* Support for the [/pylon/sample](http://dev.datasift.com/pylon/docs/api/pylon-api-endpoints/pylonsample) API endpoint. Full details about the feature can be found in our [platform release notes](http://community.datasift.com/t/pylon-1-6-release-notes/1859)

### Changed
* Only set ```Content-Type``` HTTP header for POST/PUT requests; it's not necessary unless we are passing a request entity
* Teased out some minor performance enhancements by allocating fewer objects on each request
* Loosen some Gem dependancies. Successfully tested against [rest-client](https://github.com/rest-client/rest-client) v2.0.0

## v.3.4.0 (2015-08-20)
### Added
* Support for [Open Data Processing](https://datasift.com/products/open-data-processing-for-twitter/) batch uploads (Thanks @giovannelli)
* Explicit supprot for 413 and 422 errors from API
* Ability to get at API response headers using the ```object.response``` accessor. (Thanks again @giovannelli)
* Support for [Open Data Processing](https://datasift.com/products/open-data-processing-for-twitter/) batch uploads (Thanks [@giovannelli](https://github.com/giovannelli))
* Explicit support for 413 and 422 errors from API
* Ability to get at API response headers using the ```object.response``` accessor. (Thanks again [@giovannelli](https://github.com/giovannelli))

### Changed
* Bumped [rest-client](https://github.com/rest-client/rest-client) dependency to ~> 1.8
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group :test do
gem 'minitest', '~> 5.0'
gem 'rubocop', '>= 0.27'
gem 'simplecov', '>= 0.9'
gem 'shoulda', '~> 2.11'
gem 'shoulda', '>= 2.11'
gem 'vcr', '~> 2.9'
gem 'webmock'
end
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.5.0
8 changes: 4 additions & 4 deletions datasift.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test}/*`.split("\n")
s.require_paths = ["lib"]

s.add_runtime_dependency('rest-client', '~> 1.8')
s.add_runtime_dependency('multi_json', '~> 1.7')
s.add_runtime_dependency('websocket-td', '~> 0.0.5')
s.add_development_dependency('bundler', '~> 1.0')
s.add_runtime_dependency 'rest-client', ['>= 1.8', '< 3.0']
s.add_runtime_dependency 'multi_json', '~> 1.7'
s.add_runtime_dependency 'websocket-td', '~> 0.0.5'
s.add_development_dependency 'bundler', '~> 1.0'
end
33 changes: 33 additions & 0 deletions examples/account_eg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require './auth'
class AccountEg < DataSiftExample
def initialize
super
@datasift = DataSift::Client.new(@config)
run
end

def run
begin
puts "Get account usage for the default period"
puts @datasift.account.usage[:data].to_json

puts "\nGet account usage for the past month"
puts @datasift.account.usage('monthly')[:data].to_json

rescue DataSiftError => dse
puts dse.message
# Then match specific error to take action;
# All errors thrown by the client extend DataSiftError
case dse
when ConnectionError
# some connection error
when AuthError
when BadRequestError
else
# do something else...
end
end
end
end

AccountEg.new
18 changes: 10 additions & 8 deletions examples/account_identity_eg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ def run
begin
puts "Create a new identity"
identity = @datasift.account_identity.create(
"Ruby Identity", "active", false
"Ruby Identity #{DateTime.now}", "active", false
)
identity_id = identity[:data][:id]
puts identity.to_json
puts identity[:data].to_json

puts "\nList all existing identities"
puts @datasift.account_identity.list.to_json
puts @datasift.account_identity.list[:data].to_json

puts "\nGet existing identity"
puts @datasift.account_identity.get(identity_id).to_json
puts @datasift.account_identity.get(identity_id)[:data].to_json

puts "\nUpdate an identity"
puts @datasift.account_identity.update(
identity_id, 'Updated Ruby Identity'
).to_json
identity_id, "Updated Ruby Identity #{DateTime.now}"
)[:data].to_json

puts "\nDelete an identity"
puts @datasift.account_identity.delete(identity_id).to_json
@datasift.account_identity.delete(identity_id)

rescue DataSiftError => dse
puts dse.message
puts dse.inspect
# Then match specific error to take action;
# All errors thrown by the client extend DataSiftError
case dse
Expand All @@ -41,6 +41,8 @@ def run
else
# do something else...
end
puts "\nClean up and delete the identity"
@datasift.account_identity.delete(identity_id)
end
end
end
Expand Down
18 changes: 10 additions & 8 deletions examples/account_identity_limit_eg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@ def run
"Ruby Identity for Token Limits", "active", false
)
identity_id = identity[:data][:id]
puts identity.to_json
puts identity[:data].to_json

puts "\nCreate a Limit for our Identity"
puts @datasift.account_identity_limit.create(
identity_id,
'facebook',
100_000
)
)[:data].to_json

puts "\nList all existing Limits for this Service"
puts @datasift.account_identity_limit.list(
'facebook'
).to_json
)[:data].to_json

puts "\nGet existing Limit by Identity and Service"
puts @datasift.account_identity_limit.get(
identity_id,
'facebook'
).to_json
)[:data].to_json

puts "\nUpdate a Limit for a given Identity"
puts @datasift.account_identity_limit.update(
identity_id,
'facebook',
250_000
).to_json
)[:data].to_json

puts "\nRemove the Limit from a given Identity and Service"
puts @datasift.account_identity_limit.delete(
@datasift.account_identity_limit.delete(
identity_id,
'facebook'
).to_json
)

puts "\nCleanup and remove the Identity"
@datasift.account_identity.delete(identity_id)

rescue DataSiftError => dse
puts dse.message
puts dse.inspect
# Then match specific error to take action;
# All errors thrown by the client extend DataSiftError
case dse
Expand All @@ -61,6 +61,8 @@ def run
else
# do something else...
end
puts "\nCleanup and remove the Identity"
@datasift.account_identity.delete(identity_id)
end
end
end
Expand Down
7 changes: 5 additions & 2 deletions examples/account_identity_token_eg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def run
begin
puts "Create a new identity to create tokens for"
identity = @datasift.account_identity.create(
"Ruby Identity for Tokens",
"Ruby Identity for Tokena",
"active",
false
)
Expand Down Expand Up @@ -52,17 +52,20 @@ def run
@datasift.account_identity.delete(identity_id)

rescue DataSiftError => dse
puts dse.message
puts dse.inspect
# Then match specific error to take action;
# All errors thrown by the client extend DataSiftError
case dse
when ConnectionError
# some connection error
when AuthError
when BadRequestError
puts '[WARNING] You will need to use a valid token to run through this example'
else
# do something else...
end
puts "\nCleanup and remove the Identity"
@datasift.account_identity.delete(identity_id)
end
end
end
Expand Down
57 changes: 28 additions & 29 deletions examples/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ class DataSiftExample

def initialize
@config = {
:username => 'DATASIFT_USERNAME',
:api_key => 'DATASIFT_API_KEY',
:api_version => 'v1.2'
username: 'DATASIFT_USERNAME',
api_key: 'DATASIFT_API_KEY',
api_version: 'v1.2'
}
@params = {
:output_type => 's3',
:output_params => {
:bucket => 'YOUR_BUCKET_NAME',
:directory => 'ruby',
:acl => 'private',
:delivery_frequency => 0,
:max_size => 104857600,
:file_prefix => 'DataSift',
:auth => {
:access_key => 'ADD_YOUR_ACCESS_KEY',
:secret_key => 'ADD_YOUR_SECRET_KEY',
output_type: 's3',
output_params: {
bucket: 'YOUR_BUCKET_NAME',
directory: 'ruby',
acl: 'private',
delivery_frequency: 0,
max_size: 104857600,
file_prefix: 'DataSift',
auth: {
access_key: 'ADD_YOUR_ACCESS_KEY',
secret_key: 'ADD_YOUR_SECRET_KEY',
}
}
}
@pull_params = {
:output_type => 'pull',
:output_params => {
:max_size => 52428800
output_type: 'pull',
output_params: {
max_size: 52428800
}
}
@datasift = DataSift::Client.new(@config)
Expand All @@ -35,22 +35,21 @@ def initialize

def create_push(hash, is_historics_id = false)
create_params = @params.merge ({
#hash or historics_id can be used but not both
:name => 'My awesome push subscription',
:initial_status => 'active', # or 'paused' or 'waiting_for_start'
# Hash or historics_id can be used, but not both
name: 'My awesome push subscription',
initial_status: 'active', # or 'paused' or 'waiting_for_start'
})
if is_historics_id
create_params.merge!({:historics_id => hash})
create_params.merge!(historics_id: hash)
else
create_params.merge!({:hash => hash,
#start and end are not valid for historics
:start => Time.now.to_i,
:end => Time.now.to_i + 320
})
# Start and end are not valid for historics
create_params.merge!(
hash: hash,
start: Time.now.to_i,
end: Time.now.to_i + 320
)
end
puts 'Creating subscription'
subscription = @datasift.push.create create_params
puts 'Create push => ' + subscription.to_s
subscription
@datasift.push.create create_params
end
end
2 changes: 1 addition & 1 deletion examples/core_api_eg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run

rescue DataSiftError => dse
puts dse.message
# Then match specific one to take action - All errors thrown by the client extend DataSiftError
# Then match specific one to take action; All errors thrown by the client extend DataSiftError
case dse
when ConnectionError
# some connection error
Expand Down
6 changes: 3 additions & 3 deletions examples/live_stream_eg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def run
puts "DataSift Message #{hash} ==> #{message}"
end

conn = DataSift::new_stream(@config, on_delete, on_error, on_connect, on_close)
conn = DataSift::new_stream(@config, on_delete, on_error, on_connect, on_close)
conn.on_datasift_message = on_datasift_message
#can do something else here now...
puts 'Do some other business stuff...'
conn.stream.read_thread.join
#rescue DataSiftError
rescue DataSiftError => dse
puts "Error #{dse.message}"
# Then match specific one to take action - All errors thrown by the client extend DataSiftError
puts dse.inspect
# Then match specific one to take action; All errors thrown by the client extend DataSiftError
case dse
when ConnectionError
# some connection error
Expand Down
Loading

0 comments on commit da74f54

Please sign in to comment.