travis-stalker 0.0.1

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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stalking-travis.gemspec
4
+ gemspec
@@ -0,0 +1,44 @@
1
+ # Travis::Stalker
2
+
3
+ ![](https://github.com/dylanegan/travis-stalker/raw/master/travis-stalker.jpg)
4
+
5
+ > Maybe I should just stick to stalking. Maybe that's my system.
6
+
7
+ Completely stolen from a [gist](https://gist.github.com/3186275) by @sosedoff.
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ $ gem install travis-stalker
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```
18
+ $ travis-stalker --help
19
+ ````
20
+
21
+ ## License
22
+
23
+ Copyright (c) 2012 Dylan Egan
24
+
25
+ MIT License
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining
28
+ a copy of this software and associated documentation files (the
29
+ "Software"), to deal in the Software without restriction, including
30
+ without limitation the rights to use, copy, modify, merge, publish,
31
+ distribute, sublicense, and/or sell copies of the Software, and to
32
+ permit persons to whom the Software is furnished to do so, subject to
33
+ the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be
36
+ included in all copies or substantial portions of the Software.
37
+
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
42
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
43
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
44
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "rubygems"
6
+ require "bundler/setup"
7
+
8
+ require "travis/stalker/cli"
9
+
10
+ Travis::Stalker::CLI.run
@@ -0,0 +1,45 @@
1
+ require "travis/stalker/charlie"
2
+ require "travis/stalker/version"
3
+
4
+ module Travis
5
+ module Stalker
6
+ module Logger
7
+ def self.log(data, &block)
8
+ STDOUT.puts data
9
+ yield if block_given?
10
+ end
11
+ end
12
+
13
+ # Public: Allows the user to specify a logger for the log messages that Travis::Stalker
14
+ # produces.
15
+ #
16
+ # logger = The object you want logs to be sent too
17
+ #
18
+ # Examples
19
+ #
20
+ # Travis::Stalker.instrument_with(STDOUT.method(:puts))
21
+ # # => #<Method: IO#puts>
22
+ #
23
+ # Returns the logger object
24
+ def self.instrument_with(logger)
25
+ @logger = logger
26
+ end
27
+
28
+ # Internal: Top level log method for use by Travis::Stalker
29
+ #
30
+ # data = Logging data (typically a hash)
31
+ # blk = block to execute
32
+ #
33
+ # Returns the response from calling the logger with the arguments
34
+ def self.log(data, &blk)
35
+ logger.call({ 'stalking-travis' => true }.merge(data), &blk)
36
+ end
37
+
38
+ # Public: The logging location
39
+ #
40
+ # Returns an Object
41
+ def self.logger
42
+ @logger || Travis::Stalker::Logger.method(:log)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,52 @@
1
+ gem "pusher-client-merman"
2
+
3
+ require "pusher-client"
4
+ PusherClient.logger.level = Logger::INFO
5
+ require "terminal-notifier"
6
+
7
+ module Travis
8
+ module Stalker
9
+ class Charlie
10
+ attr_accessor :projects
11
+
12
+ # Initialize a new connection to travis feed
13
+ #
14
+ # publisher_token - pusher token id
15
+ # projects - Array of projects to stalk
16
+ #
17
+ def initialize(pusher_token, projects=[])
18
+ @socket = PusherClient::Socket.new(pusher_token)
19
+ @projects = projects
20
+ end
21
+
22
+ def start
23
+ @socket.subscribe('common')
24
+ @socket['common'].bind('build:finished') do |payload|
25
+ notify(payload_to_notification(JSON.parse(payload)))
26
+ end
27
+ @socket.connect
28
+ end
29
+
30
+ private
31
+
32
+ def payload_to_notification(payload)
33
+ id = payload['build']['id']
34
+ number = payload['repository']['last_build_number']
35
+ result = payload['build']['result'] == 0 ? 'PASSED' : 'FAILED'
36
+ title = payload['repository']['slug']
37
+ message = "Build ##{number} #{result}"
38
+ url = "http://travis-ci.org/#!/#{title}/builds/#{id}"
39
+ { title: title, message: message, url: url }
40
+ end
41
+
42
+ def notify(notification)
43
+ if projects.empty? || projects.include?(notification[:title])
44
+ Travis::Stalker.log({ notifying: true }.merge(notification))
45
+ TerminalNotifier.notify(notification.delete(:message), notification)
46
+ else
47
+ Travis::Stalker.log({ notifying: false }.merge(notification))
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,40 @@
1
+ require "clamp"
2
+ require "scrolls"
3
+ require "travis/stalker"
4
+
5
+ module Travis
6
+ module Stalker
7
+ module CLI
8
+ class Logger
9
+ def self.log(data, &block)
10
+ Scrolls.log(data, &block)
11
+ end
12
+ end
13
+
14
+ def self.run(*a)
15
+ MainCommand.run(*a)
16
+ end
17
+
18
+ class AbstractCommand < Clamp::Command
19
+ option ["--pusher-token"], "PUSHER_TOKEN", "pusher token id", :default => "23ed642e81512118260e"
20
+ option ["--projects"], "PROJECTS", "comma separated list of projects to stalk", :default => [] do |projects|
21
+ projects.split(',')
22
+ end
23
+
24
+ option "--version", :flag, "show version" do
25
+ puts "stalking-travis #{Travis::Stalker::VERSION}"
26
+ exit 0
27
+ end
28
+ end
29
+
30
+ class MainCommand < AbstractCommand
31
+ def execute
32
+ stalker = Travis::Stalker::Charlie.new(pusher_token, projects)
33
+ stalker.start
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ Travis::Stalker.instrument_with(Travis::Stalker::CLI::Logger.method(:log))
@@ -0,0 +1,5 @@
1
+ module Travis
2
+ module Stalker
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/travis/stalker/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Dan Sosedoff", "Dylan Egan"]
6
+ gem.email = ["dan.sosedoff@gmail.com", "dylanegan@gmail.com"]
7
+ gem.description = %q{Stalk Travis CI builds.}
8
+ gem.summary = %q{Stalk Travis.}
9
+ gem.homepage = "https://github.com/dylanegan/travis-stalker"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "travis-stalker"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Travis::Stalker::VERSION
17
+
18
+ gem.add_dependency "clamp", "~> 0.3.0"
19
+ gem.add_dependency "pusher-client-merman", "~> 0.2"
20
+ gem.add_dependency "rake", "~> 0.9.0"
21
+ gem.add_dependency "scrolls", "~> 0.2.1"
22
+ gem.add_dependency "terminal-notifier", "~> 1.3"
23
+ end
Binary file
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: travis-stalker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Sosedoff
9
+ - Dylan Egan
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-08-02 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: clamp
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 0.3.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: pusher-client-merman
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '0.2'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '0.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 0.9.0
63
+ - !ruby/object:Gem::Dependency
64
+ name: scrolls
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 0.2.1
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.2.1
79
+ - !ruby/object:Gem::Dependency
80
+ name: terminal-notifier
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: '1.3'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '1.3'
95
+ description: Stalk Travis CI builds.
96
+ email:
97
+ - dan.sosedoff@gmail.com
98
+ - dylanegan@gmail.com
99
+ executables:
100
+ - travis-stalker
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - bin/travis-stalker
109
+ - lib/travis/stalker.rb
110
+ - lib/travis/stalker/charlie.rb
111
+ - lib/travis/stalker/cli.rb
112
+ - lib/travis/stalker/version.rb
113
+ - travis-stalker.gemspec
114
+ - travis-stalker.png
115
+ homepage: https://github.com/dylanegan/travis-stalker
116
+ licenses: []
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.23
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Stalk Travis.
139
+ test_files: []