hipchat 0.5.0 → 0.6.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.
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+
8
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+
3
+ gem "httparty"
4
+
5
+ group :test do
6
+ gem "rake"
7
+ gem "rspec"
8
+ gem "rr"
9
+ end
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ httparty (0.9.0)
6
+ multi_json (~> 1.0)
7
+ multi_xml
8
+ multi_json (1.3.6)
9
+ multi_xml (0.5.1)
10
+ rake (0.9.2.2)
11
+ rr (1.0.4)
12
+ rspec (2.11.0)
13
+ rspec-core (~> 2.11.0)
14
+ rspec-expectations (~> 2.11.0)
15
+ rspec-mocks (~> 2.11.0)
16
+ rspec-core (2.11.1)
17
+ rspec-expectations (2.11.3)
18
+ diff-lcs (~> 1.1.3)
19
+ rspec-mocks (2.11.3)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ httparty
26
+ rake
27
+ rr
28
+ rspec
@@ -2,6 +2,10 @@ h1. HipChat Wrapper
2
2
 
3
3
  A very basic wrapper for the HipChat HTTP API.
4
4
 
5
+ h2. Build Status
6
+
7
+ "!https://travis-ci.org/hipchat/hipchat-rb.png!":https://travis-ci.org/hipchat/hipchat-rb
8
+
5
9
  h2. Usage
6
10
 
7
11
  bc.. client = HipChat::Client.new(api_token)
@@ -21,7 +25,7 @@ h2. Capistrano
21
25
  bc.. require 'hipchat/capistrano'
22
26
 
23
27
  set :hipchat_token, "<your token>"
24
- set :hipchat_room_name, "Your room"
28
+ set :hipchat_room_name, "Your room" # If you pass an array such as ["room_a", "room_b"] you can send announcements to multiple rooms.
25
29
  set :hipchat_announce, false # notify users
26
30
  set :hipchat_color, 'green' #finished deployment message color
27
31
  set :hipchat_failed_color, 'red' #cancelled deployment message color
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -4,20 +4,23 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "hipchat"
8
- s.version = "0.5.0"
7
+ s.name = %q{hipchat}
8
+ s.version = "0.6.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 = "2012-10-12"
13
- s.description = "Ruby library to interact with HipChat"
14
- s.email = "support@hipchat.com"
12
+ s.date = %q{2012-11-02}
13
+ s.description = %q{Ruby library to interact with HipChat}
14
+ s.email = %q{support@hipchat.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.textile"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".travis.yml",
22
+ "Gemfile",
23
+ "Gemfile.lock",
21
24
  "LICENSE",
22
25
  "README.textile",
23
26
  "Rakefile",
@@ -32,24 +35,28 @@ Gem::Specification.new do |s|
32
35
  "spec/spec.opts",
33
36
  "spec/spec_helper.rb"
34
37
  ]
35
- s.homepage = "https://github.com/hipchat/hipchat-rb"
38
+ s.homepage = %q{https://github.com/hipchat/hipchat-rb}
36
39
  s.require_paths = ["lib"]
37
- s.rubygems_version = "1.8.24"
38
- s.summary = "Ruby library to interact with HipChat"
40
+ s.rubygems_version = %q{1.3.6}
41
+ s.summary = %q{Ruby library to interact with HipChat}
39
42
 
40
43
  if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
45
  s.specification_version = 3
42
46
 
43
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
44
49
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
45
50
  s.add_development_dependency(%q<rspec>, ["~> 2.0"])
46
51
  s.add_development_dependency(%q<rr>, ["~> 1.0"])
47
52
  else
53
+ s.add_dependency(%q<httparty>, [">= 0"])
48
54
  s.add_dependency(%q<httparty>, [">= 0"])
49
55
  s.add_dependency(%q<rspec>, ["~> 2.0"])
50
56
  s.add_dependency(%q<rr>, ["~> 1.0"])
51
57
  end
52
58
  else
59
+ s.add_dependency(%q<httparty>, [">= 0"])
53
60
  s.add_dependency(%q<httparty>, [">= 0"])
54
61
  s.add_dependency(%q<rspec>, ["~> 2.0"])
55
62
  s.add_dependency(%q<rr>, ["~> 1.0"])
@@ -2,40 +2,30 @@ require 'hipchat'
2
2
 
3
3
  Capistrano::Configuration.instance(:must_exist).load do
4
4
  set :hipchat_send_notification, false
5
- set :hipchat_with_migrations, false
5
+ set :hipchat_with_migrations, ''
6
6
 
7
7
  namespace :hipchat do
8
- task :set_client do
9
- set :hipchat_client, HipChat::Client.new(hipchat_token)
10
- end
11
-
12
8
  task :trigger_notification do
13
9
  set :hipchat_send_notification, true
14
10
  end
15
11
 
16
12
  task :configure_for_migrations do
17
- set :hipchat_with_migrations, true
13
+ set :hipchat_with_migrations, ' (with migrations)'
18
14
  end
19
15
 
20
16
  task :notify_deploy_started do
21
17
  if hipchat_send_notification
22
18
  on_rollback do
23
19
  send_options.merge!(:color => failed_message_color)
24
- hipchat_client[hipchat_room_name].
25
- send(deploy_user, "#{human} cancelled deployment of #{deployment_name} to #{env}.", send_options)
20
+ send("#{human} cancelled deployment of #{deployment_name} to #{env}.", send_options)
26
21
  end
27
22
 
28
- message = "#{human} is deploying #{deployment_name} to #{env}"
29
- message << " (with migrations)" if hipchat_with_migrations
30
- message << "."
31
-
32
- hipchat_client[hipchat_room_name].send(deploy_user, message, send_options)
23
+ send("#{human} is deploying #{deployment_name} to #{env}#{fetch(:hipchat_with_migrations, '')}.", send_options)
33
24
  end
34
25
  end
35
26
 
36
27
  task :notify_deploy_finished do
37
- hipchat_client[hipchat_room_name].
38
- send(deploy_user, "#{human} finished deploying #{deployment_name} to #{env}.", send_options)
28
+ send("#{human} finished deploying #{deployment_name} to #{env}#{fetch(:hipchat_with_migrations, '')}.", send_options)
39
29
  end
40
30
 
41
31
  def send_options
@@ -46,6 +36,22 @@ Capistrano::Configuration.instance(:must_exist).load do
46
36
  @send_options
47
37
  end
48
38
 
39
+ def send(message, options)
40
+ set :hipchat_client, HipChat::Client.new(hipchat_token) if fetch(:hipchat_client, nil).nil?
41
+
42
+ if hipchat_room_name.is_a?(String)
43
+ rooms = [hipchat_room_name]
44
+ elsif hipchat_room_name.is_a?(Symbol)
45
+ rooms = [hipchat_room_name.to_s]
46
+ else
47
+ rooms = hipchat_room_name
48
+ end
49
+
50
+ rooms.each { |room|
51
+ hipchat_client[room].send(deploy_user, message, options)
52
+ }
53
+ end
54
+
49
55
  def deployment_name
50
56
  if branch
51
57
  "#{application}/#{branch}"
@@ -91,7 +97,6 @@ Capistrano::Configuration.instance(:must_exist).load do
91
97
  end
92
98
  end
93
99
 
94
- before "hipchat:notify_deploy_started", "hipchat:set_client"
95
100
  before "deploy", "hipchat:trigger_notification"
96
101
  before "deploy:migrations", "hipchat:trigger_notification", "hipchat:configure_for_migrations"
97
102
  before "deploy:update_code", "hipchat:notify_deploy_started"
@@ -7,12 +7,13 @@ describe HipChat do
7
7
 
8
8
  # Helper for mocking room message post requests
9
9
  def mock_successful_send(from, message, options={})
10
- options = {:color => 'yellow', :notify => 0}.merge(options)
10
+ options = {:color => 'yellow', :notify => 0, :message_format => 'html'}.merge(options)
11
11
  mock(HipChat::Room).post("/message",
12
12
  :query => {:auth_token => "blah"},
13
13
  :body => {:room_id => "Hipchat",
14
14
  :from => "Dude",
15
15
  :message => "Hello world",
16
+ :message_format => options[:message_format],
16
17
  :color => options[:color],
17
18
  :notify => options[:notify]}) {
18
19
  OpenStruct.new(:code => 200)
@@ -38,6 +39,12 @@ describe HipChat do
38
39
  room.send("Dude", "Hello world", :color => 'red').should be_true
39
40
  end
40
41
 
42
+ it "successfully with text message_format" do
43
+ mock_successful_send 'Dude', 'Hello world', :message_format => 'text'
44
+
45
+ room.send("Dude", "Hello world", :message_format => 'text').should be_true
46
+ end
47
+
41
48
  it "but fails when the room doesn't exist" do
42
49
  mock(HipChat::Room).post(anything, anything) {
43
50
  OpenStruct.new(:code => 404)
metadata CHANGED
@@ -1,73 +1,86 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hipchat
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - HipChat/Atlassian
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-11-02 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ type: :runtime
15
23
  name: httparty
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ prerelease: false
22
34
  type: :runtime
35
+ name: httparty
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ requirement: *id002
44
+ - !ruby/object:Gem::Dependency
23
45
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
46
+ type: :development
31
47
  name: rspec
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
48
+ version_requirements: &id003 !ruby/object:Gem::Requirement
49
+ requirements:
35
50
  - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '2.0'
38
- type: :development
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 2
54
+ - 0
55
+ version: "2.0"
56
+ requirement: *id003
57
+ - !ruby/object:Gem::Dependency
39
58
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '2.0'
46
- - !ruby/object:Gem::Dependency
47
- name: rr
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.0'
54
59
  type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
60
+ name: rr
61
+ version_requirements: &id004 !ruby/object:Gem::Requirement
62
+ requirements:
59
63
  - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 1
67
+ - 0
68
+ version: "1.0"
69
+ requirement: *id004
62
70
  description: Ruby library to interact with HipChat
63
71
  email: support@hipchat.com
64
72
  executables: []
73
+
65
74
  extensions: []
66
- extra_rdoc_files:
75
+
76
+ extra_rdoc_files:
67
77
  - LICENSE
68
78
  - README.textile
69
- files:
79
+ files:
70
80
  - .document
81
+ - .travis.yml
82
+ - Gemfile
83
+ - Gemfile.lock
71
84
  - LICENSE
72
85
  - README.textile
73
86
  - Rakefile
@@ -81,28 +94,35 @@ files:
81
94
  - spec/hipchat_spec.rb
82
95
  - spec/spec.opts
83
96
  - spec/spec_helper.rb
97
+ has_rdoc: true
84
98
  homepage: https://github.com/hipchat/hipchat-rb
85
99
  licenses: []
100
+
86
101
  post_install_message:
87
102
  rdoc_options: []
88
- require_paths:
103
+
104
+ require_paths:
89
105
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
93
- - - ! '>='
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
119
+ version: "0"
102
120
  requirements: []
121
+
103
122
  rubyforge_project:
104
- rubygems_version: 1.8.24
123
+ rubygems_version: 1.3.6
105
124
  signing_key:
106
125
  specification_version: 3
107
126
  summary: Ruby library to interact with HipChat
108
127
  test_files: []
128
+