mina-rollbar 1.0.0 → 1.0.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
- SHA1:
3
- metadata.gz: fd9cb62f390ac0d4daff0c6dd77d364c6f97f35d
4
- data.tar.gz: 8f1738c968934669883cbb4108c260f745b33476
2
+ SHA256:
3
+ metadata.gz: 41e7cbc805007c993e9f946db75a6be6d6e1147d819303d5b7da6cca27dd1f33
4
+ data.tar.gz: 6c6d787b7861f98a5f0209679b135dc8b978b2e5ea77b2e2bb6fc33f9aadffe1
5
5
  SHA512:
6
- metadata.gz: 3fbca57b21c9d81b46d4239681c49f4c7a7263ce9ab414bfa37c23875ac988c055f8eb28f6dbfb63a79d8b4647b21df8a3de6e11d84b8aaab512e4080a9a92ca
7
- data.tar.gz: ad4747c7ee87927e02b01987045ee7210bbee8647757324685b29d6ecbfa3e86b7044adb5d3c80582035124309b1df3b13091dded6de2cdf3c285193a556ca43
6
+ metadata.gz: 0cfeb277a43c328956255554663f1dc201a20bafd1f04925842cd3c6912a9df176f8ac63fb4483332189f8db11fff7397aed664afa1ddd16c4d733c55d65f00d
7
+ data.tar.gz: 0b3dd33df8eb592de51d2e19805311216d358d3038ac037a074941abea37dba24234d3f0c7896fc75f27e2e26ee456b877005c0d679227207dd413976d4dcfa9
@@ -0,0 +1,14 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_style = space
7
+ insert_final_newline = true
8
+
9
+ [*.{rb,spec}]
10
+ indent_size = 2
11
+ trim_trailing_whitespace = true
12
+
13
+ [*.[md,MD,markdown}]
14
+ indent_size = 2
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Aramis Group, LLC dba code lever
1
+ Copyright (c) 2014-2018 Aramis Group, LLC dba code lever
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -20,13 +20,11 @@ And then execute:
20
20
 
21
21
  ## Usage
22
22
 
23
- **Note:** Currently requires `curl` to be present on the server for notifications to be sent. Patches happily accepted to improve this limitation!
24
-
25
23
  require 'mina/rollbar'
26
24
 
27
25
  ...
28
26
  # replace value w/your real access token
29
- set :rollbar_access_token, '9a18d718214b4348822b7cec493f86d2'
27
+ set :rollbar_access_token, 'this-is-not-a-real-token'
30
28
 
31
29
  task deploy: :environment do
32
30
  deploy do
@@ -41,14 +39,13 @@ And then execute:
41
39
 
42
40
  ## Options
43
41
 
44
- | Name | Description |
45
- | ---------------------------- | -------------------------------------------------- |
46
- | `rollbar_access_token` | Rollbar access token (post_server_item token) |
47
- | `rollbar_username` | Rollbar username of deploying user (optional) |
48
- | `rollbar_local_username` | Local username of deploying user (optional) |
49
- | `rollbar_comment` | Comment for this deployment (optional) |
50
- | `rollbar_notification_debug` | `true` to enable notification debugging info |
51
- | `rollbar_environment` | Deployment environment string, defaults to `rails_env` |
42
+ | Name | Description |
43
+ | ---------------------------- | ------------------------------------------------------ |
44
+ | `rollbar_access_token` | Rollbar access token (post_server_item token) |
45
+ | `rollbar_username` | Rollbar username of deploying user (optional) |
46
+ | `rollbar_local_username` | Local username of deploying user (optional) |
47
+ | `rollbar_comment` | Comment for this deployment (optional) |
48
+ | `rollbar_env` | Deployment environment string, defaults to `rails_env` |
52
49
 
53
50
  ## Contributing
54
51
 
@@ -20,6 +20,10 @@
20
20
  # end
21
21
  # end
22
22
 
23
+ require 'net/http'
24
+ require 'rubygems'
25
+ require 'json'
26
+
23
27
  require 'mina/rails'
24
28
 
25
29
  # ## Settings
@@ -41,47 +45,53 @@ set :rollbar_local_username, %x[whoami].strip rescue nil
41
45
  # Sets a deployment comment (what was deployed, etc.). Optional.
42
46
  set :rollbar_comment, nil
43
47
 
44
- # ### rollbar_notification_debug
45
- # If true, enables verbosity in the notification to help debug issues. Defaults to false.
46
- set :rollbar_notification_debug, false
47
-
48
- # ### :rollbar_environment
48
+ # ### :rollbar_env
49
49
  # Sets the rollbar environment being deployed. If left un-set, will default to `rails_env` value.
50
- set :rollbar_environment, nil
50
+ set :rollbar_env, nil
51
51
 
52
52
  namespace :rollbar do
53
53
 
54
54
  desc 'Notifies Rollbar of your deployment'
55
- task notify: :environment do
55
+ task :notify do
56
56
 
57
57
  unless fetch(:rollbar_access_token)
58
- print_error 'Must set your `:rollbar_access_token` to notify'
59
- exit
58
+ print_error 'Rollbar: You must set `:rollbar_access_token` to notify'
59
+ next
60
60
  end
61
61
 
62
62
  unless set?(:branch) || set?(:commit)
63
- print_error 'Must define either `:branch` or `:commit`'
64
- exit
63
+ print_error 'Rollbar: Must set either `:branch` or `:commit`'
64
+ next
65
65
  end
66
66
 
67
- revision = set?(:commit) ? fetch(:commit) : %x[git rev-parse #{fetch(:branch)}].strip
68
-
69
- silent = fetch(:rollbar_notification_debug) ? '-v' : '-s -o /dev/null'
70
- script = ["curl #{silent} https://api.rollbar.com/api/1/deploy/"]
71
- script << "-F access_token=#{fetch(:rollbar_access_token)}"
72
- if set?(:rollbar_environment)
73
- script << "-F environment=#{fetch(:rollbar_environment)}"
74
- else
75
- script << "-F environment=#{fetch(:rails_env)}"
67
+ uri = URI.parse 'https://api.rollbar.com/api/1/deploy/'
68
+ revision = fetch(:commit) || %x[git rev-parse origin/#{fetch(:branch)}].strip
69
+ params = {
70
+ local_username: fetch(:rollbar_local_username),
71
+ rollbar_username: fetch(:rollbar_username),
72
+ access_token: fetch(:rollbar_access_token),
73
+ environment: fetch(:rollbar_env) || fetch(:rollbar_environment) || fetch(:rails_env),
74
+ comment: fetch(:rollbar_comment),
75
+ revision: revision
76
+ }.reject { |_, value| value.nil? }
77
+
78
+ request = Net::HTTP::Post.new(uri.request_uri)
79
+ request.body = ::JSON.dump(params)
80
+
81
+ begin
82
+ comment "Notifying Rollbar of deployment"
83
+
84
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
85
+ response = http.request(request)
86
+
87
+ unless response.is_a?(Net::HTTPSuccess)
88
+ print_error "Rollbar: [#{response.code}] #{response.message}"
89
+ end
90
+ end
91
+
92
+ rescue StandardError => e
93
+ print_error "Rollbar: #{e.class} #{e.message}"
76
94
  end
77
- script << "-F revision=#{revision}"
78
- script << "-F local_username=#{fetch(:rollbar_local_username)}" if set?(:rollbar_local_username)
79
- script << "-F rollbar_username=#{fetch(:rollbar_username)}" if set?(:rollbar_username)
80
- script << "-F comment=#{set(:rollbar_comment)}" if set?(:rollbar_comment)
81
-
82
- comment %{Notifying Rollbar of deployment}
83
- command %[#{script.join(' ')}]
84
-
85
95
  end
86
96
 
87
97
  end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Rollbar
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'mina', '~> 1.0.0'
21
+ spec.add_dependency 'mina', '~> 1.0'
22
+ spec.add_dependency 'json', '~> 2.1.0'
22
23
 
23
24
  spec.add_development_dependency 'awesome_print'
24
25
  spec.add_development_dependency 'bundler', '~> 1.13'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2018-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mina
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: awesome_print
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -199,6 +213,7 @@ executables: []
199
213
  extensions: []
200
214
  extra_rdoc_files: []
201
215
  files:
216
+ - ".editorconfig"
202
217
  - ".gitignore"
203
218
  - ".rspec"
204
219
  - ".rubocop.yml"
@@ -231,9 +246,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
246
  version: '0'
232
247
  requirements: []
233
248
  rubyforge_project:
234
- rubygems_version: 2.4.8
249
+ rubygems_version: 2.7.5
235
250
  signing_key:
236
251
  specification_version: 4
237
252
  summary: Mina tasks for Rollbar
238
253
  test_files: []
239
- has_rdoc: