travis-stalker 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Travis::Stalker
2
2
 
3
- ![](https://github.com/dylanegan/travis-stalker/raw/master/travis-stalker.jpg)
3
+ ![](https://github.com/dylanegan/travis-stalker/raw/master/travis-stalker.png)
4
4
 
5
5
  > Maybe I should just stick to stalking. Maybe that's my system.
6
6
 
7
- Completely stolen from a [gist](https://gist.github.com/3186275) by @sosedoff.
7
+ Completely stolen from a [gist](https://gist.github.com/3186275) by @[sosedoff](https://github.com/sosedoff).
8
8
 
9
9
  ## Installation
10
10
 
@@ -20,7 +20,7 @@ $ travis-stalker --help
20
20
 
21
21
  ## License
22
22
 
23
- Copyright (c) 2012 Dylan Egan
23
+ Copyright (c) 2012 Dan Sosedoff, Dylan Egan
24
24
 
25
25
  MIT License
26
26
 
@@ -13,10 +13,18 @@ module Travis
13
13
  #
14
14
  # publisher_token - pusher token id
15
15
  # projects - Array of projects to stalk
16
+ # regex - if true then accept partial matches
16
17
  #
17
- def initialize(pusher_token, projects=[])
18
- @socket = PusherClient::Socket.new(pusher_token)
18
+ def initialize(pusher_token, projects=[], regex=false)
19
19
  @projects = projects
20
+ @regex = regex
21
+ @socket = PusherClient::Socket.new(pusher_token)
22
+
23
+ Travis::Stalker.log(regex: regex, projects: projects)
24
+ end
25
+
26
+ def regex?
27
+ @regex
20
28
  end
21
29
 
22
30
  def start
@@ -39,10 +47,20 @@ module Travis
39
47
  { title: title, message: message, url: url }
40
48
  end
41
49
 
50
+ def has_project?(project)
51
+ return true if projects.empty?
52
+
53
+ if regex?
54
+ projects.find { |p| project[/#{p}/] }
55
+ else
56
+ projects.include?(project)
57
+ end
58
+ end
59
+
42
60
  def notify(notification)
43
- if projects.empty? || projects.include?(notification[:title])
61
+ if has_project?(notification[:title])
44
62
  Travis::Stalker.log({ notifying: true }.merge(notification))
45
- TerminalNotifier.notify(notification.delete(:message), notification)
63
+ TerminalNotifier.notify(notification[:message], { title: notification[:title], open: notification[:url] })
46
64
  else
47
65
  Travis::Stalker.log({ notifying: false }.merge(notification))
48
66
  end
@@ -20,6 +20,7 @@ module Travis
20
20
  option ["--projects"], "PROJECTS", "comma separated list of projects to stalk", :default => [] do |projects|
21
21
  projects.split(',')
22
22
  end
23
+ option "--regex", :flag, :default => false
23
24
 
24
25
  option "--version", :flag, "show version" do
25
26
  puts "stalking-travis #{Travis::Stalker::VERSION}"
@@ -29,7 +30,7 @@ module Travis
29
30
 
30
31
  class MainCommand < AbstractCommand
31
32
  def execute
32
- stalker = Travis::Stalker::Charlie.new(pusher_token, projects)
33
+ stalker = Travis::Stalker::Charlie.new(pusher_token, projects, regex?)
33
34
  stalker.start
34
35
  end
35
36
  end
@@ -1,5 +1,5 @@
1
1
  module Travis
2
2
  module Stalker
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-stalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: