bwapi 9.0.0.pre.349 → 9.0.0.pre.364

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 (99) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -1
  3. data/.rubocop.yml +3 -0
  4. data/.travis.yml +0 -3
  5. data/Gemfile +3 -3
  6. data/README.md +0 -1
  7. data/bin/bwapi +0 -1
  8. data/bwapi.gemspec +6 -9
  9. data/lib/bwapi.rb +16 -14
  10. data/lib/bwapi/client.rb +65 -16
  11. data/lib/bwapi/client/admin.rb +0 -2
  12. data/lib/bwapi/client/admin/become.rb +0 -2
  13. data/lib/bwapi/client/admin/search.rb +0 -2
  14. data/lib/bwapi/client/admin/sub_clients.rb +0 -2
  15. data/lib/bwapi/client/admin/users.rb +0 -2
  16. data/lib/bwapi/client/admin/users/sharing.rb +0 -2
  17. data/lib/bwapi/client/brandwatch.rb +0 -2
  18. data/lib/bwapi/client/brandwatch/become.rb +0 -2
  19. data/lib/bwapi/client/brandwatch/client_modules.rb +0 -1
  20. data/lib/bwapi/client/client.rb +0 -2
  21. data/lib/bwapi/client/command_center.rb +0 -2
  22. data/lib/bwapi/client/command_center/client.rb +0 -2
  23. data/lib/bwapi/client/command_center/displays.rb +0 -2
  24. data/lib/bwapi/client/command_center/displays/events.rb +0 -2
  25. data/lib/bwapi/client/command_center/displays/messages.rb +0 -1
  26. data/lib/bwapi/client/command_center/displays/scenes.rb +0 -2
  27. data/lib/bwapi/client/command_center/displays/screens.rb +0 -2
  28. data/lib/bwapi/client/command_center/displays/users.rb +0 -2
  29. data/lib/bwapi/client/command_center/displays/users/access.rb +0 -1
  30. data/lib/bwapi/client/command_center/scene_types.rb +0 -2
  31. data/lib/bwapi/client/command_center/themes.rb +0 -2
  32. data/lib/bwapi/client/command_center/users.rb +0 -2
  33. data/lib/bwapi/client/command_center/users/access.rb +0 -2
  34. data/lib/bwapi/client/error_codes.rb +0 -2
  35. data/lib/bwapi/client/filters.rb +0 -2
  36. data/lib/bwapi/client/languages.rb +0 -2
  37. data/lib/bwapi/client/locations.rb +0 -2
  38. data/lib/bwapi/client/logout.rb +0 -3
  39. data/lib/bwapi/client/me.rb +2 -11
  40. data/lib/bwapi/client/metrics.rb +0 -2
  41. data/lib/bwapi/client/oauth.rb +0 -3
  42. data/lib/bwapi/client/ping.rb +0 -2
  43. data/lib/bwapi/client/projects.rb +0 -2
  44. data/lib/bwapi/client/projects/bulkactions.rb +0 -2
  45. data/lib/bwapi/client/projects/bulkactions/author.rb +0 -2
  46. data/lib/bwapi/client/projects/bulkactions/mentions.rb +0 -2
  47. data/lib/bwapi/client/projects/categories.rb +0 -2
  48. data/lib/bwapi/client/projects/categories/copy.rb +0 -2
  49. data/lib/bwapi/client/projects/data.rb +0 -1
  50. data/lib/bwapi/client/projects/data/mentions.rb +0 -1
  51. data/lib/bwapi/client/projects/data/mentions/notes.rb +0 -2
  52. data/lib/bwapi/client/projects/data/volume.rb +0 -2
  53. data/lib/bwapi/client/projects/data_download.rb +0 -2
  54. data/lib/bwapi/client/projects/demographics.rb +0 -1
  55. data/lib/bwapi/client/projects/facebook_queries.rb +0 -2
  56. data/lib/bwapi/client/projects/group.rb +0 -1
  57. data/lib/bwapi/client/projects/group/author_group.rb +0 -2
  58. data/lib/bwapi/client/projects/group/location_group.rb +0 -1
  59. data/lib/bwapi/client/projects/group/site_group.rb +0 -1
  60. data/lib/bwapi/client/projects/queries.rb +0 -2
  61. data/lib/bwapi/client/projects/queries/backfill.rb +0 -1
  62. data/lib/bwapi/client/projects/queries/date_range.rb +0 -2
  63. data/lib/bwapi/client/projects/queries/mentions.rb +0 -1
  64. data/lib/bwapi/client/projects/query_groups.rb +0 -1
  65. data/lib/bwapi/client/projects/rules.rb +0 -1
  66. data/lib/bwapi/client/projects/rules/backfill.rb +0 -2
  67. data/lib/bwapi/client/projects/rules/copy.rb +0 -2
  68. data/lib/bwapi/client/projects/sharing.rb +0 -2
  69. data/lib/bwapi/client/projects/signals.rb +0 -2
  70. data/lib/bwapi/client/projects/stream_dashboards.rb +0 -2
  71. data/lib/bwapi/client/projects/stream_dashboards/streams.rb +0 -1
  72. data/lib/bwapi/client/projects/summary.rb +0 -2
  73. data/lib/bwapi/client/projects/tags.rb +0 -2
  74. data/lib/bwapi/client/projects/twitter_queries.rb +0 -2
  75. data/lib/bwapi/client/projects/users.rb +0 -2
  76. data/lib/bwapi/client/projects/workflow.rb +0 -2
  77. data/lib/bwapi/client/query_validation.rb +0 -2
  78. data/lib/bwapi/client/sso.rb +0 -2
  79. data/lib/bwapi/client/test_search.rb +0 -2
  80. data/lib/bwapi/client/user.rb +0 -2
  81. data/lib/bwapi/client/user/notifications.rb +0 -2
  82. data/lib/bwapi/configuration.rb +40 -56
  83. data/lib/bwapi/connection.rb +32 -14
  84. data/lib/bwapi/default.rb +91 -0
  85. data/lib/bwapi/error.rb +1 -3
  86. data/lib/bwapi/performance.rb +39 -0
  87. data/lib/bwapi/request.rb +6 -33
  88. data/lib/bwapi/response/error.rb +28 -0
  89. data/lib/bwapi/response/logger.rb +35 -0
  90. data/lib/bwapi/response/performance.rb +31 -0
  91. data/lib/bwapi/version.rb +0 -2
  92. data/spec/bwapi/client_spec.rb +55 -49
  93. data/spec/bwapi_spec.rb +1 -3
  94. data/spec/helper.rb +1 -4
  95. metadata +32 -47
  96. data/lib/bwapi/authentication.rb +0 -48
  97. data/lib/faraday/response/brandwatch_error.rb +0 -25
  98. data/spec/bwapi/authentication_spec.rb +0 -57
  99. data/spec/fixtures/.netrc +0 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWRhMzBhM2FkNzExZTMwZjIwMjcwYzc3ZDNiODZmYTFiNWZjOTQ1ZQ==
4
+ YjJlMmJiYWUwMDE3ZjlhNmRmMDE5NGZmZWVlYWZiYmQ3MjQ3Y2YwYg==
5
5
  data.tar.gz: !binary |-
6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@ AccessorMethodName:
15
15
 
16
16
  RaiseArgs:
17
17
  Enabled: false
18
+
19
+ Encoding:
20
+ EnforcedStyle: when_needed
@@ -11,9 +11,6 @@ matrix:
11
11
  allow_failures:
12
12
  - rvm: ruby-head
13
13
 
14
- before_script:
15
- - chmod 600 spec/fixtures/.netrc
16
-
17
14
  script:
18
15
  - bundle exec rspec
19
16
  - bundle exec rubocop
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem "coveralls", "~> 0.7.0", require: false
3
+ gem 'coveralls', '~> 0.7.0', require: false
4
4
  gem 'simplecov'
5
5
 
6
- gemspec
6
+ gemspec
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jonathanchrisp/bwapi/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
2
1
  [![Gem Version](https://badge.fury.io/rb/bwapi.png)](http://badge.fury.io/rb/bwapi)
3
2
  [![Build Status](https://travis-ci.org/jonathanchrisp/bwapi.png?branch=master)](https://travis-ci.org/jonathanchrisp/bwapi)
4
3
  [![Dependency Status](https://gemnasium.com/jonathanchrisp/bwapi.png)](https://gemnasium.com/jonathanchrisp/bwapi)
data/bin/bwapi CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
  require 'bwapi'
@@ -1,12 +1,10 @@
1
- # encoding: utf-8
2
-
3
1
  require File.dirname(__FILE__) + '/lib/bwapi/version'
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = 'bwapi'
7
5
  s.version = BWAPI::VERSION
8
6
  s.version = BWAPI::VERSION + ".pre.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
9
- s.date = '2014-05-28'
7
+ s.date = '2014-08-04'
10
8
  s.summary = 'Brandwatch API Wrapper'
11
9
  s.description = 'A Ruby wrapper for the Brandwatch API'
12
10
  s.author = 'Jonathan Chrisp'
@@ -15,14 +13,13 @@ Gem::Specification.new do |s|
15
13
  s.homepage = 'https://github.com/jonathanchrisp/bwapi'
16
14
  s.required_ruby_version = '>= 1.9.2'
17
15
 
18
- s.add_development_dependency 'rspec', '~> 2.14.1', '>= 2.14.1'
19
- s.add_development_dependency 'rubocop', '~> 0.21.0', '>= 0.21.0'
16
+ s.add_development_dependency 'rspec', '~> 3.0.0', '>= 3.0.0'
17
+ s.add_development_dependency 'rubocop', '~> 0.24.1', '>= 0.24.1'
20
18
 
21
- s.add_runtime_dependency 'colored', '~> 1.2'
19
+ s.add_runtime_dependency 'allotment', '~> 1.1.0', '>= 1.1.0'
22
20
  s.add_runtime_dependency 'faraday', '~> 0.9.0', '>= 0.9.0'
23
- s.add_runtime_dependency 'faraday_middleware', '~> 0.9.0', '>= 0.9.0'
24
- s.add_runtime_dependency 'hashie', '~> 2.1.1', '>= 2.1.1'
25
- s.add_runtime_dependency 'netrc', '~> 0.7.7', '>= 0.7.7'
21
+ s.add_runtime_dependency 'faraday_middleware', '~> 0.9.1', '>= 0.9.1'
22
+ s.add_runtime_dependency 'hashie', '~> 3.2.0', '>= 3.2.0'
26
23
 
27
24
  s.files = `git ls-files`.split("\n")
28
25
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
@@ -1,29 +1,31 @@
1
- # encoding: utf-8
2
-
3
- require 'bwapi/version'
4
- require 'bwapi/configuration'
5
- require 'bwapi/error'
6
1
  require 'bwapi/client'
2
+ require 'bwapi/default'
7
3
 
8
- # BWAPI namespace module
4
+ # Ruby wrapper for the Brandwatch API
9
5
  module BWAPI
10
- extend Configuration
11
6
  class << self
7
+ include BWAPI::Configuration
8
+
12
9
  # Alias for BWAPI::Client.new
13
10
  #
14
11
  # @return [BWAPI::Client]
15
12
  def new(opts = {})
16
- BWAPI::Client.new opts
13
+ BWAPI::Client.new(opts)
17
14
  end
18
15
 
19
- # Delegate to BWAPI::Client.new
20
- def method_missing(method, *args, &block)
21
- return super unless new.respond_to? method
22
- new.send method, *args, &block
16
+ # Check BWAPI::Client.new responds
17
+ def respond_to?(method_name, include_private = false)
18
+ new.respond_to?(method_name, include_private) || super
23
19
  end
24
20
 
25
- def respond_to?(method, include_private = false)
26
- new.respond_to?(method, include_private) || super(method, include_private)
21
+ private
22
+
23
+ # Delegate to BWAPI::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
27
  end
28
28
  end
29
29
  end
30
+
31
+ BWAPI.reset
@@ -1,8 +1,7 @@
1
- # encoding: utf-8
2
-
3
- require 'bwapi/authentication'
1
+ require 'bwapi/configuration'
4
2
  require 'bwapi/connection'
5
3
  require 'bwapi/request'
4
+ require 'bwapi/performance'
6
5
 
7
6
  require 'bwapi/client/admin'
8
7
  require 'bwapi/client/brandwatch'
@@ -22,25 +21,15 @@ require 'bwapi/client/projects'
22
21
  require 'bwapi/client/query_validation'
23
22
  require 'bwapi/client/test_search'
24
23
  require 'bwapi/client/user'
24
+ require 'faraday'
25
25
 
26
26
  module BWAPI
27
27
  # Client class to create BWAPI instances
28
28
  class Client
29
- attr_accessor(*Configuration::OPTION_KEYS)
30
-
31
- def initialize(opts = {})
32
- opts = BWAPI.options.merge(opts)
33
- Configuration::OPTION_KEYS.each { |k| send("#{k}=", opts[k]) }
34
- netrc_credentials opts[:netrc]
35
- end
36
-
37
- def destroy
38
- Configuration::OPTION_KEYS.each { |k| send("#{k}=", nil) }
39
- end
40
-
41
- include BWAPI::Authentication
29
+ include BWAPI::Configuration
42
30
  include BWAPI::Connection
43
31
  include BWAPI::Request
32
+ include BWAPI::Performance
44
33
 
45
34
  include BWAPI::Client::Admin
46
35
  include BWAPI::Client::Brandwatch
@@ -60,5 +49,65 @@ module BWAPI
60
49
  include BWAPI::Client::QueryValidation
61
50
  include BWAPI::Client::TestSearch
62
51
  include BWAPI::Client::User
52
+
53
+ # Initializes Client
54
+ #
55
+ # @params options [Hash] the configuration options
56
+ def initialize(options = {})
57
+ BWAPI::Configuration.keys.each do |key|
58
+ instance_variable_set(:"@#{key}", options[key] || BWAPI.instance_variable_get(:"@#{key}"))
59
+ end
60
+ end
61
+
62
+ # Check if user is authenicated
63
+ #
64
+ # @return [Boolean] Authenticated status
65
+ def authenticated?
66
+ @access_token ? true : false
67
+ end
68
+
69
+ # Check if user is a brandwatch-application-client type
70
+ #
71
+ # @return [Boolean] Application client status
72
+ def application_client?
73
+ @client_id == 'brandwatch-application-client' ? true : false
74
+ end
75
+
76
+ # Check if user is a brandwatch-api-client type
77
+ #
78
+ # @return [Boolean] Application client status
79
+ def api_client?
80
+ @client_id == 'brandwatch-api-client' ? true : false
81
+ end
82
+
83
+ def access_token=(value)
84
+ reset_connection
85
+ @access_token = value
86
+ end
87
+
88
+ def api_endpoint=(value)
89
+ reset_connection
90
+ @api_endpoint = value
91
+ end
92
+
93
+ def connection_options=(value)
94
+ reset_connection
95
+ @connection_options = value
96
+ end
97
+
98
+ def debug=(value)
99
+ reset_connection
100
+ @debug = value
101
+ end
102
+
103
+ def logger=(value)
104
+ reset_connection
105
+ @logger = value
106
+ end
107
+
108
+ def verify_ssl=(value)
109
+ reset_connection
110
+ @verify_ssl = value
111
+ end
63
112
  end
64
113
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/admin/become'
4
2
  require 'bwapi/client/admin/search'
5
3
  require 'bwapi/client/admin/sub_clients'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module Admin
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module Admin
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module Admin
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/admin/users/sharing'
4
2
 
5
3
  module BWAPI
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module Admin
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/brandwatch/become'
4
2
  require 'bwapi/client/brandwatch/client_modules'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module Brandwatch
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module BWAPI
3
2
  class Client
4
3
  module Brandwatch
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # Client module for client endpoints
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/command_center/client'
4
2
  require 'bwapi/client/command_center/displays'
5
3
  require 'bwapi/client/command_center/scene_types'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/command_center/displays/events'
4
2
  require 'bwapi/client/command_center/displays/messages'
5
3
  require 'bwapi/client/command_center/displays/scenes'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module BWAPI
3
2
  class Client
4
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/command_center/displays/users/access'
4
2
 
5
3
  module BWAPI
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module BWAPI
3
2
  class Client
4
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bwapi/client/command_center/users/access'
4
2
 
5
3
  module BWAPI
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  module CommandCenter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # ErrorCodes module for errorCodes endpoint
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # Filters module for filters endpoint
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # Languages module for languages endpoints
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # Location module for locations endpoints
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module BWAPI
4
2
  class Client
5
3
  # Logout module for logout endpoint
@@ -12,7 +10,6 @@ module BWAPI
12
10
  ensure
13
11
  self.access_token = nil
14
12
  self.refresh_token = nil
15
- self.expires_in = nil
16
13
  end
17
14
  end
18
15
  end