headquarters 0.0.6 → 0.1.1
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +31 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +120 -3
- data/Rakefile +6 -1
- data/headquarters.gemspec +11 -7
- data/lib/headquarters/email/rails_delivery_method.rb +30 -0
- data/lib/headquarters/email.rb +31 -0
- data/lib/headquarters/endpoints.rb +14 -0
- data/lib/headquarters/github.rb +7 -0
- data/lib/headquarters/member.rb +15 -0
- data/lib/headquarters/railtie.rb +12 -0
- data/lib/headquarters/request.rb +64 -3
- data/lib/headquarters/version.rb +1 -1
- data/lib/headquarters.rb +26 -2
- data/spec/email_spec.rb +16 -0
- data/spec/github_spec.rb +25 -0
- data/spec/member_spec.rb +25 -0
- data/spec/request_spec.rb +56 -0
- data/spec/spec_helper.rb +13 -0
- metadata +82 -10
- data/lib/headquarters/members.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c8858cd727bb5bfaa410338e9954e8aead57fb
|
4
|
+
data.tar.gz: 14be54a98af2d5aa54487e167ebaff35f8df1756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20688ff4596a0c475d428f8783358cae21a066bc87c50fc2f3c3de0120316ace93fee8830fe32afc02ebd9fcd98244ec2515ad347f0d4830563b4b9578b60a4a
|
7
|
+
data.tar.gz: 66fa2672ef7ddf33476e4533c7c1acf8af9044288f3a1415bf829a5096ec880fe48cef1d987ece4210a9e8a686168319c7e7dfa51e4960db71901cdce1489f77
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/Rakefile'
|
4
|
+
- '**/config.ru'
|
5
|
+
Exclude:
|
6
|
+
- 'db/**/*'
|
7
|
+
- 'config/**/*'
|
8
|
+
- 'script/**/*'
|
9
|
+
- 'bin/**/*'
|
10
|
+
- 'vendor/**/*'
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/AlignParameters:
|
16
|
+
EnforcedStyle: with_fixed_indentation
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/DotPosition:
|
25
|
+
EnforcedStyle: trailing
|
26
|
+
|
27
|
+
Style/IfUnlessModifier:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/RegexpLiteral:
|
31
|
+
MaxSlashes: 0
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Headquarters
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[](https://semaphoreapp.com/groupbuddies/headquarters-ruby)
|
4
|
+
|
5
|
+
Ruby wrapper for the [headquarters API](https://github.com/groupbuddies/headquarters)
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
@@ -11,6 +12,12 @@ Add this line to your application's Gemfile:
|
|
11
12
|
gem 'headquarters'
|
12
13
|
```
|
13
14
|
|
15
|
+
Or if you want the edge version:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'headquarters', github: 'groupbuddies/headquarters-ruby'
|
19
|
+
```
|
20
|
+
|
14
21
|
And then execute:
|
15
22
|
|
16
23
|
$ bundle
|
@@ -19,9 +26,119 @@ Or install it yourself as:
|
|
19
26
|
|
20
27
|
$ gem install headquarters
|
21
28
|
|
29
|
+
|
30
|
+
## Configuration
|
31
|
+
|
32
|
+
You can set the API's base endpoint and port:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Headquarters.api_base = "0.0.0.0"
|
36
|
+
Headquarters.api_port = 3000
|
37
|
+
```
|
38
|
+
|
39
|
+
### Logging
|
40
|
+
|
41
|
+
Out of the box headquarters-ruby will log all requests and responses to `STDOUT`, you
|
42
|
+
can use any logger you want, though:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Headquarters.logger = Logger.new(STDERR)
|
46
|
+
```
|
47
|
+
|
22
48
|
## Usage
|
23
49
|
|
24
|
-
|
50
|
+
These are all the available method to interact with the headquarters.
|
51
|
+
|
52
|
+
### Members
|
53
|
+
|
54
|
+
To retrieve a collection of all members of the team you might use the `all`
|
55
|
+
operation:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Headquarters::Member.all
|
59
|
+
```
|
60
|
+
|
61
|
+
Or you can search for a specific email
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Headquarters::Member.search('mpalhas@groupbuddies.com')
|
65
|
+
```
|
66
|
+
|
67
|
+
### Pull Requests
|
68
|
+
|
69
|
+
To get all (paginated) pull requests for groupbuddies, use the
|
70
|
+
`pull_requests` operation:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Headquarters::Github.pull_requests
|
74
|
+
```
|
75
|
+
|
76
|
+
You can filter these results using anything that github takes in the `q`
|
77
|
+
parameters of its [search API](https://developer.github.com/v3/search/). For
|
78
|
+
instance, if you want to get only the open pull requests, you might do:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Headquarters::Github.pull_requests(query: 'is:open')
|
82
|
+
```
|
83
|
+
|
84
|
+
### Internal
|
85
|
+
|
86
|
+
There is some extra info protected with basic authentication. In order to get it
|
87
|
+
you must first add the credentials to you `.env` file:
|
88
|
+
|
89
|
+
```
|
90
|
+
BASIC_AUTH_USER=some-username
|
91
|
+
BASIC_AUTH_PASS=some-password
|
92
|
+
```
|
93
|
+
|
94
|
+
#### Members
|
95
|
+
|
96
|
+
Now you may use the `all_internal` operation:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
Headquarters::Member.all_internal
|
100
|
+
```
|
101
|
+
|
102
|
+
#### Emails
|
103
|
+
|
104
|
+
You can send emails for Group Buddies addresses (Any non-GB addresses will be filtered out).
|
105
|
+
|
106
|
+
`app_name` can be set to be appended to the sender. i.e. `from: hq@groupbuddies.com, app_name: test` will become `hq+test@groupbuddies.com`. This is useful for filtering and labeling.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
Headquarters::Email.send(to: 'mpalhas@groupbuddies.com,zamith@groupbuddies.com', subject: 'custom subject', body: '<b>HTML body</b>', app_name: 'hq')
|
110
|
+
```
|
111
|
+
|
112
|
+
When using rails you can use headquarters as the delivery method, and transparently send emails using ActiveMailer as usual:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
# config/initializers/mailer.rb
|
116
|
+
ActionMailer::Base.delivery_method = :headquarters
|
117
|
+
```
|
118
|
+
|
119
|
+
Using this method, `app_name` is also available as a header or parameter to the `mail` function
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
class CustomMailer < ActionMailer::Base
|
123
|
+
# option 1, default header
|
124
|
+
default 'app_name' => 'MyApp'
|
125
|
+
|
126
|
+
def email
|
127
|
+
# option 2, as an argument
|
128
|
+
mail to: 'example@email.com', subjet: 'Subject', app_name: 'MyApp'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
## Testing
|
134
|
+
|
135
|
+
To run the tests (including style tests with Rubucop) install all the
|
136
|
+
dependencies and run the default rake task:
|
137
|
+
|
138
|
+
```
|
139
|
+
bundle install
|
140
|
+
bundle exec rake
|
141
|
+
```
|
25
142
|
|
26
143
|
## Contributing
|
27
144
|
|
data/Rakefile
CHANGED
data/headquarters.gemspec
CHANGED
@@ -4,22 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'headquarters/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'headquarters'
|
8
8
|
spec.version = Headquarters::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Miguel Palhas', 'Luís Ferreira']
|
10
|
+
spec.email = ['mpalhas@groupbuddies.com', 'zamith@groupbuddies.com']
|
11
11
|
spec.summary = %q{Ruby wrapper for the headquarters API for Group Buddies}
|
12
12
|
spec.description = %q{Ruby wrapper for the headquarters API for Group Buddies}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/groupbuddies/headquarters-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency 'dotenv'
|
21
22
|
spec.add_dependency 'httparty', '>= 0.13.3'
|
22
23
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'climate_control'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.27.1'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
28
|
+
spec.add_development_dependency 'webmock', '~> 1.20.4'
|
25
29
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'headquarters/email'
|
2
|
+
|
3
|
+
module Headquarters
|
4
|
+
class Email
|
5
|
+
class RailsDeliveryMethod
|
6
|
+
attr_accessor :options
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
self.options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def deliver(mail)
|
13
|
+
params = {
|
14
|
+
from: mail.from,
|
15
|
+
to: mail.to,
|
16
|
+
subject: mail.subject,
|
17
|
+
body: mail.body.to_s,
|
18
|
+
app_name: mail.header['app_name'].to_s
|
19
|
+
}
|
20
|
+
Headquarters::Email.new(params).send
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_method :deliver!, :deliver
|
24
|
+
alias_method :deliver_now, :deliver
|
25
|
+
alias_method :deliver_now!, :deliver
|
26
|
+
alias_method :deliver_later, :deliver
|
27
|
+
alias_method :deliver_later!, :deliver
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Headquarters
|
2
|
+
class Email
|
3
|
+
FIELDS = %i(to from subject app_name body)
|
4
|
+
|
5
|
+
def self.send(**raw_params)
|
6
|
+
prepare_params(raw_params)
|
7
|
+
Request.perform_with_auth(:post, Endpoints::Internal::EMAIL, params)
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor(*FIELDS)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.params
|
15
|
+
Hash[FIELDS.map do |field|
|
16
|
+
[field, public_send(field)]
|
17
|
+
end.compact]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.prepare_params(raw_params)
|
21
|
+
@to = raw_params[:to]
|
22
|
+
if @to.is_a? Array
|
23
|
+
@to = @to.join(',')
|
24
|
+
end
|
25
|
+
@from = raw_params[:from]
|
26
|
+
@subject = raw_params[:subject]
|
27
|
+
@app_name = raw_params[:app_name]
|
28
|
+
@body = raw_params[:body]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Headquarters
|
2
|
+
class Member
|
3
|
+
def self.all
|
4
|
+
Request.perform(:get, Endpoints::MEMBERS)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.search(query)
|
8
|
+
Request.perform(:get, Endpoints::MEMBERS, q: query)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.all_internal
|
12
|
+
Request.perform_with_auth(:get, Endpoints::Internal::MEMBERS)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'headquarters/email'
|
2
|
+
require 'headquarters/email/rails_delivery_method'
|
3
|
+
|
4
|
+
module Headquarters
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer 'headquaters.add_delivery_method' do
|
7
|
+
ActiveSupport.on_load :action_mailer do
|
8
|
+
ActionMailer::Base.add_delivery_method :headquarters, Headquarters::Email::RailsDeliveryMethod
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/headquarters/request.rb
CHANGED
@@ -3,10 +3,71 @@ require 'httparty'
|
|
3
3
|
module Headquarters
|
4
4
|
class Request
|
5
5
|
include ::HTTParty
|
6
|
-
base_uri
|
6
|
+
base_uri Headquarters.api_base
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
8
|
+
def self.perform_with_auth(http_method, path, params = {}, options = {})
|
9
|
+
options_with_auth = options.merge(basic_auth_info)
|
10
|
+
perform(http_method, path, params, options_with_auth)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.perform(http_method, path, params = {}, options = {})
|
14
|
+
new(path, params, options).public_send(http_method)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(path, params, options)
|
18
|
+
@path = path
|
19
|
+
@options = options
|
20
|
+
@params = params
|
21
|
+
end
|
22
|
+
|
23
|
+
def get
|
24
|
+
@options.merge!(query: params) if params && params.any?
|
25
|
+
response = Request.get(path, options)
|
26
|
+
log_request_info(:get, response)
|
27
|
+
response.parsed_response
|
28
|
+
end
|
29
|
+
|
30
|
+
def post
|
31
|
+
@options.merge!(body: params) if params && params.any?
|
32
|
+
response = Request.post(path, options)
|
33
|
+
log_request_info(:post, response)
|
34
|
+
response.parsed_response
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :path, :options, :params
|
40
|
+
|
41
|
+
def log_request_info(http_method, response)
|
42
|
+
Headquarters.logger.info "[HQ] [#{current_time}] #{http_method.to_s.upcase} #{path} #{options} #{response.code}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_time
|
46
|
+
Time.now.utc.strftime('%d/%b/%Y %H:%M:%S %Z')
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.basic_auth_info
|
50
|
+
hq_basic_auth_info || deprecated_basic_auth_info
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.hq_basic_auth_info
|
54
|
+
return unless ENV['HQ_BASIC_AUTH_USER']
|
55
|
+
{
|
56
|
+
basic_auth: {
|
57
|
+
username: ENV['HQ_BASIC_AUTH_USER'],
|
58
|
+
password: ENV['HQ_BASIC_AUTH_PASS']
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.deprecated_basic_auth_info
|
64
|
+
warn '[DEPRECATED] Using ENV["BASIC_AUTH_USER"] is deprecated. Please use ENV["HQ_BASIC_AUTH_USER"]'
|
65
|
+
{
|
66
|
+
basic_auth: {
|
67
|
+
username: ENV['BASIC_AUTH_USER'],
|
68
|
+
password: ENV['BASIC_AUTH_PASS']
|
69
|
+
}
|
70
|
+
}
|
10
71
|
end
|
11
72
|
end
|
12
73
|
end
|
data/lib/headquarters/version.rb
CHANGED
data/lib/headquarters.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'logger'
|
3
|
+
require 'dotenv'
|
4
|
+
|
1
5
|
require 'headquarters/version'
|
2
|
-
require 'headquarters/
|
3
|
-
|
6
|
+
require 'headquarters/endpoints'
|
7
|
+
|
8
|
+
if defined? ::Rails::Railtie
|
9
|
+
require 'headquarters/railtie'
|
10
|
+
end
|
4
11
|
|
5
12
|
module Headquarters
|
13
|
+
API_BASE = 'hq.groupbuddies.com'
|
14
|
+
ROOT_PATH = File.dirname(__FILE__)
|
15
|
+
|
16
|
+
@api_base = API_BASE
|
17
|
+
@api_port = Net::HTTP.https_default_port
|
18
|
+
@logger = Logger.new(STDOUT)
|
19
|
+
|
20
|
+
class << self
|
21
|
+
attr_accessor :api_base, :api_port, :logger
|
22
|
+
end
|
6
23
|
end
|
24
|
+
|
25
|
+
require 'headquarters/request'
|
26
|
+
require 'headquarters/member'
|
27
|
+
require 'headquarters/github'
|
28
|
+
require 'headquarters/email'
|
29
|
+
|
30
|
+
Dotenv.load
|
data/spec/email_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Headquarters
|
4
|
+
describe Email do
|
5
|
+
context '.send' do
|
6
|
+
it 'makes a new POST request using the correct API endpoint' do
|
7
|
+
allow(Request).to receive(:perform_with_auth)
|
8
|
+
params = { subject: 'fake subject' }
|
9
|
+
|
10
|
+
Email.send(params)
|
11
|
+
|
12
|
+
expect(Request).to have_received(:perform_with_auth).with(:post, Endpoints::Internal::EMAIL, hash_including(params))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/github_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Headquarters
|
4
|
+
describe Github do
|
5
|
+
context '.pull_requests' do
|
6
|
+
it 'asks for all the pull requests' do
|
7
|
+
allow(Request).to receive(:perform)
|
8
|
+
|
9
|
+
Github.pull_requests
|
10
|
+
|
11
|
+
expect(Request).to have_received(:perform).
|
12
|
+
with(:get, Endpoints::Github::PULL_REQUESTS, query: { q: nil })
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'asks for the open pull requests' do
|
16
|
+
allow(Request).to receive(:perform)
|
17
|
+
|
18
|
+
Github.pull_requests(query: 'is:open')
|
19
|
+
|
20
|
+
expect(Request).to have_received(:perform).
|
21
|
+
with(:get, Endpoints::Github::PULL_REQUESTS, query: { q: 'is:open' })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/member_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Headquarters
|
4
|
+
describe Member do
|
5
|
+
context '.all' do
|
6
|
+
it 'makes a new GET request using the correct API endpoint' do
|
7
|
+
allow(Request).to receive(:perform)
|
8
|
+
|
9
|
+
Member.all
|
10
|
+
|
11
|
+
expect(Request).to have_received(:perform).with(:get, Endpoints::MEMBERS)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context '.all_internal' do
|
16
|
+
it 'makes a new GET request using the correct API endpoint' do
|
17
|
+
allow(Request).to receive(:perform_with_auth)
|
18
|
+
|
19
|
+
Member.all_internal
|
20
|
+
|
21
|
+
expect(Request).to have_received(:perform_with_auth).with(:get, Endpoints::Internal::MEMBERS)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
WebMock.disable_net_connect!
|
4
|
+
|
5
|
+
module Headquarters
|
6
|
+
describe Request do
|
7
|
+
let(:request) { spy('request') }
|
8
|
+
|
9
|
+
context '.perform' do
|
10
|
+
it 'makes the correct call for a GET' do
|
11
|
+
allow(Request).to receive(:new).and_return(request)
|
12
|
+
|
13
|
+
Request.perform(:get, '/some-url')
|
14
|
+
|
15
|
+
expect(request).to have_received(:get)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'makes the correct call for a POST' do
|
19
|
+
allow(Request).to receive(:new).and_return(request)
|
20
|
+
|
21
|
+
Request.perform(:post, '/some-url')
|
22
|
+
|
23
|
+
expect(request).to have_received(:post)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'makes the actual call' do
|
27
|
+
url = '/some-url'
|
28
|
+
stub_request(:get, Headquarters.api_base + url)
|
29
|
+
allow(Request).to receive(:get).and_call_original
|
30
|
+
|
31
|
+
Request.perform(:get, url)
|
32
|
+
|
33
|
+
expect(Request).to have_received(:get).with(url, {})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context '.perform_with_auth' do
|
38
|
+
it 'makes the actual call with basic auth' do
|
39
|
+
url = '/some-url'
|
40
|
+
credentials = { basic_auth: { username: 'user', password: 'pass' } }
|
41
|
+
new_env = {
|
42
|
+
BASIC_AUTH_PASS: credentials[:basic_auth][:password],
|
43
|
+
BASIC_AUTH_USER: credentials[:basic_auth][:username]
|
44
|
+
}
|
45
|
+
stub_request(:get, 'user:pass@' + Headquarters.api_base + url)
|
46
|
+
allow(Request).to receive(:get).and_call_original
|
47
|
+
|
48
|
+
with_modified_env new_env do
|
49
|
+
Request.perform_with_auth(:get, url)
|
50
|
+
|
51
|
+
expect(Request).to have_received(:get).with(url, credentials)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'headquarters'
|
2
|
+
require 'climate_control'
|
3
|
+
|
4
|
+
Dir[File.join(Headquarters::ROOT_PATH, 'spec/support/**/*.rb')].each { |f| require f }
|
5
|
+
|
6
|
+
class DummyLogger
|
7
|
+
def self.info(_message); end
|
8
|
+
end
|
9
|
+
Headquarters.logger = DummyLogger
|
10
|
+
|
11
|
+
def with_modified_env(options, &block)
|
12
|
+
ClimateControl.modify(options, &block)
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: headquarters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Palhas
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: dotenv
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: httparty
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -26,19 +40,19 @@ dependencies:
|
|
26
40
|
- !ruby/object:Gem::Version
|
27
41
|
version: 0.13.3
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
43
|
+
name: climate_control
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
|
-
- - "
|
46
|
+
- - ">="
|
33
47
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
48
|
+
version: '0'
|
35
49
|
type: :development
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
|
-
- - "
|
53
|
+
- - ">="
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
55
|
+
version: '0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: rake
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +67,48 @@ dependencies:
|
|
53
67
|
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.27.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.27.1
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.1.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 3.1.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: webmock
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.20.4
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.20.4
|
56
112
|
description: Ruby wrapper for the headquarters API for Group Buddies
|
57
113
|
email:
|
58
114
|
- mpalhas@groupbuddies.com
|
@@ -62,15 +118,26 @@ extensions: []
|
|
62
118
|
extra_rdoc_files: []
|
63
119
|
files:
|
64
120
|
- ".gitignore"
|
121
|
+
- ".rubocop.yml"
|
65
122
|
- Gemfile
|
66
123
|
- LICENSE
|
67
124
|
- README.md
|
68
125
|
- Rakefile
|
69
126
|
- headquarters.gemspec
|
70
127
|
- lib/headquarters.rb
|
71
|
-
- lib/headquarters/
|
128
|
+
- lib/headquarters/email.rb
|
129
|
+
- lib/headquarters/email/rails_delivery_method.rb
|
130
|
+
- lib/headquarters/endpoints.rb
|
131
|
+
- lib/headquarters/github.rb
|
132
|
+
- lib/headquarters/member.rb
|
133
|
+
- lib/headquarters/railtie.rb
|
72
134
|
- lib/headquarters/request.rb
|
73
135
|
- lib/headquarters/version.rb
|
136
|
+
- spec/email_spec.rb
|
137
|
+
- spec/github_spec.rb
|
138
|
+
- spec/member_spec.rb
|
139
|
+
- spec/request_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
74
141
|
homepage: https://github.com/groupbuddies/headquarters-ruby
|
75
142
|
licenses:
|
76
143
|
- MIT
|
@@ -91,8 +158,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
158
|
version: '0'
|
92
159
|
requirements: []
|
93
160
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.4.
|
161
|
+
rubygems_version: 2.4.5
|
95
162
|
signing_key:
|
96
163
|
specification_version: 4
|
97
164
|
summary: Ruby wrapper for the headquarters API for Group Buddies
|
98
|
-
test_files:
|
165
|
+
test_files:
|
166
|
+
- spec/email_spec.rb
|
167
|
+
- spec/github_spec.rb
|
168
|
+
- spec/member_spec.rb
|
169
|
+
- spec/request_spec.rb
|
170
|
+
- spec/spec_helper.rb
|