bw_status_board_api 1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7a1e9c2a8acbfad568be87a78aa676467242a54
4
+ data.tar.gz: 63971a8dc5f39ed3ad74b2b5762acbcd4c1cf10d
5
+ SHA512:
6
+ metadata.gz: 710438c0fe8a4cb2a8291d67b3443b945aa3ff6828db60828d25add6995d4eab26dd300f9292299c56b3c704cbd0bd88ad682f38c047ce636bd2a9d8d509d90f
7
+ data.tar.gz: 92d2910299f3463bfc56ab8dec51b0c3ec952c232acf903b99c180b7ecf5cf8728d32147f4e48f0400c78255fa7d89b3b39d8d2ad14ea31b02283381aa44f654
data/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ # EditorConfig file
2
+ root = true
3
+
4
+ [*]
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ trim_trailing_whitespace = true
8
+
9
+ [*.rb]
10
+ indent_style = spaces
11
+ indent_size = 2
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+ .DS_Store
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ # See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+ # To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
data/CONTRIBUTING.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'coveralls', '~> 0.7.0', require: false
4
+ gem 'simplecov'
5
+
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ bw_status_board_api
2
+ ===================
3
+
4
+ API wrapper for the Brandwatch Status Board
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bw_status_board_api'
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/lib/bw_status_board_api/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'bw_status_board_api'
5
+ s.version = BWStatusBoardAPI::VERSION
6
+ s.date = '2014-09-04'
7
+ s.summary = 'Brandwatch Status Board API Wrapper'
8
+ s.description = 'A Ruby wrapper for the Brandwatch Status Board'
9
+ s.author = 'Jonathan Chrisp'
10
+ s.email = 'jonathan@brandwatch.com'
11
+ s.license = 'MIT'
12
+ s.homepage = 'https://gite.brandwatch.com/jonathan/bw_status_board_api'
13
+ s.required_ruby_version = '>= 1.9.2'
14
+
15
+ s.add_development_dependency 'rspec', '~> 3.0.0'
16
+ s.add_development_dependency 'rubocop', '~> 0.24.1'
17
+
18
+ s.add_runtime_dependency 'allotment', '~> 1.1.0'
19
+ s.add_runtime_dependency 'faraday', '~> 0.9.0'
20
+ s.add_runtime_dependency 'faraday_middleware', '~> 0.9.1'
21
+ s.add_runtime_dependency 'faraday_middleware-parse_oj', '~> 0.3.0'
22
+ s.add_runtime_dependency 'oj', '~> 2.10.2'
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
+ s.test_files = `git ls-files -- spec/*`.split("\n")
27
+ s.require_paths = ['lib']
28
+ end
@@ -0,0 +1,16 @@
1
+ module BWStatusBoardAPI
2
+ class Client
3
+ module Environments
4
+ # Services module for environment services endpoints
5
+ module Services
6
+ # Get environment services
7
+ #
8
+ # @param environment_id [Integer] Id of the existing environment
9
+ # @return [Hash] the services stored
10
+ def services(environment_id)
11
+ get "environments/#{environment_id}/services"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'bw_status_board_api/client/environments/services'
2
+
3
+ module BWStatusBoardAPI
4
+ class Client
5
+ # Environments module for environments endpoints
6
+ module Environments
7
+ include BWStatusBoardAPI::Client::Environments::Services
8
+
9
+ # Get environments stored
10
+ #
11
+ # @return [Hash] the environments stored
12
+ def environments
13
+ get 'environments'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ require 'bw_status_board_api/configuration'
2
+ require 'bw_status_board_api/connection'
3
+ require 'bw_status_board_api/request'
4
+ require 'bw_status_board_api/performance'
5
+
6
+ require 'bw_status_board_api/client/environments'
7
+
8
+ require 'faraday'
9
+
10
+ module BWStatusBoardAPI
11
+ # Client class to create BWStatusBoardAPI instances
12
+ class Client
13
+ include BWStatusBoardAPI::Configuration
14
+ include BWStatusBoardAPI::Connection
15
+ include BWStatusBoardAPI::Request
16
+ include BWStatusBoardAPI::Performance
17
+
18
+ include BWStatusBoardAPI::Client::Environments
19
+
20
+ # Initializes Client
21
+ #
22
+ # @params options [Hash] the configuration options
23
+ def initialize(options = {})
24
+ BWStatusBoardAPI::Configuration.keys.each do |key|
25
+ instance_variable_set(:"@#{key}", options[key] || BWStatusBoardAPI.instance_variable_get(:"@#{key}"))
26
+ end
27
+ end
28
+
29
+ def api_endpoint=(value)
30
+ reset_connection
31
+ @api_endpoint = value
32
+ end
33
+
34
+ def connection_options=(value)
35
+ reset_connection
36
+ @connection_options = value
37
+ end
38
+
39
+ def debug=(value)
40
+ reset_connection
41
+ @debug = value
42
+ end
43
+
44
+ def logger=(value)
45
+ reset_connection
46
+ @logger = value
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,43 @@
1
+ module BWStatusBoardAPI
2
+ # Configuration module
3
+ module Configuration
4
+ attr_accessor :adapter, :api_endpoint, :debug, :logger, :performance, :user_agent, :verify_ssl
5
+
6
+ class << self
7
+ # Configuration keys
8
+ def keys
9
+ @keys ||= [
10
+ :adapter,
11
+ :api_endpoint,
12
+ :connection_options,
13
+ :debug,
14
+ :logger,
15
+ :performance,
16
+ :user_agent,
17
+ :verify_ssl
18
+ ]
19
+ end
20
+ end
21
+
22
+ # Set configuration options using a block
23
+ def configure
24
+ yield self
25
+ end
26
+
27
+ def reset
28
+ BWStatusBoardAPI::Configuration.keys.each { |key| instance_variable_set(:"@#{key}", BWStatusBoardAPI::Default.options[key]) }
29
+ self
30
+ end
31
+
32
+ def destroy
33
+ BWStatusBoardAPI::Configuration.keys.each { |key| instance_variable_set(:"@#{key}", nil) }
34
+ self
35
+ end
36
+
37
+ private
38
+
39
+ def options
40
+ Hash[BWStatusBoardAPI::Configuration.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+ require 'bw_status_board_api/response/error'
2
+ require 'bw_status_board_api/response/logger'
3
+ require 'bw_status_board_api/response/performance'
4
+ require 'faraday_middleware'
5
+ require 'faraday_middleware/parse_oj'
6
+
7
+ module BWStatusBoardAPI
8
+ # Connection module
9
+ module Connection
10
+ RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
11
+
12
+ private
13
+
14
+ def connection
15
+ @connection ||= Faraday.new(faraday_options)
16
+ end
17
+
18
+ def reset_connection
19
+ @connection = nil
20
+ end
21
+
22
+ def faraday_options
23
+ opts = @connection_options
24
+ opts[:builder] = middleware
25
+ opts[:ssl] = { verify: @verify_ssl }
26
+ opts[:url] = @api_endpoint
27
+ opts
28
+ end
29
+
30
+ def middleware
31
+ RACK_BUILDER_CLASS.new do |builder|
32
+ builder.request :json
33
+
34
+ builder.response :performance, self if debug
35
+ builder.response :error
36
+ builder.response :logger, self if debug
37
+
38
+ builder.response :oj
39
+ builder.response :follow_redirects
40
+ builder.adapter Faraday.default_adapter
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,61 @@
1
+ require 'bw_status_board_api/version'
2
+ require 'bw_status_board_api/configuration'
3
+
4
+ require 'allotment'
5
+ require 'faraday'
6
+
7
+ module BWStatusBoardAPI
8
+ # Default module
9
+ module Default
10
+ ADAPTER = Faraday.default_adapter
11
+
12
+ API_ENDPOINT = 'http://argus:3000/api/'
13
+
14
+ USER_AGENT = "BWStatusBoardAPI Ruby Gem #{BWStatusBoardAPI::VERSION}".freeze
15
+
16
+ class << self
17
+ def options
18
+ Hash[BWStatusBoardAPI::Configuration.keys.map { |key| [key, send(key)] }]
19
+ end
20
+
21
+ def adapter
22
+ ENV['BWStatusBoardAPI_ADAPTER'] || ADAPTER
23
+ end
24
+
25
+ def api_endpoint
26
+ ENV['BWStatusBoardAPI_API_ENDPOINT'] || API_ENDPOINT
27
+ end
28
+
29
+ def connection_options
30
+ {
31
+ headers: {
32
+ user_agent: user_agent
33
+ },
34
+ request: {
35
+ params_encoder: Faraday::FlatParamsEncoder
36
+ }
37
+ }
38
+ end
39
+
40
+ def debug
41
+ ENV['BWStatusBoardAPI_DEBUG'] || false
42
+ end
43
+
44
+ def logger
45
+ nil
46
+ end
47
+
48
+ def performance
49
+ Allotment.results
50
+ end
51
+
52
+ def user_agent
53
+ ENV['BWStatusBoardAPI_USER_AGENT'] || USER_AGENT
54
+ end
55
+
56
+ def verify_ssl
57
+ ENV['BWStatusBoardAPI_VERIFY_SSL'] || false
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,103 @@
1
+ module BWStatusBoardAPI
2
+ # BWStatusBoardAPI error class
3
+ class BWStatusBoardAPIError < StandardError
4
+ def initialize(response = nil)
5
+ @errors = []
6
+ valid_response?(response)
7
+ @errors.empty? ? super() : super(@errors.join(', '))
8
+ end
9
+
10
+ # Check if response is valid
11
+ #
12
+ # @param object [Object] response object to check for errors
13
+ def valid_response?(response)
14
+ return nil if response.nil?
15
+ return nil unless response.body.is_a?(Object) && response.respond_to?(:body)
16
+ return nil unless response.body.is_a?(Hash)
17
+ parse_errors(errors_keys?(response.body)) unless response.body.nil?
18
+ end
19
+
20
+ # Check if response has known errors keys
21
+ #
22
+ # @param object [Object] response object to process for errors
23
+ def errors_keys?(body)
24
+ if body.key?('error') && body.key?('error_description')
25
+ body
26
+ elsif body.key?('errors')
27
+ body['errors']
28
+ else
29
+ nil
30
+ end
31
+ end
32
+
33
+ # Parses errors based on error body passed
34
+ #
35
+ # @param body [Hash] errors
36
+ def parse_errors(body)
37
+ verify_type body
38
+ end
39
+
40
+ # Verifies type
41
+ #
42
+ # @param object [Object] type to determine
43
+ def verify_type(type)
44
+ case type
45
+ when Array
46
+ split_array_errors(type)
47
+ when Hash
48
+ split_hash_errors(type)
49
+ when String
50
+ @errors << type
51
+ end
52
+ end
53
+
54
+ # Iterates through errors in array
55
+ #
56
+ # @param array [Array] array to iterate
57
+ def split_array_errors(array)
58
+ array.each_with_index { |_e, i| verify_type array[i] }
59
+ end
60
+
61
+ # Iterates through errors in hash
62
+ #
63
+ # @param hash [Hash] hash to iterate
64
+ def split_hash_errors(hash)
65
+ message = []
66
+ hash.each { |k, v| message << "#{k}: #{v}" }
67
+ @errors << message.flatten.join(' with ')
68
+ end
69
+ end
70
+
71
+ # Raised when Brandwatch returns a 400 HTTP status code
72
+ class BadRequest < BWStatusBoardAPIError; end
73
+
74
+ # Raised when Brandwatch returns a 401 HTTP status code
75
+ class Unauthorized < BWStatusBoardAPIError; end
76
+
77
+ # Raised when Brandwatch returns a 403 HTTP status code
78
+ class Forbidden < BWStatusBoardAPIError; end
79
+
80
+ # Raised when Brandwatch returns a 404 HTTP status code
81
+ class NotFound < BWStatusBoardAPIError; end
82
+
83
+ # Raised when Brandwatch returns a 406 HTTP status code
84
+ class NotAcceptable < BWStatusBoardAPIError; end
85
+
86
+ # Raised when Brandwatch returns a 422 HTTP status code
87
+ class UnprocessableEntity < BWStatusBoardAPIError; end
88
+
89
+ # Raised when Brandwatch returns a 429 HTTP status code
90
+ class TooManyRequests < BWStatusBoardAPIError; end
91
+
92
+ # Raised when Brandwatch returns a 500 HTTP status code
93
+ class InternalServerError < BWStatusBoardAPIError; end
94
+
95
+ # Raised when Brandwatch returns a 501 HTTP status code
96
+ class NotImplemented < BWStatusBoardAPIError; end
97
+
98
+ # Raised when Brandwatch returns a 502 HTTP status code
99
+ class BadGateway < BWStatusBoardAPIError; end
100
+
101
+ # Raised when Brandwatch returns a 503 HTTP status code
102
+ class ServiceUnavailable < BWStatusBoardAPIError; end
103
+ end
@@ -0,0 +1,39 @@
1
+ require 'allotment'
2
+ require 'hashie'
3
+
4
+ module BWStatusBoardAPI
5
+ # Performance module
6
+ module Performance
7
+ def average_response_time
8
+ averages = []
9
+ performance.each_key { |key| averages << Allotment.results[key].average }
10
+ averages.average
11
+ end
12
+
13
+ def average_response_time_breakdown
14
+ results = []
15
+ performance.each do |key, value|
16
+ results << Hashie::Mash.new(path: key, average: Allotment.results[key].average, count: value.size)
17
+ end
18
+ results
19
+ end
20
+
21
+ def fastest_response
22
+ average_response_time_breakdown.sort_by { |result| result[:average] }.first
23
+ end
24
+
25
+ def response_paths
26
+ performance.keys
27
+ end
28
+
29
+ def slowest_response
30
+ average_response_time_breakdown.sort_by { |result| result[:average] }.reverse.first
31
+ end
32
+
33
+ def total_responses
34
+ responses = 0
35
+ performance.each_value { |value| responses += value.size }
36
+ responses
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,77 @@
1
+ require 'faraday'
2
+
3
+ module BWStatusBoardAPI
4
+ # Request module
5
+ module Request
6
+ # Perform a get request
7
+ #
8
+ # @param path [String] URL path to send request
9
+ # @param opts [Hash] Request parameters
10
+ # @return [Hash] Response body
11
+ def get(path, opts = {})
12
+ request(:get, path, opts).body
13
+ end
14
+
15
+ # Perform a delete request
16
+ #
17
+ # @param path [String] URL path to send request
18
+ # @param opts [Hash] Request parameters
19
+ # @return [Hash] Response body
20
+ def delete(path, opts = {})
21
+ request(:delete, path, opts).body
22
+ end
23
+
24
+ # Perform a post request
25
+ #
26
+ # @param path [String] URL path to send request
27
+ # @param opts [Hash] Request parameters
28
+ # @return [Hash] Response body
29
+ def post(path, opts = {})
30
+ request(:post, path, opts).body
31
+ end
32
+
33
+ # Perform a put request
34
+ #
35
+ # @param path [String] URL path to send request
36
+ # @param opts [Hash] Request parameters
37
+ # @return [Hash] Response body
38
+ def put(path, opts = {})
39
+ request(:put, path, opts).body
40
+ end
41
+
42
+ # Perform a patch request
43
+ #
44
+ # @param path [String] URL path to send request
45
+ # @param opts [Hash] Request parameters
46
+ # @return [Hash] Response body
47
+ def patch(path, opts = {})
48
+ request(:patch, path, opts).body
49
+ end
50
+
51
+ private
52
+
53
+ # Perform a request
54
+ #
55
+ # @param method [String] Type of request
56
+ # @param path [String] URL path to send request
57
+ # @param opts [Hash] Request parameters
58
+ # @return [Hash] Response
59
+ def request(method, path, opts = {})
60
+ response = connection.send(method) do |r|
61
+ case method
62
+ when :get, :delete
63
+ r.url path, opts
64
+ when :patch, :post, :put
65
+ if opts.is_a?(Hash) && opts.key?(:force_urlencoded)
66
+ opts.delete(:force_urlencoded)
67
+ r.url path, opts
68
+ else
69
+ r.path = path
70
+ r.body = opts
71
+ end
72
+ end
73
+ end
74
+ response
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,30 @@
1
+ require 'bw_status_board_api/error'
2
+ require 'faraday'
3
+
4
+ module BWStatusBoardAPI
5
+ module Response
6
+ # Brandwatch Status Board API response middleware to handle errors
7
+ class Error < Faraday::Response::Middleware
8
+ ERROR_MAP = {
9
+ 400 => BWStatusBoardAPI::BadRequest,
10
+ 401 => BWStatusBoardAPI::Unauthorized,
11
+ 403 => BWStatusBoardAPI::Forbidden,
12
+ 404 => BWStatusBoardAPI::NotFound,
13
+ 406 => BWStatusBoardAPI::NotAcceptable,
14
+ 422 => BWStatusBoardAPI::UnprocessableEntity,
15
+ 429 => BWStatusBoardAPI::TooManyRequests,
16
+ 500 => BWStatusBoardAPI::InternalServerError,
17
+ 501 => BWStatusBoardAPI::NotImplemented,
18
+ 502 => BWStatusBoardAPI::BadGateway,
19
+ 503 => BWStatusBoardAPI::ServiceUnavailable
20
+ }
21
+
22
+ def on_complete(response)
23
+ key = response[:status].to_i
24
+ fail ERROR_MAP[key].new(response) if ERROR_MAP.key? key
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Faraday::Response.register_middleware error: BWStatusBoardAPI::Response::Error
@@ -0,0 +1,37 @@
1
+ require 'faraday'
2
+
3
+ module BWStatusBoardAPI
4
+ module Response
5
+ # Brandwatch Status Board API response middleware to handle logging
6
+ class Logger < Faraday::Response::Middleware
7
+ def initialize(app, client)
8
+ super(app)
9
+ @client = client
10
+ end
11
+
12
+ def logger
13
+ @logger = @client.logger || begin
14
+ require 'logger'
15
+ ::Logger.new(STDOUT)
16
+ end
17
+ end
18
+
19
+ def call(env)
20
+ logger.info("Request: #{env.method.upcase} - #{env.url}")
21
+ logger.debug("Request headers: #{dump_output(env.request_headers)}")
22
+ super
23
+ end
24
+
25
+ def on_complete(env)
26
+ logger.info("Response Status: #{env.status}")
27
+ logger.debug("Response headers: #{dump_output(env.response_headers)}")
28
+ end
29
+
30
+ def dump_output(object)
31
+ object.map { |key, value| "#{key}: #{value.inspect}" }.join(', ')
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Faraday::Response.register_middleware logger: BWStatusBoardAPI::Response::Logger
@@ -0,0 +1,33 @@
1
+ require 'faraday'
2
+ require 'allotment'
3
+
4
+ module BWStatusBoardAPI
5
+ module Response
6
+ # Brandwatch Status Board API response middleware to monitor performance
7
+ class Performance < Faraday::Response::Middleware
8
+ def initialize(app, client)
9
+ super(app)
10
+ @client = client
11
+ end
12
+
13
+ def logger
14
+ @logger = @client.logger || begin
15
+ require 'logger'
16
+ ::Logger.new(STDOUT)
17
+ end
18
+ end
19
+
20
+ def call(env)
21
+ @recording = ("#{env.method}#{env.url.path}").gsub!('/', '_')
22
+ Allotment.start(@recording)
23
+ super
24
+ end
25
+
26
+ def on_complete(_env)
27
+ logger.info "Response time: #{Allotment.stop(@recording)} seconds"
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Faraday::Response.register_middleware performance: BWStatusBoardAPI::Response::Performance
@@ -0,0 +1,4 @@
1
+ # BW Version
2
+ module BWStatusBoardAPI
3
+ VERSION = '1.0.0'
4
+ end
@@ -0,0 +1,31 @@
1
+ require 'bw_status_board_api/client'
2
+ require 'bw_status_board_api/default'
3
+
4
+ # Ruby wrapper for the Brandwatch API
5
+ module BWStatusBoardAPI
6
+ class << self
7
+ include BWStatusBoardAPI::Configuration
8
+
9
+ # Alias for BWStatusBoardAPI::Client.new
10
+ #
11
+ # @return [BWStatusBoardAPI::Client]
12
+ def new(opts = {})
13
+ BWStatusBoardAPI::Client.new(opts)
14
+ end
15
+
16
+ # Check BWStatusBoardAPI::Client.new responds
17
+ def respond_to?(method_name, include_private = false)
18
+ new.respond_to?(method_name, include_private) || super
19
+ end
20
+
21
+ private
22
+
23
+ # Delegate to BWStatusBoardAPI::Client.new
24
+ def method_missing(method_name, *args, &block)
25
+ return super unless client.respond_to?(method_name)
26
+ new.send(method_name, *args, &block)
27
+ end
28
+ end
29
+ end
30
+
31
+ BWStatusBoardAPI.reset
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ describe BWStatusBoardAPI do
4
+ describe 'when called' do
5
+ it 'should be an instance of Module' do
6
+ expect(BWStatusBoardAPI).to be_an_instance_of Module
7
+ end
8
+ end
9
+
10
+ describe '.new' do
11
+ it 'is a BWStatusBoardAPI::Client' do
12
+ expect(BWStatusBoardAPI.new).to be_a BWStatusBoardAPI::Client
13
+ end
14
+ end
15
+
16
+ describe '.respond_to?' do
17
+ it 'returns true if new method exists' do
18
+ expect(BWStatusBoardAPI.respond_to?(:new, true)).to eq(true)
19
+ end
20
+ end
21
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ Coveralls::SimpleCov::Formatter,
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ ]
8
+
9
+ SimpleCov.start
10
+ require 'bw_status_board_api'
11
+
12
+ RSpec.configure do |config|
13
+ config.color = true
14
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bw_status_board_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Chrisp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.24.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.24.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: allotment
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday_middleware-parse_oj
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: oj
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.10.2
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.10.2
111
+ description: A Ruby wrapper for the Brandwatch Status Board
112
+ email: jonathan@brandwatch.com
113
+ executables:
114
+ - bw_status_board_api
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .editorconfig
119
+ - .gitignore
120
+ - .rubocop.yml
121
+ - CHANGELOG.md
122
+ - CONTRIBUTING.md
123
+ - Gemfile
124
+ - README.md
125
+ - bin/bw_status_board_api
126
+ - bw_status_board_api.gemspec
127
+ - lib/bw_status_board_api.rb
128
+ - lib/bw_status_board_api/client.rb
129
+ - lib/bw_status_board_api/client/environments.rb
130
+ - lib/bw_status_board_api/client/environments/services.rb
131
+ - lib/bw_status_board_api/configuration.rb
132
+ - lib/bw_status_board_api/connection.rb
133
+ - lib/bw_status_board_api/default.rb
134
+ - lib/bw_status_board_api/error.rb
135
+ - lib/bw_status_board_api/performance.rb
136
+ - lib/bw_status_board_api/request.rb
137
+ - lib/bw_status_board_api/response/error.rb
138
+ - lib/bw_status_board_api/response/logger.rb
139
+ - lib/bw_status_board_api/response/performance.rb
140
+ - lib/bw_status_board_api/version.rb
141
+ - spec/bw_status_board_api_spec.rb
142
+ - spec/helper.rb
143
+ homepage: https://gite.brandwatch.com/jonathan/bw_status_board_api
144
+ licenses:
145
+ - MIT
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: 1.9.2
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.4.1
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Brandwatch Status Board API Wrapper
167
+ test_files:
168
+ - spec/bw_status_board_api_spec.rb
169
+ - spec/helper.rb
170
+ has_rdoc: