hipchat 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24cf2734642567d8b9776d38a0692c10da6c7950
4
+ data.tar.gz: 35631b2283ed2d4b6667079543bb1ad1e7fc35ab
5
+ SHA512:
6
+ metadata.gz: 68e9b8c4efd921c20a0a53d772dbc1dc3b836d426738d4c25b1f2502b34401abcae5971820ef6d131fdcc9ad79f865e919a31853791adfa5399e75c45f5274b2
7
+ data.tar.gz: 80d29347ebaf6a6d5d802eb66ea17df29f0bf9077d0a8ace7899e692f39693039500ac7be9bc6fc4ecaa5c150c0837a7371133992cfed69587724ff0ad87d278
@@ -0,0 +1,35 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ *.gem
21
+ *.rbc
22
+ .bundle
23
+ .config
24
+ .yardoc
25
+ Gemfile.lock
26
+ InstalledFiles
27
+ _yardoc
28
+ doc/
29
+ lib/bundler/man
30
+ spec/reports
31
+ test/tmp
32
+ test/version_tmp
33
+ tmp
34
+
35
+ ## PROJECT::SPECIFIC
data/Gemfile CHANGED
@@ -1,14 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "httparty"
4
-
5
- group :test do
6
- gem "rake"
7
- gem "rspec"
8
- gem "rr"
9
- end
10
-
11
- group :development do
12
- gem "jeweler"
13
- gem "builder"
14
- end
3
+ # Specify your gem's dependencies in hipchat.gemspec
4
+ gemspec
@@ -1,40 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hipchat (0.10.0)
5
+ httparty
6
+
1
7
  GEM
2
8
  remote: https://rubygems.org/
3
9
  specs:
4
- builder (3.2.0)
5
- diff-lcs (1.1.3)
6
- git (1.2.5)
7
- httparty (0.9.0)
10
+ addressable (2.3.4)
11
+ crack (0.4.0)
12
+ safe_yaml (~> 0.9.0)
13
+ diff-lcs (1.2.4)
14
+ httparty (0.11.0)
8
15
  multi_json (~> 1.0)
9
- multi_xml
10
- jeweler (1.8.4)
11
- bundler (~> 1.0)
12
- git (>= 1.2.5)
13
- rake
14
- rdoc
15
- json (1.7.7)
16
- multi_json (1.3.6)
17
- multi_xml (0.5.1)
18
- rake (0.9.2.2)
19
- rdoc (3.12)
20
- json (~> 1.4)
21
- rr (1.0.4)
22
- rspec (2.11.0)
23
- rspec-core (~> 2.11.0)
24
- rspec-expectations (~> 2.11.0)
25
- rspec-mocks (~> 2.11.0)
26
- rspec-core (2.11.1)
27
- rspec-expectations (2.11.3)
28
- diff-lcs (~> 1.1.3)
29
- rspec-mocks (2.11.3)
16
+ multi_xml (>= 0.5.2)
17
+ multi_json (1.7.3)
18
+ multi_xml (0.5.3)
19
+ rake (10.0.4)
20
+ rr (1.0.5)
21
+ rspec (2.13.0)
22
+ rspec-core (~> 2.13.0)
23
+ rspec-expectations (~> 2.13.0)
24
+ rspec-mocks (~> 2.13.0)
25
+ rspec-core (2.13.1)
26
+ rspec-expectations (2.13.0)
27
+ diff-lcs (>= 1.1.3, < 2.0)
28
+ rspec-mocks (2.13.1)
29
+ safe_yaml (0.9.3)
30
+ webmock (1.11.0)
31
+ addressable (>= 2.2.7)
32
+ crack (>= 0.3.2)
30
33
 
31
34
  PLATFORMS
32
35
  ruby
33
36
 
34
37
  DEPENDENCIES
35
- builder
36
- httparty
37
- jeweler
38
+ bundler (~> 1.3)
39
+ hipchat!
38
40
  rake
39
41
  rr
40
42
  rspec
43
+ webmock
@@ -26,6 +26,11 @@ client['my room'].topic('Free Ice Cream in the kitchen')
26
26
  # Change the from field for a topic update (default "API")
27
27
  client['my room'].topic('Weekely sales: $10,000', :from => 'Sales Team')
28
28
 
29
+ # Get history from a room
30
+ client['my room'].history()
31
+
32
+ # Get history for a date in time with a particular timezone (default is latest 75 messages, timezone default is 'UTC')
33
+ client['my room'].history(:date => '2010-11-19', :timezone => 'PST')
29
34
 
30
35
 
31
36
  h2. Capistrano
data/Rakefile CHANGED
@@ -1,29 +1,10 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "hipchat"
8
- gem.summary = %Q{Ruby library to interact with HipChat}
9
- gem.description = %Q{Ruby library to interact with HipChat}
10
- gem.email = "support@hipchat.com"
11
- gem.homepage = "https://github.com/hipchat/hipchat-rb"
12
- gem.authors = ["HipChat/Atlassian"]
13
- gem.add_dependency "httparty"
14
- gem.add_development_dependency "rspec", "~> 2.0"
15
- gem.add_development_dependency "rr", "~> 1.0"
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
1
+ require "bundler/gem_tasks"
21
2
 
22
3
  task :default => :spec
23
4
 
24
5
  require 'rdoc/task'
25
6
  Rake::RDocTask.new do |rdoc|
26
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
7
+ version = HipChat::VERSION
27
8
 
28
9
  rdoc.rdoc_dir = 'rdoc'
29
10
  rdoc.title = "hipchat #{version}"
@@ -1,70 +1,28 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hipchat/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "hipchat"
8
- s.version = "0.9.0"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hipchat"
8
+ spec.version = HipChat::VERSION
9
+ spec.authors = ["HipChat/Atlassian"]
10
+ spec.email = ["support@hipchat.com"]
11
+ spec.description = %q{Ruby library to interact with HipChat}
12
+ spec.summary = %q{Ruby library to interact with HipChat}
13
+ spec.homepage = "https://github.com/hipchat/hipchat-rb"
14
+ spec.license = "MIT"
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["HipChat/Atlassian"]
12
- s.date = "2013-05-18"
13
- s.description = "Ruby library to interact with HipChat"
14
- s.email = "support@hipchat.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.textile"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".travis.yml",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.textile",
26
- "Rakefile",
27
- "VERSION",
28
- "hipchat.gemspec",
29
- "lib/hipchat.rb",
30
- "lib/hipchat/capistrano.rb",
31
- "lib/hipchat/chef.rb",
32
- "lib/hipchat/rails3_tasks.rb",
33
- "lib/hipchat/railtie.rb",
34
- "spec/hipchat_spec.rb",
35
- "spec/spec.opts",
36
- "spec/spec_helper.rb"
37
- ]
38
- s.homepage = "https://github.com/hipchat/hipchat-rb"
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.24"
41
- s.summary = "Ruby library to interact with HipChat"
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
42
20
 
43
- if s.respond_to? :specification_version then
44
- s.specification_version = 3
21
+ spec.add_dependency "httparty"
45
22
 
46
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
48
- s.add_development_dependency(%q<jeweler>, [">= 0"])
49
- s.add_development_dependency(%q<builder>, [">= 0"])
50
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
51
- s.add_development_dependency(%q<rspec>, ["~> 2.0"])
52
- s.add_development_dependency(%q<rr>, ["~> 1.0"])
53
- else
54
- s.add_dependency(%q<httparty>, [">= 0"])
55
- s.add_dependency(%q<jeweler>, [">= 0"])
56
- s.add_dependency(%q<builder>, [">= 0"])
57
- s.add_dependency(%q<httparty>, [">= 0"])
58
- s.add_dependency(%q<rspec>, ["~> 2.0"])
59
- s.add_dependency(%q<rr>, ["~> 1.0"])
60
- end
61
- else
62
- s.add_dependency(%q<httparty>, [">= 0"])
63
- s.add_dependency(%q<jeweler>, [">= 0"])
64
- s.add_dependency(%q<builder>, [">= 0"])
65
- s.add_dependency(%q<httparty>, [">= 0"])
66
- s.add_dependency(%q<rspec>, ["~> 2.0"])
67
- s.add_dependency(%q<rr>, ["~> 1.0"])
68
- end
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rr"
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "webmock"
69
28
  end
70
-
@@ -2,6 +2,7 @@ require 'httparty'
2
2
  require 'ostruct'
3
3
 
4
4
  require 'hipchat/railtie' if defined?(Rails::Railtie)
5
+ require "hipchat/version"
5
6
 
6
7
  module HipChat
7
8
  class UnknownRoom < StandardError; end
@@ -129,5 +130,46 @@ module HipChat
129
130
  raise UnknownResponseCode, "Unexpected #{response.code} for room `#{room_id}'"
130
131
  end
131
132
  end
133
+
134
+ # Pull this room's history
135
+ #
136
+ # Usage
137
+ #
138
+ # # Default
139
+ #
140
+ #
141
+ # Options
142
+ #
143
+ # +date+:: Whether to return a specific day (YYYY-MM-DD format) or recent
144
+ # (default "recent")
145
+ # +timezone+:: Your timezone. Supported timezones are at: https://www.hipchat.com/docs/api/timezones
146
+ # (default "UTC")
147
+ # +format+:: Format to retrieve the history in. Valid options are JSON and XML
148
+ # (default "JSON")
149
+ def history(options = {})
150
+
151
+ options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge options
152
+
153
+ response = self.class.get('/history',
154
+ :query => {
155
+ :room_id => room_id,
156
+ :date => options[:date],
157
+ :timezone => options[:timezone],
158
+ :format => options[:format],
159
+ :auth_token => @token,
160
+ }
161
+ )
162
+
163
+ case response.code
164
+ when 200
165
+ response.body
166
+ when 404
167
+ raise UnknownRoom, "Unknown room: `#{room_id}'"
168
+ when 401
169
+ raise Unauthorized, "Access denied to room `#{room_id}'"
170
+ else
171
+ raise UnknownResponseCode, "Unexpected #{response.code} for room `#{room_id}'"
172
+ end
173
+ end
132
174
  end
133
175
  end
@@ -0,0 +1,3 @@
1
+ module HipChat
2
+ VERSION = "0.10.0"
3
+ end
@@ -0,0 +1,36 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ {
5
+ "messages": [
6
+ {
7
+ "date": "2010-11-19T15:48:19-0800",
8
+ "from": {
9
+ "name": "Garret Heaton",
10
+ "user_id": 10
11
+ },
12
+ "message": "Good morning! This is a regular message."
13
+ },
14
+ {
15
+ "date": "2010-11-19T15:49:44-0800",
16
+ "from": {
17
+ "name": "Garret Heaton",
18
+ "user_id": 10
19
+ },
20
+ "file": {
21
+ "name": "Screenshot.png",
22
+ "size": 141909,
23
+ "url": "http:\/\/uploads.hipchat.com\/xxx\/Screenshot.png"
24
+ },
25
+ "message": "This is a file upload"
26
+ },
27
+ {
28
+ "date": "2010-11-19T16:13:40-0800",
29
+ "from": {
30
+ "name": "Deploy Bot",
31
+ "user_id": "api"
32
+ },
33
+ "message": "This message is sent via the API so the user_id is 'api'."
34
+ }
35
+ ]
36
+ }
@@ -31,6 +31,54 @@ describe HipChat do
31
31
  }
32
32
  end
33
33
 
34
+ def mock_successful_history(options={})
35
+ options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
36
+ canned_response = File.new File.expand_path(File.dirname(__FILE__) + '/example/history.json')
37
+ stub_request(:get, "https://api.hipchat.com/v1/rooms/history").with(:query => {:auth_token => "blah",
38
+ :room_id => "Hipchat",
39
+ :date => options[:date],
40
+ :timezone => options[:timezone],
41
+ :format => options[:format]}).to_return(canned_response)
42
+ end
43
+
44
+ describe "#history" do
45
+ it "is successful without custom options" do
46
+ mock_successful_history()
47
+
48
+ room.history().should be_true
49
+ end
50
+
51
+ it "is successful with custom options" do
52
+ mock_successful_history(:timezone => 'America/Los_Angeles', :date => '2010-11-19')
53
+ room.history(:timezone => 'America/Los_Angeles', :date => '2010-11-19').should be_true
54
+ end
55
+
56
+ it "fails when the room doen't exist" do
57
+ mock(HipChat::Room).get(anything, anything) {
58
+ OpenStruct.new(:code => 404)
59
+ }
60
+
61
+ lambda { room.history }.should raise_error(HipChat::UnknownRoom)
62
+ end
63
+
64
+ it "fails when we're not allowed to do so" do
65
+ mock(HipChat::Room).get(anything, anything) {
66
+ OpenStruct.new(:code => 401)
67
+ }
68
+
69
+ lambda { room.history }.should raise_error(HipChat::Unauthorized)
70
+ end
71
+
72
+ it "fails if we get an unknown response code" do
73
+ mock(HipChat::Room).get(anything, anything) {
74
+ OpenStruct.new(:code => 403)
75
+ }
76
+
77
+ lambda { room.history }.
78
+ should raise_error(HipChat::UnknownResponseCode)
79
+ end
80
+ end
81
+
34
82
  describe "#topic" do
35
83
  it "is successful without custom options" do
36
84
  mock_successful_topic_change("Nice topic")
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'hipchat'
4
4
  require 'rspec'
5
5
  require 'rspec/autorun'
6
+ require 'webmock/rspec'
6
7
 
7
8
  RSpec.configure do |config|
8
9
  config.mock_with :rr
metadata CHANGED
@@ -1,162 +1,151 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
5
- prerelease:
4
+ version: 0.10.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - HipChat/Atlassian
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-18 00:00:00.000000000 Z
11
+ date: 2013-06-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: httparty
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: jeweler
28
+ name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: builder
42
+ name: rr
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: httparty
56
+ name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
61
+ version: '1.3'
62
+ type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: '0'
68
+ version: '1.3'
78
69
  - !ruby/object:Gem::Dependency
79
- name: rspec
70
+ name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
- version: '2.0'
75
+ version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
- version: '2.0'
82
+ version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
- name: rr
84
+ name: webmock
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
- version: '1.0'
89
+ version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
- version: '1.0'
96
+ version: '0'
110
97
  description: Ruby library to interact with HipChat
111
- email: support@hipchat.com
98
+ email:
99
+ - support@hipchat.com
112
100
  executables: []
113
101
  extensions: []
114
- extra_rdoc_files:
115
- - LICENSE
116
- - README.textile
102
+ extra_rdoc_files: []
117
103
  files:
118
104
  - .document
105
+ - .gitignore
119
106
  - .travis.yml
120
107
  - Gemfile
121
108
  - Gemfile.lock
122
109
  - LICENSE
123
110
  - README.textile
124
111
  - Rakefile
125
- - VERSION
126
112
  - hipchat.gemspec
127
113
  - lib/hipchat.rb
128
114
  - lib/hipchat/capistrano.rb
129
115
  - lib/hipchat/chef.rb
130
116
  - lib/hipchat/rails3_tasks.rb
131
117
  - lib/hipchat/railtie.rb
118
+ - lib/hipchat/version.rb
119
+ - spec/example/history.json
132
120
  - spec/hipchat_spec.rb
133
121
  - spec/spec.opts
134
122
  - spec/spec_helper.rb
135
123
  homepage: https://github.com/hipchat/hipchat-rb
136
- licenses: []
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
137
127
  post_install_message:
138
128
  rdoc_options: []
139
129
  require_paths:
140
130
  - lib
141
131
  required_ruby_version: !ruby/object:Gem::Requirement
142
- none: false
143
132
  requirements:
144
- - - ! '>='
133
+ - - '>='
145
134
  - !ruby/object:Gem::Version
146
135
  version: '0'
147
- segments:
148
- - 0
149
- hash: -3630291999816657472
150
136
  required_rubygems_version: !ruby/object:Gem::Requirement
151
- none: false
152
137
  requirements:
153
- - - ! '>='
138
+ - - '>='
154
139
  - !ruby/object:Gem::Version
155
140
  version: '0'
156
141
  requirements: []
157
142
  rubyforge_project:
158
- rubygems_version: 1.8.24
143
+ rubygems_version: 2.0.3
159
144
  signing_key:
160
- specification_version: 3
145
+ specification_version: 4
161
146
  summary: Ruby library to interact with HipChat
162
- test_files: []
147
+ test_files:
148
+ - spec/example/history.json
149
+ - spec/hipchat_spec.rb
150
+ - spec/spec.opts
151
+ - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.0