kilt 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/LICENSE +0 -0
- data/README.textile +22 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/bin/kilt-app +13 -0
- data/bin/kilt-install +5 -0
- data/lib/kilt.rb +41 -0
- data/spec/data/latests_activities.xml +53 -0
- data/spec/kilt_spec.rb +69 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +23 -0
- metadata +112 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
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
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
22
|
+
*.gemspec
|
23
|
+
cache
|
24
|
+
gems
|
25
|
+
bin/pivotal-tracker-client.rb.pid
|
data/LICENSE
ADDED
File without changes
|
data/README.textile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
h2. LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2010 Diego Carrion
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "kilt"
|
8
|
+
gem.summary = "A client that listens to Pivotal Tracker activities and notifies them with Growl."
|
9
|
+
gem.description = "A client that listens to Pivotal Tracker activities and notifies them with Growl."
|
10
|
+
gem.email = "dc.rec1@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/dcrec1/kilt"
|
12
|
+
gem.authors = ["Diego Carrion"]
|
13
|
+
gem.add_development_dependency "rest-client"
|
14
|
+
gem.add_development_dependency "crack"
|
15
|
+
gem.add_development_dependency "rufus-scheduler"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "pivotal-tracker-client #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/bin/kilt-app
ADDED
data/bin/kilt-install
ADDED
data/lib/kilt.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'crack/xml'
|
3
|
+
require 'rufus/scheduler'
|
4
|
+
|
5
|
+
class Kilt
|
6
|
+
include Crack
|
7
|
+
|
8
|
+
attr_reader :id
|
9
|
+
|
10
|
+
def self.init(token)
|
11
|
+
new token
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
activities = fetch_activities
|
16
|
+
activities.reverse.each do |activity|
|
17
|
+
if activity['id'] > @id.to_i
|
18
|
+
system "growlnotify -t 'Pivotal Tracker' -m '#{activity['description']}'"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
update_id_from activities
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def initialize(token)
|
27
|
+
@token = token
|
28
|
+
update_id_from fetch_activities
|
29
|
+
Rufus::Scheduler.start_new.every('30s') { update }
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def update_id_from(activities)
|
35
|
+
@id = activities.first['id'].to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch_activities
|
39
|
+
return XML.parse(RestClient.get("http://www.pivotaltracker.com/services/v3/activities?limit=10", 'X-TrackerToken' => @token).body)['activities']
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<activities type="array">
|
3
|
+
<activity>
|
4
|
+
<id type="integer">25906467</id>
|
5
|
+
<version type="integer">27585</version>
|
6
|
+
<event_type>story_update</event_type>
|
7
|
+
<occurred_at type="datetime">2010/03/17 21:48:15 ARST</occurred_at>
|
8
|
+
<author>Superman</author>
|
9
|
+
<project_id type="integer">32498</project_id>
|
10
|
+
<description>Superman finished lorem ipsum</description>
|
11
|
+
<stories>
|
12
|
+
<story>
|
13
|
+
<id type="integer">3934566</id>
|
14
|
+
<url>http://www.pivotaltracker.com/services/v3/projects/43498/stories/3934566</url>
|
15
|
+
<current_state>finished</current_state>
|
16
|
+
</story>
|
17
|
+
</stories>
|
18
|
+
</activity>
|
19
|
+
<activity>
|
20
|
+
<id type="integer">225906466</id>
|
21
|
+
<version type="integer">27585</version>
|
22
|
+
<event_type>story_update</event_type>
|
23
|
+
<occurred_at type="datetime">2010/03/17 21:48:15 ARST</occurred_at>
|
24
|
+
<author>SpongeBob</author>
|
25
|
+
<project_id type="integer">32498</project_id>
|
26
|
+
<description>SpongeBog finished lorem ipsum</description>
|
27
|
+
<stories>
|
28
|
+
<story>
|
29
|
+
<id type="integer">3934566</id>
|
30
|
+
<url>http://www.pivotaltracker.com/services/v3/projects/43498/stories/3934566</url>
|
31
|
+
<current_state>finished</current_state>
|
32
|
+
</story>
|
33
|
+
</stories>
|
34
|
+
</activity>
|
35
|
+
<activity>
|
36
|
+
<id type="integer">25906311</id>
|
37
|
+
<version type="integer">27584</version>
|
38
|
+
<event_type>story_update</event_type>
|
39
|
+
<occurred_at type="datetime">2010/03/17 21:44:42 ARST</occurred_at>
|
40
|
+
<author>Spiderman</author>
|
41
|
+
<project_id type="integer">43498</project_id>
|
42
|
+
<description>Spiderman edited "I want to delete alert notifications from the main alert notification page"</description>
|
43
|
+
<stories>
|
44
|
+
<story>
|
45
|
+
<id type="integer">3935407</id>
|
46
|
+
<url>http://www.pivotaltracker.com/services/v3/projects/43498/stories/3935407</url>
|
47
|
+
<description>In the main page, in place of the "Ignore" column, we will have a "Delete" column.
|
48
|
+
|
49
|
+
At the bottom, there should be a Deletar button, just like the "Aplicar" button (without the dropdown) in the Solicitacao management page. So, the user will be able to select many notifications and delete multiples at the same time.</description>
|
50
|
+
</story>
|
51
|
+
</stories>
|
52
|
+
</activity>
|
53
|
+
</activities>
|
data/spec/kilt_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Kilt do
|
4
|
+
context "on init with a token" do
|
5
|
+
before :each do
|
6
|
+
Rufus::Scheduler.stub(:start_new).and_return(@scheduler = mock(Object, :every => nil))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should save the id of the latest activity" do
|
10
|
+
client = Kilt.init '123456789'
|
11
|
+
client.id.should == '25906467'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should request the feed with the token" do
|
15
|
+
token = '34g43g4334g43g43'
|
16
|
+
RestClient.should_receive(:get) do |url, opts|
|
17
|
+
opts['X-TrackerToken'].should eql(token)
|
18
|
+
mock(Object, :body => latests_activities)
|
19
|
+
end
|
20
|
+
Kilt.init token
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should fetch new activities every 30 seconds" do
|
24
|
+
@scheduler.should_receive(:every).with('30s')
|
25
|
+
Kilt.init 'fegegege'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should fetch new activities" do
|
29
|
+
@scheduler.stub(:every) do |time, block|
|
30
|
+
block.call
|
31
|
+
end
|
32
|
+
RestClient.should_receive(:get).exactly(2).times do
|
33
|
+
mock(Object, :body => latests_activities)
|
34
|
+
end
|
35
|
+
Kilt.init 'fegegege'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "on update" do
|
40
|
+
before :each do
|
41
|
+
@client = Kilt.init('fake')
|
42
|
+
@client.stub! :system
|
43
|
+
@client.instance_variable_set "@id", '25906311'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should get the new activities and update the id" do
|
47
|
+
@client.update
|
48
|
+
@client.id.should == '25906467'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should notifify about each new activity" do
|
52
|
+
@client.should_receive(:system).exactly(2).times
|
53
|
+
@client.update
|
54
|
+
end
|
55
|
+
|
56
|
+
context "on os x" do
|
57
|
+
it "should notify growl calling growlnotify with 'Pivotal Tracker' as the name the application, the author and the action" do
|
58
|
+
@client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Superman finished lorem ipsum'")
|
59
|
+
@client.update
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should notify newer activities at least" do
|
63
|
+
@client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'SpongeBog finished lorem ipsum'").ordered
|
64
|
+
@client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Superman finished lorem ipsum'").ordered
|
65
|
+
@client.update
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
require 'kilt'
|
6
|
+
require 'spec'
|
7
|
+
require 'spec/autorun'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def read(name)
|
14
|
+
File.open(File.join(File.dirname(__FILE__), 'data', "#{name}.xml")).read
|
15
|
+
end
|
16
|
+
|
17
|
+
def latests_activities
|
18
|
+
read "latests_activities"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'fakeweb'
|
22
|
+
|
23
|
+
FakeWeb.register_uri(:get, "http://www.pivotaltracker.com/services/v3/activities?limit=10", :body => latests_activities)
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kilt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Diego Carrion
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-19 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rest-client
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: crack
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rufus-scheduler
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :development
|
55
|
+
version_requirements: *id003
|
56
|
+
description: A client that listens to Pivotal Tracker activities and notifies them with Growl.
|
57
|
+
email: dc.rec1@gmail.com
|
58
|
+
executables:
|
59
|
+
- kilt-app
|
60
|
+
- kilt-install
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
extra_rdoc_files:
|
64
|
+
- LICENSE
|
65
|
+
- README.textile
|
66
|
+
files:
|
67
|
+
- .document
|
68
|
+
- .gitignore
|
69
|
+
- LICENSE
|
70
|
+
- README.textile
|
71
|
+
- Rakefile
|
72
|
+
- VERSION
|
73
|
+
- bin/kilt-app
|
74
|
+
- bin/kilt-install
|
75
|
+
- lib/kilt.rb
|
76
|
+
- spec/data/latests_activities.xml
|
77
|
+
- spec/kilt_spec.rb
|
78
|
+
- spec/spec.opts
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/dcrec1/kilt
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- --charset=UTF-8
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.6
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: A client that listens to Pivotal Tracker activities and notifies them with Growl.
|
110
|
+
test_files:
|
111
|
+
- spec/kilt_spec.rb
|
112
|
+
- spec/spec_helper.rb
|