escobar 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1734c4c77497ac41042dada569e23e2f694921c7
4
- data.tar.gz: d08a56a8e2fe64867e066e77cbf44c9c19bf5743
3
+ metadata.gz: 4504457f5bf33b345fdb8250cff7d246a07c1102
4
+ data.tar.gz: 8780426f0b46903792a101954476e1781c9128f9
5
5
  SHA512:
6
- metadata.gz: 82a1cebae49c1fc0c6a2d12837cbb89cf0315b8d36a5932091a097072b969acf0cf18dc967862ffd6957b8b4cded1d5520b96c51d6cb5c204418328f50f3931c
7
- data.tar.gz: 323a9bc6acde6d4efb535002dcc0af090173c7b2856a0ef95d5e6db98df65325adaa7aa9e665ca2827ce5ec3f8ecb34e3875672cb53f50fda4f6e613dc7bceaa
6
+ metadata.gz: afd9fbe836337dcdd8eaee118bb8e246a500ca1b65bd3a92acafd85b4a217383ec3426b9b744ea67bf9aaf70ec9b4cedb9b6c91c8be1987fc1883fdb67e432d8
7
+ data.tar.gz: 953d97c4041b6669c3caa9fb485e2c93a83b7db63a37f0e6daef3bf0a72e2278874072fd3d704b06e15759e50ffadae59c79472d84b9ee012c212b8a1df1e2e2
@@ -74,6 +74,9 @@ MethodLength:
74
74
  Max: 25
75
75
  Severity: error
76
76
 
77
+ FrozenStringLiteralComment:
78
+ Enabled: false # Adding comment to all files...
79
+
77
80
  Alias:
78
81
  Enabled: false # We have no guidance on alias vs alias_method
79
82
 
@@ -87,6 +90,7 @@ Metrics/AbcSize:
87
90
  Max: 16
88
91
 
89
92
  AllCops:
93
+ TargetRubyVersion: 2.3
90
94
  # Include gemspec and Rakefile
91
95
  Include:
92
96
  - '**/*.gemspec'
@@ -103,7 +107,9 @@ AllCops:
103
107
  - 'script/**/*'
104
108
  - 'config/**/*'
105
109
  - 'vendor/**/*'
106
- # By default, the rails cops are not run. Override in project or home
107
- # directory .rubocop.yml files, or by giving the -R/--rails option.
110
+ # By default, the rails cops are not run. Override in project or home
111
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
108
112
  Rails:
109
- Enabled: false
113
+ Enabled: true
114
+ Rails/Delegate:
115
+ Enabled: false # delegate isn't available outside of rails?
data/README.md CHANGED
@@ -18,8 +18,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
18
18
 
19
19
  Bug reports and pull requests are welcome on GitHub at https://github.com/atmos/escobar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
20
20
 
21
-
22
21
  ## License
23
22
 
24
23
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
25
-
@@ -26,28 +26,25 @@ module Escobar
26
26
  response && response.headers && response.headers["Location"]
27
27
  end
28
28
 
29
+ def not_found
30
+ raise RepoNotFound, "Unable to access #{name_with_owner}"
31
+ end
32
+
29
33
  def required_contexts
30
34
  path = "/repos/#{name_with_owner}/branches/#{default_branch}"
31
35
  response = http_method(:get, path)
32
- if response.status == 200
33
- repo = JSON.parse(response.body)
34
- if repo["protection"] && repo["protection"]["enabled"]
35
- return repo["protection"]["required_status_checks"]["contexts"]
36
- else
37
- []
38
- end
39
- else
40
- raise RepoNotFound, "Unable to access #{name_with_owner}"
41
- end
36
+
37
+ not_found unless response.status == 200
38
+
39
+ repo = JSON.parse(response.body)
40
+ return [] unless repo["protection"] && repo["protection"]["enabled"]
41
+ repo["protection"]["required_status_checks"]["contexts"]
42
42
  end
43
43
 
44
44
  def default_branch
45
45
  response = http_method(:get, "/repos/#{name_with_owner}")
46
- if response.status == 200
47
- JSON.parse(response.body)["default_branch"]
48
- else
49
- raise RepoNotFound, "Unable to access #{name_with_owner}"
50
- end
46
+ not_found unless response.status == 200
47
+ JSON.parse(response.body)["default_branch"]
51
48
  end
52
49
 
53
50
  def create_deployment(options)
@@ -19,6 +19,11 @@ module Escobar
19
19
  def dashboard_url
20
20
  "https://dashboard.heroku.com/apps/#{name}"
21
21
  end
22
+
23
+ # Accepts either google authenticator or yubikey second_factor formatting
24
+ def preauth(second_factor)
25
+ !client.heroku.put("/apps/#{id}/pre-authorizations", second_factor).any?
26
+ end
22
27
  end
23
28
  end
24
29
  end
@@ -61,6 +61,23 @@ module Escobar
61
61
  response && response.body
62
62
  end
63
63
 
64
+ def put(path, second_factor = nil)
65
+ response = client.put do |request|
66
+ request.url path
67
+ request.headers["Accept"] = heroku_accept_header(3)
68
+ request.headers["Accept-Encoding"] = ""
69
+ request.headers["Content-Type"] = "application/json"
70
+ request.headers["Authorization"] = "Bearer #{token}"
71
+ if second_factor
72
+ request.headers["Heroku-Two-Factor-Code"] = second_factor
73
+ end
74
+ end
75
+
76
+ JSON.parse(response.body)
77
+ rescue StandardError
78
+ response && response.body
79
+ end
80
+
64
81
  private
65
82
 
66
83
  def heroku_accept_header(version)
@@ -97,7 +97,7 @@ module Escobar
97
97
  when "two_factor"
98
98
  description = "A second factor is required. Use your configured authenticator app or yubikey."
99
99
  create_github_deployment_status(github_deployment["url"], nil, "failure", description)
100
- return({ error: build["message"] })
100
+ { error: build["message"] }
101
101
  when Escobar::Heroku::BuildRequestSuccess
102
102
  target_url = "https://dashboard.heroku.com/apps/#{app.name}/activity/builds/#{build['id']}"
103
103
 
@@ -112,7 +112,7 @@ module Escobar
112
112
  deployment_url: github_deployment["url"]
113
113
  }
114
114
  else
115
- return({ error: "Unable to create heroku build for #{name}" })
115
+ { error: "Unable to create heroku build for #{name}" }
116
116
  end
117
117
  end
118
118
 
@@ -1,3 +1,3 @@
1
1
  module Escobar
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escobar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Donohoe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-10 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday