kilt 0.3.2 → 0.4.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
data/lib/kilt.rb CHANGED
@@ -15,7 +15,7 @@ class Kilt
15
15
  activities = fetch_activities
16
16
  activities.reverse.each do |activity|
17
17
  if activity['id'] > @id.to_i
18
- system "growlnotify -t 'Pivotal Tracker' -m '#{activity['description']}'"
18
+ notify_about activity['description']
19
19
  end
20
20
  end
21
21
  update_id_from activities
@@ -38,4 +38,14 @@ class Kilt
38
38
  def fetch_activities
39
39
  return XML.parse(RestClient.get("http://www.pivotaltracker.com/services/v3/activities?limit=10", 'X-TrackerToken' => @token).body)['activities']
40
40
  end
41
+
42
+ def notify_about(message)
43
+ title = 'Pivotal Tracker'
44
+ case RUBY_PLATFORM
45
+ when /linux/
46
+ system "notify-send '#{title}' '#{message}'"
47
+ when /darwin/
48
+ system "growlnotify -t '#{title}' -m '#{message}'"
49
+ end
50
+ end
41
51
  end
data/spec/kilt_spec.rb CHANGED
@@ -54,6 +54,10 @@ describe Kilt do
54
54
  end
55
55
 
56
56
  context "on os x" do
57
+ before :all do
58
+ silence_warnings { RUBY_PLATFORM = "darwin" }
59
+ end
60
+
57
61
  it "should notify growl calling growlnotify with 'Pivotal Tracker' as the name the application, the author and the action" do
58
62
  @client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Superman finished lorem ipsum'")
59
63
  @client.update
@@ -65,5 +69,23 @@ describe Kilt do
65
69
  @client.update
66
70
  end
67
71
  end
72
+
73
+ context "on linux" do
74
+ before :all do
75
+ silence_warnings { RUBY_PLATFORM = "linux" }
76
+ end
77
+
78
+ it "should notify libnotify calling notify-send with 'Pivotal Tracker' as the name the application, the author and the action" do
79
+ @client.should_receive(:system).with("notify-send 'Pivotal Tracker' 'Superman finished lorem ipsum'")
80
+ @client.update
81
+ end
82
+
83
+ it "should notify newer activities at least" do
84
+ @client.should_receive(:system).with("notify-send 'Pivotal Tracker' 'SpongeBog finished lorem ipsum'").ordered
85
+ @client.should_receive(:system).with("notify-send 'Pivotal Tracker' 'Superman finished lorem ipsum'").ordered
86
+ @client.update
87
+ end
88
+ end
89
+
68
90
  end
69
91
  end
data/spec/spec_helper.rb CHANGED
@@ -18,6 +18,13 @@ def latests_activities
18
18
  read "latests_activities"
19
19
  end
20
20
 
21
+ def silence_warnings(&block)
22
+ old_verbose, $VERBOSE = $VERBOSE, nil
23
+ yield
24
+ ensure
25
+ $VERBOSE = old_verbose
26
+ end
27
+
21
28
  require 'fakeweb'
22
29
 
23
30
  FakeWeb.register_uri(:get, "http://www.pivotaltracker.com/services/v3/activities?limit=10", :body => latests_activities)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Diego Carrion
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-22 00:00:00 -03:00
17
+ date: 2010-04-20 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency