hipchat 0.8.0 → 0.9.0
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.
- data/.travis.yml +1 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/hipchat.gemspec +5 -2
- data/lib/hipchat.rb +4 -0
- data/lib/hipchat/capistrano.rb +9 -7
- data/lib/hipchat/chef.rb +15 -4
- data/spec/hipchat_spec.rb +4 -0
- metadata +19 -3
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/hipchat.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "hipchat"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.9.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["HipChat/Atlassian"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-05-18"
|
13
13
|
s.description = "Ruby library to interact with HipChat"
|
14
14
|
s.email = "support@hipchat.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -46,12 +46,14 @@ Gem::Specification.new do |s|
|
|
46
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
47
|
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
48
48
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<builder>, [">= 0"])
|
49
50
|
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
50
51
|
s.add_development_dependency(%q<rspec>, ["~> 2.0"])
|
51
52
|
s.add_development_dependency(%q<rr>, ["~> 1.0"])
|
52
53
|
else
|
53
54
|
s.add_dependency(%q<httparty>, [">= 0"])
|
54
55
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
56
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
55
57
|
s.add_dependency(%q<httparty>, [">= 0"])
|
56
58
|
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
57
59
|
s.add_dependency(%q<rr>, ["~> 1.0"])
|
@@ -59,6 +61,7 @@ Gem::Specification.new do |s|
|
|
59
61
|
else
|
60
62
|
s.add_dependency(%q<httparty>, [">= 0"])
|
61
63
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
64
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
62
65
|
s.add_dependency(%q<httparty>, [">= 0"])
|
63
66
|
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
64
67
|
s.add_dependency(%q<rr>, ["~> 1.0"])
|
data/lib/hipchat.rb
CHANGED
@@ -7,6 +7,7 @@ module HipChat
|
|
7
7
|
class UnknownRoom < StandardError; end
|
8
8
|
class Unauthorized < StandardError; end
|
9
9
|
class UnknownResponseCode < StandardError; end
|
10
|
+
class UsernameTooLong < StandardError; end
|
10
11
|
|
11
12
|
class Client
|
12
13
|
include HTTParty
|
@@ -59,6 +60,9 @@ module HipChat
|
|
59
60
|
# +notify+:: true or false
|
60
61
|
# (default false)
|
61
62
|
def send(from, message, options_or_notify = {})
|
63
|
+
if from.length > 15
|
64
|
+
raise UsernameTooLong, "Username #{from} is `#{from.length} characters long. Limit is 15'"
|
65
|
+
end
|
62
66
|
options = if options_or_notify == true or options_or_notify == false
|
63
67
|
warn "DEPRECATED: Specify notify flag as an option (e.g., :notify => true)"
|
64
68
|
{ :notify => options_or_notify }
|
data/lib/hipchat/capistrano.rb
CHANGED
@@ -6,7 +6,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
|
7
7
|
namespace :hipchat do
|
8
8
|
task :trigger_notification do
|
9
|
-
set :hipchat_send_notification, true
|
9
|
+
set :hipchat_send_notification, true if !dry_run
|
10
10
|
end
|
11
11
|
|
12
12
|
task :configure_for_migrations do
|
@@ -31,14 +31,16 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
task :notify_deploy_finished do
|
34
|
-
|
34
|
+
if hipchat_send_notification
|
35
|
+
send_options.merge!(:color => success_message_color)
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
environment_string = env
|
38
|
+
if self.respond_to?(:stage)
|
39
|
+
environment_string = "#{stage} (#{env})"
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
+
send("#{human} finished deploying #{deployment_name} to #{environment_string}#{fetch(:hipchat_with_migrations, '')}.", send_options)
|
43
|
+
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def send_options
|
data/lib/hipchat/chef.rb
CHANGED
@@ -15,17 +15,28 @@ require 'hipchat'
|
|
15
15
|
module HipChat
|
16
16
|
class NotifyRoom < Chef::Handler
|
17
17
|
|
18
|
-
def initialize(api_token, room_name, notify_users=false)
|
18
|
+
def initialize(api_token, room_name, notify_users=false, report_success=false)
|
19
19
|
@api_token = api_token
|
20
20
|
@room_name = room_name
|
21
21
|
@notify_users = notify_users
|
22
|
+
@report_success = report_success
|
22
23
|
end
|
23
24
|
|
24
25
|
def report
|
25
|
-
msg = "Failure on #{node.name}: #{run_status.formatted_exception}"
|
26
|
+
msg = if run_status.failed? then "Failure on \"#{node.name}\": #{run_status.formatted_exception}"
|
27
|
+
elsif run_status.success? && @report_success
|
28
|
+
"Chef run on \"#{node.name}\" completed in #{run_status.elapsed_time.round(2)} seconds"
|
29
|
+
else nil
|
30
|
+
end
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
color = if run_status.success? then 'green'
|
33
|
+
else 'red'
|
34
|
+
end
|
35
|
+
|
36
|
+
if msg
|
37
|
+
client = HipChat::Client.new(@api_token)
|
38
|
+
client[@room_name].send('Chef', msg, :notify => @notify_users, :color => color)
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
data/spec/hipchat_spec.rb
CHANGED
@@ -111,6 +111,10 @@ describe HipChat do
|
|
111
111
|
lambda { room.send "", "" }.should raise_error(HipChat::Unauthorized)
|
112
112
|
end
|
113
113
|
|
114
|
+
it "but fails if the username is more than 15 chars" do
|
115
|
+
lambda { room.send "a very long username here", "a message" }.should raise_error(HipChat::UsernameTooLong)
|
116
|
+
end
|
117
|
+
|
114
118
|
it "but fails if we get an unknown response code" do
|
115
119
|
mock(HipChat::Room).post(anything, anything) {
|
116
120
|
OpenStruct.new(:code => 403)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: builder
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: httparty
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
146
|
version: '0'
|
131
147
|
segments:
|
132
148
|
- 0
|
133
|
-
hash:
|
149
|
+
hash: -3630291999816657472
|
134
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
151
|
none: false
|
136
152
|
requirements:
|