timetrap-hipchat 1.0.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: 50c306c84dc2f34f59fbf1487043891953a155da
4
+ data.tar.gz: b9ceeb90873208adaed095d686062bd6296596ef
5
+ SHA512:
6
+ metadata.gz: 231df442192c607fea361002314bc72a5b76b3b50f24c73293a5eff5ad599727c88e81811000a6b49b17afeea32894e5d2afff8b19038a66ef5c418fbacbb387
7
+ data.tar.gz: b206189ef6af9bdc42765b1514f05fcd05ec25f2573064123255e0246fe39b88bbfb3c3d2110a66612c1d9b2fe16b7afb00fb6adfb8faa5b732617fd64610d71
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'timetrap'
4
+ gem 'hipchat'
5
+ gem 'thor'
6
+ gem 'jeweler'
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ chronic (0.10.2)
7
+ descendants_tracker (0.0.4)
8
+ thread_safe (~> 0.3, >= 0.3.1)
9
+ faraday (0.9.0)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.2.6)
12
+ github_api (0.11.3)
13
+ addressable (~> 2.3)
14
+ descendants_tracker (~> 0.0.1)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 1.2)
17
+ multi_json (>= 1.7.5, < 2.0)
18
+ nokogiri (~> 1.6.0)
19
+ oauth2
20
+ hashie (2.0.5)
21
+ highline (1.6.18)
22
+ hipchat (1.1.0)
23
+ httparty
24
+ httparty (0.13.1)
25
+ json (~> 1.8)
26
+ multi_xml (>= 0.5.2)
27
+ jeweler (2.0.1)
28
+ builder
29
+ bundler (>= 1.0)
30
+ git (>= 1.2.5)
31
+ github_api
32
+ highline (>= 1.6.15)
33
+ nokogiri (>= 1.5.10)
34
+ rake
35
+ rdoc
36
+ json (1.8.1)
37
+ jwt (0.1.11)
38
+ multi_json (>= 1.5)
39
+ mini_portile (0.5.2)
40
+ multi_json (1.9.2)
41
+ multi_xml (0.5.5)
42
+ multipart-post (2.0.0)
43
+ nokogiri (1.6.1)
44
+ mini_portile (~> 0.5.0)
45
+ oauth2 (0.9.3)
46
+ faraday (>= 0.8, < 0.10)
47
+ jwt (~> 0.1.8)
48
+ multi_json (~> 1.3)
49
+ multi_xml (~> 0.5)
50
+ rack (~> 1.2)
51
+ rack (1.5.2)
52
+ rake (10.3.1)
53
+ rdoc (4.1.1)
54
+ json (~> 1.4)
55
+ sequel (4.0.0)
56
+ sqlite3 (1.3.9)
57
+ thor (0.19.1)
58
+ thread_safe (0.3.2)
59
+ timetrap (1.8.14)
60
+ chronic (~> 0.10.2)
61
+ sequel (~> 4.0.0)
62
+ sqlite3 (~> 1.3.3)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ hipchat
69
+ jeweler
70
+ thor
71
+ timetrap
@@ -0,0 +1,3 @@
1
+ === 1.0.0 / 2014-04-22
2
+
3
+ * Initial release
@@ -0,0 +1,74 @@
1
+ # timetrap-hipchat
2
+
3
+ This Ruby gem extends the popular
4
+ [Timetrap](https://github.com/samg/timetrap) time tracker to notify a
5
+ [Hipchat](https://hipchat.com) room any time you use the `in`, `out`, and
6
+ `resume` commands.
7
+
8
+ ![Example](https://raw.githubusercontent.com/logankoester/timetrap-hipchat/master/demo.png)
9
+
10
+ ## Requirements
11
+
12
+ * Ruby 1.9+
13
+ * My [fork of Timetrap](https://github.com/logankoester/timetrap/tree/hooks)
14
+ (until **hook support** is accepted and released upstream)
15
+ * A Hipchat API token
16
+
17
+ ## Installation
18
+
19
+ Once you've installed and configured my forked `timetrap` gem, install
20
+ timetrap-hipchat.
21
+
22
+ ```bash
23
+ $ gem install timetrap-hipchat
24
+ ```
25
+
26
+ Then use the `timetrap-hipchat` command to add the relevant hooks to your
27
+ sheets.
28
+
29
+ ```bash
30
+ $ timetrap-hipchat <sheet>
31
+ ```
32
+
33
+ Example...
34
+
35
+ ```bash
36
+ $ timetrap-hipchat install example
37
+ Configuring hipchat hooks for timetrap sheet example
38
+ HipChat API Token: YOUR_TOKEN
39
+ HipChat Room Name: YOUR_ROOM
40
+ Your name: Your Name
41
+ create /home/ldk/.timetrap/hooks/example/hipchat.yml
42
+ create /home/ldk/.timetrap/hooks/example/in.rb
43
+ create /home/ldk/.timetrap/hooks/example/out.rb
44
+ create /home/ldk/.timetrap/hooks/example/resume.rb
45
+ All done!
46
+ ```
47
+
48
+ **You're done!** Any time you run `timetrap [in|out|resume]`, the channel
49
+ you configured will be notified.
50
+
51
+ ## License
52
+
53
+ (The MIT License)
54
+
55
+ Copyright (c) 2014 Logan Koester
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining
58
+ a copy of this software and associated documentation files (the
59
+ 'Software'), to deal in the Software without restriction, including
60
+ without limitation the rights to use, copy, modify, merge, publish,
61
+ distribute, sublicense, and/or sell copies of the Software, and to
62
+ permit persons to whom the Software is furnished to do so, subject to
63
+ the following conditions:
64
+
65
+ The above copyright notice and this permission notice shall be
66
+ included in all copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ begin
7
+ Bundler.setup(:default, :xzibit, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+
14
+ require 'rake'
15
+ require 'jeweler'
16
+
17
+ Jeweler::Tasks.new do |gem|
18
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
19
+ gem.name = 'timetrap-hipchat'
20
+ gem.version = '1.0.0'
21
+ gem.summary = 'Timetrap hooks to notify a Hipchat room'
22
+ gem.description = 'Extends the Timetrap timetracker by providing command hooks to notify a Hipchat room when you clock in/out/resume'
23
+ gem.homepage = 'https://github.com/logankoester/timetrap-hipchat'
24
+ gem.authors = ['Logan Koester']
25
+ gem.email = ['logan@logankoester.com']
26
+ gem.license = 'MIT'
27
+
28
+ gem.files.include 'History.txt'
29
+ gem.files.include 'README.md'
30
+ gem.files.include 'Rakefile'
31
+ gem.files.include 'bin/timetrap-hipchat'
32
+ gem.files.include 'lib/timetrap/hipchat/templates/hipchat.yml.tt'
33
+ gem.files.include 'lib/timetrap/hipchat/templates/in.rb'
34
+ gem.files.include 'lib/timetrap/hipchat/templates/out.rb'
35
+ gem.files.include 'lib/timetrap/hipchat/templates/resume.rb'
36
+ gem.files.include 'lib/timetrap/hipchat.rb'
37
+
38
+ # dependencies defined in Gemfile
39
+
40
+ gem.executables = ['timetrap-hipchat']
41
+ end
42
+
43
+ Jeweler::RubygemsDotOrgTasks.new
44
+
45
+ # vim: syntax=ruby
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'timetrap'
5
+ require 'hipchat'
6
+ require 'thor'
7
+
8
+ module Timetrap
9
+ module Hipchat
10
+ class CLI < Thor
11
+ include Thor::Actions
12
+
13
+ source_root File.join(File.dirname(__FILE__), '..', 'lib', 'timetrap', 'hipchat', 'templates')
14
+
15
+ desc 'install <sheet>', 'Install & configure for the specified sheet'
16
+ def install(sheet)
17
+ say "Configuring hipchat hooks for timetrap sheet #{sheet}", :green
18
+ @@destination_root = hooks_path(sheet)
19
+
20
+ @hipchat_token = ask 'HipChat API Token:'
21
+ @hipchat_room = ask 'HipChat Room Name:'
22
+ @hipchat_display_name = ask 'Your name:'
23
+
24
+ template 'hipchat.yml.tt', File.join(@@destination_root, 'hipchat.yml')
25
+ copy_file 'in.rb', File.join(@@destination_root, 'in.rb')
26
+ copy_file 'out.rb', File.join(@@destination_root, 'out.rb')
27
+ copy_file 'resume.rb', File.join(@@destination_root, 'resume.rb')
28
+
29
+ say 'All done!', :green
30
+ end
31
+
32
+ private
33
+ def hooks_path(sheet)
34
+ File.join Timetrap::Config['hooks_path'], sheet
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+ Timetrap::Hipchat::CLI.start
Binary file
@@ -0,0 +1,55 @@
1
+ require 'hipchat'
2
+
3
+ module Timetrap
4
+ class Hipchat
5
+ include Timetrap::Helpers
6
+
7
+ def initialize(api_token, room, user)
8
+ @client = HipChat::Client.new api_token, api_version: 'v2'
9
+ @room = room
10
+ @user = user
11
+ end
12
+
13
+ def in
14
+ entry = Timetrap::Timer.active_entry
15
+ image = shield 'started', 'green'
16
+
17
+ send 'green', <<-MSG
18
+ <img src="#{image}" />
19
+ <strong>#{entry.note}</strong>
20
+ MSG
21
+ end
22
+
23
+ def out
24
+ entry = Timetrap::Timer.last_checkout
25
+ duration = format_seconds entry.duration
26
+ image = shield 'stopped', 'red'
27
+
28
+ send 'red', <<-MSG
29
+ <img src="#{image}" />
30
+ <strong>#{entry.note}</strong> after <em>#{duration}</em>
31
+ MSG
32
+ end
33
+
34
+ def resume
35
+ entry = Timetrap::Timer.active_entry
36
+ image = shield 'resumed', 'yellow'
37
+
38
+ send 'yellow', <<-MSG
39
+ <img src="#{image}" />
40
+ <strong>#{entry.note}</strong>
41
+ MSG
42
+ end
43
+
44
+ private
45
+
46
+ def shield(subject = @user, status, color)
47
+ "http://img.shields.io/badge/#{subject}-#{status}-#{color}.svg?style=flat"
48
+ end
49
+
50
+ def send(color, msg)
51
+ @client[@room].send 'Timetrap', msg, color: color
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ ---
2
+ hipchat:
3
+ token: '<%= @hipchat_token %>'
4
+ room: '<%= @hipchat_room %>'
5
+ display_name: '<%= @hipchat_display_name %>'
@@ -0,0 +1,7 @@
1
+ require 'timetrap/hipchat'
2
+ require 'yaml'
3
+
4
+ @hipchat_config = YAML.load_file File.join(File.dirname(__FILE__), 'hipchat.yml')
5
+ Timetrap::Hipchat.new(@hipchat_config['hipchat']['token'],
6
+ @hipchat_config['hipchat']['room'],
7
+ @hipchat_config['hipchat']['display_name']).in
@@ -0,0 +1,7 @@
1
+ require 'timetrap/hipchat'
2
+ require 'yaml'
3
+
4
+ @hipchat_config = YAML.load_file File.join(File.dirname(__FILE__), 'hipchat.yml')
5
+ Timetrap::Hipchat.new(@hipchat_config['hipchat']['token'],
6
+ @hipchat_config['hipchat']['room'],
7
+ @hipchat_config['hipchat']['display_name']).out
@@ -0,0 +1,7 @@
1
+ require 'timetrap/hipchat'
2
+ require 'yaml'
3
+
4
+ @hipchat_config = YAML.load_file File.join(File.dirname(__FILE__), 'hipchat.yml')
5
+ Timetrap::Hipchat.new(@hipchat_config['hipchat']['token'],
6
+ @hipchat_config['hipchat']['room'],
7
+ @hipchat_config['hipchat']['display_name']).resume
@@ -0,0 +1,61 @@
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 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "timetrap-hipchat"
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Logan Koester"]
12
+ s.date = "2014-04-22"
13
+ s.description = "Extends the Timetrap timetracker by providing command hooks to notify a Hipchat room when you clock in/out/resume"
14
+ s.email = ["logan@logankoester.com"]
15
+ s.executables = ["timetrap-hipchat"]
16
+ s.extra_rdoc_files = [
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "History.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "bin/timetrap-hipchat",
26
+ "demo.png",
27
+ "lib/timetrap/hipchat.rb",
28
+ "lib/timetrap/hipchat/templates/hipchat.yml.tt",
29
+ "lib/timetrap/hipchat/templates/in.rb",
30
+ "lib/timetrap/hipchat/templates/out.rb",
31
+ "lib/timetrap/hipchat/templates/resume.rb",
32
+ "timetrap-hipchat.gemspec"
33
+ ]
34
+ s.homepage = "https://github.com/logankoester/timetrap-hipchat"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "2.0.14"
38
+ s.summary = "Timetrap hooks to notify a Hipchat room"
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 4
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<timetrap>, [">= 0"])
45
+ s.add_runtime_dependency(%q<hipchat>, [">= 0"])
46
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
47
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<timetrap>, [">= 0"])
50
+ s.add_dependency(%q<hipchat>, [">= 0"])
51
+ s.add_dependency(%q<thor>, [">= 0"])
52
+ s.add_dependency(%q<jeweler>, [">= 0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<timetrap>, [">= 0"])
56
+ s.add_dependency(%q<hipchat>, [">= 0"])
57
+ s.add_dependency(%q<thor>, [">= 0"])
58
+ s.add_dependency(%q<jeweler>, [">= 0"])
59
+ end
60
+ end
61
+
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timetrap-hipchat
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Logan Koester
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: timetrap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hipchat
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Extends the Timetrap timetracker by providing command hooks to notify
70
+ a Hipchat room when you clock in/out/resume
71
+ email:
72
+ - logan@logankoester.com
73
+ executables:
74
+ - timetrap-hipchat
75
+ extensions: []
76
+ extra_rdoc_files:
77
+ - README.md
78
+ files:
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - History.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/timetrap-hipchat
85
+ - demo.png
86
+ - lib/timetrap/hipchat.rb
87
+ - lib/timetrap/hipchat/templates/hipchat.yml.tt
88
+ - lib/timetrap/hipchat/templates/in.rb
89
+ - lib/timetrap/hipchat/templates/out.rb
90
+ - lib/timetrap/hipchat/templates/resume.rb
91
+ - timetrap-hipchat.gemspec
92
+ homepage: https://github.com/logankoester/timetrap-hipchat
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.0.14
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Timetrap hooks to notify a Hipchat room
116
+ test_files: []