hipchat 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.textile +11 -0
- data/hipchat.gemspec +2 -2
- data/lib/hipchat/capistrano2.rb +9 -0
- data/lib/hipchat/client.rb +13 -2
- data/lib/hipchat/version.rb +1 -1
- data/spec/hipchat_api_v1_spec.rb +8 -0
- data/spec/hipchat_api_v2_spec.rb +9 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/shared_contexts_for_hipchat.rb +23 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87814d532992250965bb8fd683295acd9ed7e8c1
|
4
|
+
data.tar.gz: d0e551de4271ce51a6d60fdac6821b0b7c30f929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cb2ae5a7ddcc189db17a21b09a63739ebf4dbc523ab62be6908ab14120b442f5d7d5dce6fed6ce5f8c77bb0509a401fe49e5b0b2754638089588e136e36fcef
|
7
|
+
data.tar.gz: 6aed60e1f7cb4df9b021cc461e47b9f814ba06c51ae3d2c5fc8a10b528ea0690e2aa468bf569500dc5e9e83973df901113f46543c997248e9b0190c28ebb8c39
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/README.textile
CHANGED
@@ -11,6 +11,16 @@ h2. Requirements
|
|
11
11
|
* Ruby 1.9.3 or higher
|
12
12
|
* HipChat Account, sign up "here!":https://hipchat.com/
|
13
13
|
|
14
|
+
h2. Installation
|
15
|
+
|
16
|
+
h3. Gemfile
|
17
|
+
|
18
|
+
bc. gem 'hipchat'
|
19
|
+
|
20
|
+
h3. Install
|
21
|
+
|
22
|
+
bc. gem install hipchat
|
23
|
+
|
14
24
|
h1. Usage
|
15
25
|
|
16
26
|
h2. "API v1":https://www.hipchat.com/docs/api
|
@@ -159,6 +169,7 @@ bc.. set :hipchat_commit_log, true
|
|
159
169
|
# Optional
|
160
170
|
set :hipchat_commit_log_format, ":time :user\n:message\n"
|
161
171
|
set :hipchat_commit_log_time_format, "%Y/%m/%d %H:%M:%S"
|
172
|
+
set :hipchat_commit_log_message_format, "^PROJECT-\d+" # extracts ticket number from message
|
162
173
|
|
163
174
|
h2. Rails 3 Rake Task
|
164
175
|
|
data/hipchat.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
23
|
spec.add_dependency "httparty"
|
24
|
-
|
25
|
-
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.0"
|
26
26
|
spec.add_development_dependency "rr"
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
28
|
spec.add_development_dependency "rake"
|
data/lib/hipchat/capistrano2.rb
CHANGED
@@ -155,8 +155,17 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
155
155
|
|
156
156
|
format = fetch(:hipchat_commit_log_format, ":time :user\n:message\n")
|
157
157
|
time_format = fetch(:hipchat_commit_log_time_format, "%Y/%m/%d %H:%M:%S")
|
158
|
+
message_format = fetch(:hipchat_commit_log_message_format, nil)
|
158
159
|
|
159
160
|
log_hashes.map do |log_hash|
|
161
|
+
if message_format
|
162
|
+
matches = log_hash[:message].match(/#{message_format}/)
|
163
|
+
log_hash[:message] = if matches
|
164
|
+
matches[0]
|
165
|
+
else
|
166
|
+
''
|
167
|
+
end
|
168
|
+
end
|
160
169
|
log_hash[:time] &&= log_hash[:time].localtime.strftime(time_format)
|
161
170
|
log_hash.inject(format) do |l, (k, v)|
|
162
171
|
l.gsub(/:#{k}/, v.to_s)
|
data/lib/hipchat/client.rb
CHANGED
@@ -28,7 +28,7 @@ module HipChat
|
|
28
28
|
|
29
29
|
def create_room(name, options={})
|
30
30
|
if @api.version == 'v1' && options[:owner_user_id].nil?
|
31
|
-
raise RoomMissingOwnerUserId, "V1 API
|
31
|
+
raise RoomMissingOwnerUserId, "V1 API Requires owner_user_id"
|
32
32
|
end
|
33
33
|
|
34
34
|
if name.length > 50
|
@@ -67,7 +67,18 @@ module HipChat
|
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
|
+
|
71
|
+
def no_proxy?
|
72
|
+
host = URI.parse(@options[:server_url]).host
|
73
|
+
ENV.fetch('no_proxy','').split(',').any? do |pattern|
|
74
|
+
# convert patterns like `*.example.com` into `.*\.example\.com`
|
75
|
+
host =~ Regexp.new(pattern.gsub(/\./,'\\.').gsub(/\*/,'.*'))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
70
79
|
def setup_proxy(proxy_url)
|
80
|
+
return if no_proxy?
|
81
|
+
|
71
82
|
proxy_url = URI.parse(proxy_url)
|
72
83
|
|
73
84
|
self.class.http_proxy(proxy_url.host, proxy_url.port,
|
@@ -86,7 +97,7 @@ module HipChat
|
|
86
97
|
case response.code
|
87
98
|
when 200
|
88
99
|
response[@api.rooms_config[:data_key]].map do |r|
|
89
|
-
Room.new(@token, r.merge(:api_version => @api_version, :room_id => r['id']))
|
100
|
+
Room.new(@token, r.merge(:api_version => @api_version, :room_id => r['id'], :server_url => @options[:server_url]))
|
90
101
|
end
|
91
102
|
else
|
92
103
|
raise UnknownResponseCode, "Unexpected #{response.code} for room"
|
data/lib/hipchat/version.rb
CHANGED
data/spec/hipchat_api_v1_spec.rb
CHANGED
@@ -19,6 +19,14 @@ describe "HipChat (API V1)" do
|
|
19
19
|
room.history(:timezone => 'America/Los_Angeles', :date => '2010-11-19').should be_true
|
20
20
|
end
|
21
21
|
|
22
|
+
it "is successful from fetched room" do
|
23
|
+
mock_successful_rooms
|
24
|
+
mock_successful_history
|
25
|
+
|
26
|
+
subject.rooms.should be_true
|
27
|
+
subject.rooms.first.history.should be_true
|
28
|
+
end
|
29
|
+
|
22
30
|
it "fails when the room doen't exist" do
|
23
31
|
mock(HipChat::Room).get(anything, anything) {
|
24
32
|
OpenStruct.new(:code => 404)
|
data/spec/hipchat_api_v2_spec.rb
CHANGED
@@ -20,6 +20,14 @@ describe "HipChat (API V2)" do
|
|
20
20
|
room.history(:timezone => 'America/Los_Angeles', :date => '2010-11-19').should be_true
|
21
21
|
end
|
22
22
|
|
23
|
+
it "is successful from fetched room" do
|
24
|
+
mock_successful_rooms
|
25
|
+
mock_successful_history
|
26
|
+
|
27
|
+
subject.rooms.should be_true
|
28
|
+
subject.rooms.first.history.should be_true
|
29
|
+
end
|
30
|
+
|
23
31
|
it "fails when the room doen't exist" do
|
24
32
|
mock(HipChat::Room).get(anything, anything) {
|
25
33
|
OpenStruct.new(:code => 404)
|
@@ -214,4 +222,4 @@ describe "HipChat (API V2)" do
|
|
214
222
|
lambda { user.send "" }.should raise_error(HipChat::Unauthorized)
|
215
223
|
end
|
216
224
|
end
|
217
|
-
end
|
225
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,10 +7,10 @@ require 'json'
|
|
7
7
|
require 'webmock/rspec'
|
8
8
|
require 'coveralls'
|
9
9
|
|
10
|
-
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
11
|
-
|
12
10
|
Coveralls.wear!
|
13
11
|
|
12
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
13
|
+
|
14
14
|
RSpec.configure do |config|
|
15
15
|
config.mock_with :rr
|
16
16
|
end
|
@@ -29,6 +29,17 @@ shared_context "HipChatV1" do
|
|
29
29
|
'Content-Type' => 'application/x-www-form-urlencoded'}).to_return(:status => 200, :body => "", :headers => {})
|
30
30
|
end
|
31
31
|
|
32
|
+
def mock_successful_rooms
|
33
|
+
stub_request(:get, "https://api.hipchat.com/v1/rooms/list").with(
|
34
|
+
:query => {:auth_token => "blah"},
|
35
|
+
:body => "",
|
36
|
+
:headers => {'Accept' => 'application/json',
|
37
|
+
'Content-Type' => 'application/x-www-form-urlencoded'}).to_return(
|
38
|
+
:status => 200,
|
39
|
+
:body => '{"rooms":[{"id": "Hipchat", "links": {"self": "https://api.hipchat.com/v2/room/12345"}}]}',
|
40
|
+
:headers => {})
|
41
|
+
end
|
42
|
+
|
32
43
|
def mock_successful_history(options={})
|
33
44
|
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
34
45
|
canned_response = File.new(HISTORY_JSON_PATH)
|
@@ -80,6 +91,17 @@ shared_context "HipChatV2" do
|
|
80
91
|
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
81
92
|
end
|
82
93
|
|
94
|
+
def mock_successful_rooms
|
95
|
+
stub_request(:get, "https://api.hipchat.com/v2/room").with(
|
96
|
+
:query => {:auth_token => "blah"},
|
97
|
+
:body => "",
|
98
|
+
:headers => {'Accept' => 'application/json',
|
99
|
+
'Content-Type' => 'application/json'}).to_return(
|
100
|
+
:status => 200,
|
101
|
+
:body => '{"items":[{"id": "Hipchat", "links": {"self": "https://api.hipchat.com/v2/room/12345"}}]}',
|
102
|
+
:headers => {})
|
103
|
+
end
|
104
|
+
|
83
105
|
def mock_successful_history(options={})
|
84
106
|
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
85
107
|
canned_response = File.new(HISTORY_JSON_PATH)
|
@@ -130,4 +152,4 @@ shared_context "HipChatV2" do
|
|
130
152
|
:headers => {'Accept' => 'application/json',
|
131
153
|
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
132
154
|
end
|
133
|
-
end
|
155
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HipChat/Atlassian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rr
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".coveralls.yml"
|
132
133
|
- ".document"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".ruby-gemset"
|