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.
@@ -4,5 +4,6 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
+ - 2.0.0
7
8
 
8
9
  script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem "httparty"
4
4
 
@@ -10,4 +10,5 @@ end
10
10
 
11
11
  group :development do
12
12
  gem "jeweler"
13
+ gem "builder"
13
14
  end
@@ -1,6 +1,7 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
+ builder (3.2.0)
4
5
  diff-lcs (1.1.3)
5
6
  git (1.2.5)
6
7
  httparty (0.9.0)
@@ -31,6 +32,7 @@ PLATFORMS
31
32
  ruby
32
33
 
33
34
  DEPENDENCIES
35
+ builder
34
36
  httparty
35
37
  jeweler
36
38
  rake
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  task :default => :spec
23
23
 
24
- require 'rake/rdoctask'
24
+ require 'rdoc/task'
25
25
  Rake::RDocTask.new do |rdoc|
26
26
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
27
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.9.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hipchat"
8
- s.version = "0.8.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-03-15"
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"])
@@ -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 }
@@ -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
- send_options.merge!(:color => success_message_color)
34
+ if hipchat_send_notification
35
+ send_options.merge!(:color => success_message_color)
35
36
 
36
- environment_string = env
37
- if self.respond_to?(:stage)
38
- environment_string = "#{stage} (#{env})"
39
- end
37
+ environment_string = env
38
+ if self.respond_to?(:stage)
39
+ environment_string = "#{stage} (#{env})"
40
+ end
40
41
 
41
- send("#{human} finished deploying #{deployment_name} to #{environment_string}#{fetch(:hipchat_with_migrations, '')}.", send_options)
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
@@ -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
- client = HipChat::Client.new(@api_token)
28
- client[@room_name].send('Chef', msg, :notify => @notify_users)
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
@@ -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.8.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-03-15 00:00:00.000000000 Z
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: 2556426077503697686
149
+ hash: -3630291999816657472
134
150
  required_rubygems_version: !ruby/object:Gem::Requirement
135
151
  none: false
136
152
  requirements: