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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,11 +1,9 @@
1
- # encoding: utf-8
2
-
3
1
  require 'helper'
4
2
 
5
3
  describe BWAPI do
6
4
  describe 'when called' do
7
5
  it 'should be an instance of Module' do
8
- BWAPI.should be_an_instance_of Module
6
+ expect(BWAPI).to be_an_instance_of Module
9
7
  end
10
8
  end
11
9
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'simplecov'
4
2
  require 'coveralls'
5
3
 
@@ -12,8 +10,7 @@ SimpleCov.start
12
10
  require 'bwapi'
13
11
 
14
12
  RSpec.configure do |config|
15
- config.color_enabled = true
16
- config.formatter = :documentation
13
+ config.color = true
17
14
  end
18
15
 
19
16
  def fixture_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bwapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0.pre.349
4
+ version: 9.0.0.pre.364
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Chrisp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,76 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.1
19
+ version: 3.0.0
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 2.14.1
22
+ version: 3.0.0
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.14.1
29
+ version: 3.0.0
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 2.14.1
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rubocop
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: 0.21.0
39
+ version: 0.24.1
40
40
  - - ! '>='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.21.0
42
+ version: 0.24.1
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ~>
48
48
  - !ruby/object:Gem::Version
49
- version: 0.21.0
49
+ version: 0.24.1
50
50
  - - ! '>='
51
51
  - !ruby/object:Gem::Version
52
- version: 0.21.0
52
+ version: 0.24.1
53
53
  - !ruby/object:Gem::Dependency
54
- name: colored
54
+ name: allotment
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- version: '1.2'
60
- type: :runtime
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- version: '1.2'
67
- - !ruby/object:Gem::Dependency
68
- name: faraday
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ~>
72
- - !ruby/object:Gem::Version
73
- version: 0.9.0
59
+ version: 1.1.0
74
60
  - - ! '>='
75
61
  - !ruby/object:Gem::Version
76
- version: 0.9.0
62
+ version: 1.1.0
77
63
  type: :runtime
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - ~>
82
68
  - !ruby/object:Gem::Version
83
- version: 0.9.0
69
+ version: 1.1.0
84
70
  - - ! '>='
85
71
  - !ruby/object:Gem::Version
86
- version: 0.9.0
72
+ version: 1.1.0
87
73
  - !ruby/object:Gem::Dependency
88
- name: faraday_middleware
74
+ name: faraday
89
75
  requirement: !ruby/object:Gem::Requirement
90
76
  requirements:
91
77
  - - ~>
@@ -105,45 +91,45 @@ dependencies:
105
91
  - !ruby/object:Gem::Version
106
92
  version: 0.9.0
107
93
  - !ruby/object:Gem::Dependency
108
- name: hashie
94
+ name: faraday_middleware
109
95
  requirement: !ruby/object:Gem::Requirement
110
96
  requirements:
111
97
  - - ~>
112
98
  - !ruby/object:Gem::Version
113
- version: 2.1.1
99
+ version: 0.9.1
114
100
  - - ! '>='
115
101
  - !ruby/object:Gem::Version
116
- version: 2.1.1
102
+ version: 0.9.1
117
103
  type: :runtime
118
104
  prerelease: false
119
105
  version_requirements: !ruby/object:Gem::Requirement
120
106
  requirements:
121
107
  - - ~>
122
108
  - !ruby/object:Gem::Version
123
- version: 2.1.1
109
+ version: 0.9.1
124
110
  - - ! '>='
125
111
  - !ruby/object:Gem::Version
126
- version: 2.1.1
112
+ version: 0.9.1
127
113
  - !ruby/object:Gem::Dependency
128
- name: netrc
114
+ name: hashie
129
115
  requirement: !ruby/object:Gem::Requirement
130
116
  requirements:
131
117
  - - ~>
132
118
  - !ruby/object:Gem::Version
133
- version: 0.7.7
119
+ version: 3.2.0
134
120
  - - ! '>='
135
121
  - !ruby/object:Gem::Version
136
- version: 0.7.7
122
+ version: 3.2.0
137
123
  type: :runtime
138
124
  prerelease: false
139
125
  version_requirements: !ruby/object:Gem::Requirement
140
126
  requirements:
141
127
  - - ~>
142
128
  - !ruby/object:Gem::Version
143
- version: 0.7.7
129
+ version: 3.2.0
144
130
  - - ! '>='
145
131
  - !ruby/object:Gem::Version
146
- version: 0.7.7
132
+ version: 3.2.0
147
133
  description: A Ruby wrapper for the Brandwatch API
148
134
  email: jonathan@brandwatch.com
149
135
  executables:
@@ -161,7 +147,6 @@ files:
161
147
  - bin/bwapi
162
148
  - bwapi.gemspec
163
149
  - lib/bwapi.rb
164
- - lib/bwapi/authentication.rb
165
150
  - lib/bwapi/client.rb
166
151
  - lib/bwapi/client/admin.rb
167
152
  - lib/bwapi/client/admin/become.rb
@@ -236,14 +221,16 @@ files:
236
221
  - lib/bwapi/client/user/notifications.rb
237
222
  - lib/bwapi/configuration.rb
238
223
  - lib/bwapi/connection.rb
224
+ - lib/bwapi/default.rb
239
225
  - lib/bwapi/error.rb
226
+ - lib/bwapi/performance.rb
240
227
  - lib/bwapi/request.rb
228
+ - lib/bwapi/response/error.rb
229
+ - lib/bwapi/response/logger.rb
230
+ - lib/bwapi/response/performance.rb
241
231
  - lib/bwapi/version.rb
242
- - lib/faraday/response/brandwatch_error.rb
243
- - spec/bwapi/authentication_spec.rb
244
232
  - spec/bwapi/client_spec.rb
245
233
  - spec/bwapi_spec.rb
246
- - spec/fixtures/.netrc
247
234
  - spec/helper.rb
248
235
  homepage: https://github.com/jonathanchrisp/bwapi
249
236
  licenses:
@@ -265,13 +252,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
252
  version: 1.3.1
266
253
  requirements: []
267
254
  rubyforge_project:
268
- rubygems_version: 2.2.2
255
+ rubygems_version: 2.3.0
269
256
  signing_key:
270
257
  specification_version: 4
271
258
  summary: Brandwatch API Wrapper
272
259
  test_files:
273
- - spec/bwapi/authentication_spec.rb
274
260
  - spec/bwapi/client_spec.rb
275
261
  - spec/bwapi_spec.rb
276
- - spec/fixtures/.netrc
277
262
  - spec/helper.rb
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'colored'
4
-
5
- module BWAPI
6
- # Authentication module helper methods
7
- module Authentication
8
- # Check if user is authenicated
9
- #
10
- # @return [Boolean] Authenticated status
11
- def authenticated?
12
- access_token ? true : false
13
- end
14
-
15
- # Check if user is a brandwatch-application-client type
16
- #
17
- # @return [Boolean] Application client status
18
- def application_client?
19
- client_id == 'brandwatch-application-client' ? true : false
20
- end
21
-
22
- # Check if user is a brandwatch-api-client type
23
- #
24
- # @return [Boolean] Application client status
25
- def api_client?
26
- client_id == 'brandwatch-api-client' ? true : false
27
- end
28
-
29
- # Set username and password via netrc
30
- #
31
- # @param netrc [Boolean] Netrc status
32
- def netrc_credentials(netrc = false)
33
- return unless netrc
34
-
35
- require 'netrc'
36
- file = Netrc.read netrc_file
37
-
38
- # Get credentials using host
39
- netrc_host = URI.parse(api_endpoint).host
40
- creds = file[netrc_host]
41
- fail 'You are missing your .netrc file or the host provided has no credentials!'.red.underline if creds.nil?
42
- self.username = creds.shift
43
- self.password = creds.shift
44
- rescue LoadError
45
- raise 'Please install netrc gem for .netrc support'.red.underline
46
- end
47
- end
48
- end
@@ -1,25 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'faraday'
4
-
5
- # Brandwatch response middleware to handle errors
6
- class BrandwatchError < Faraday::Response::Middleware
7
- ERROR_MAP = {
8
- 400 => BWAPI::BadRequest,
9
- 401 => BWAPI::Unauthorized,
10
- 403 => BWAPI::Forbidden,
11
- 404 => BWAPI::NotFound,
12
- 406 => BWAPI::NotAcceptable,
13
- 422 => BWAPI::UnprocessableEntity,
14
- 429 => BWAPI::TooManyRequests,
15
- 500 => BWAPI::InternalServerError,
16
- 501 => BWAPI::NotImplemented,
17
- 502 => BWAPI::BadGateway,
18
- 503 => BWAPI::ServiceUnavailable
19
- }
20
-
21
- def on_complete(response)
22
- key = response[:status].to_i
23
- fail ERROR_MAP[key].new(response) if ERROR_MAP.key? key
24
- end
25
- end
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'helper'
4
-
5
- describe BWAPI::Authentication do
6
- before do
7
- BWAPI.reset
8
- end
9
-
10
- describe '.authenticated?' do
11
- it 'returns true when authenticated' do
12
- expect(BWAPI::Client.new.authenticated?).to eql(false)
13
- end
14
-
15
- it 'returns false when not authenticated' do
16
- bw = BWAPI::Client.new access_token: 'abcdef-ghijkl-123456-789012'
17
- expect(bw.authenticated?).to eql(true)
18
- end
19
- end
20
-
21
- describe '.application_client?' do
22
- it 'returns true when client is a brandwatch-application-client' do
23
- bw = BWAPI::Client.new client_id: 'brandwatch-application-client'
24
- expect(bw.application_client?).to eql(true)
25
- end
26
-
27
- it 'returns false when a client is not a brandwatch-application-client' do
28
- expect(BWAPI::Client.new.application_client?).to eql(false)
29
- end
30
- end
31
-
32
- describe '.api_client?' do
33
- it 'returns true when client is a brandwatch-api-client' do
34
- bw = BWAPI::Client.new client_id: 'brandwatch-api-client'
35
- expect(bw.api_client?).to eql(true)
36
- end
37
-
38
- it 'returns false when a client is not a brandwatch-api-client' do
39
- bw = BWAPI::Client.new client_id: 'brandwatch-application-client'
40
- expect(bw.api_client?).to eql(false)
41
- end
42
- end
43
-
44
- describe '.netrc_credentials' do
45
- it 'returns nil when netrc is false' do
46
- bw = BWAPI::Client.new
47
- expect(bw.netrc_credentials).to eql(nil)
48
- end
49
-
50
- it 'returns credentials when netrc is true' do
51
- bw = BWAPI::Client.new netrc: true, netrc_file: File.join(fixture_path, '.netrc')
52
- bw.netrc_credentials
53
- expect(bw.username).to eql('testuser@brandwatch.com')
54
- expect(bw.password).to eql('password')
55
- end
56
- end
57
- end
@@ -1,3 +0,0 @@
1
- machine newapi.brandwatch.com
2
- login testuser@brandwatch.com
3
- password password