pivotal-tracker-client 0.1.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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
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
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 = "pivotal-tracker-client"
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/pivotal-tracker-client"
12
+ gem.authors = ["Diego Carrion"]
13
+ gem.add_development_dependency "httparty"
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.1.0
@@ -0,0 +1,37 @@
1
+ require 'httparty'
2
+ require 'crack/xml'
3
+ require 'rufus/scheduler'
4
+
5
+ class PivotalTrackerClient
6
+ include HTTParty
7
+ include Crack
8
+
9
+ attr_reader :version
10
+
11
+ def self.init(token)
12
+ new token
13
+ end
14
+
15
+ def fetch
16
+ data = update_by "newer_than_version=#{@version}"
17
+ data['activities'].reverse.each do |activity|
18
+ system "growlnotify -t 'Pivotal Tracker' -m '#{activity['description']}'"
19
+ end
20
+ end
21
+
22
+ protected
23
+
24
+ def initialize(token)
25
+ @token = token
26
+ update_by 'limit=10'
27
+ Rufus::Scheduler.start_new.every('30s') { fetch }
28
+ end
29
+
30
+ private
31
+
32
+ def update_by(qs)
33
+ xml = XML.parse(self.class.get("http://www.pivotaltracker.com/services/v3/activities?#{qs}", :headers => {'X-TrackerToken' => @token}))
34
+ @version = xml['activities'].first['version']
35
+ return xml
36
+ end
37
+ end
@@ -0,0 +1,37 @@
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 &quot;When creating an alert, I want to define a severity&quot;</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">25906311</id>
21
+ <version type="integer">27584</version>
22
+ <event_type>story_update</event_type>
23
+ <occurred_at type="datetime">2010/03/17 21:44:42 ARST</occurred_at>
24
+ <author>Spiderman</author>
25
+ <project_id type="integer">43498</project_id>
26
+ <description>Superman edited &quot;I want to delete alert notifications from the main alert notification page&quot;</description>
27
+ <stories>
28
+ <story>
29
+ <id type="integer">3935407</id>
30
+ <url>http://www.pivotaltracker.com/services/v3/projects/43498/stories/3935407</url>
31
+ <description>In the main page, in place of the &quot;Ignore&quot; column, we will have a &quot;Delete&quot; column.
32
+
33
+ At the bottom, there should be a Deletar button, just like the &quot;Aplicar&quot; 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>
34
+ </story>
35
+ </stories>
36
+ </activity>
37
+ </activities>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <activities type="array">
3
+ <activity>
4
+ <id type="integer">25906467</id>
5
+ <version type="integer">28585</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">25906311</id>
21
+ <version type="integer">27584</version>
22
+ <event_type>story_update</event_type>
23
+ <occurred_at type="datetime">2010/03/17 21:44:42 ARST</occurred_at>
24
+ <author>Spiderman</author>
25
+ <project_id type="integer">43498</project_id>
26
+ <description>Spiderman edited lorem ipsum</description>
27
+ <stories>
28
+ <story>
29
+ <id type="integer">3935407</id>
30
+ <url>http://www.pivotaltracker.com/services/v3/projects/43498/stories/3935407</url>
31
+ <description>In the main page, in place of the &quot;Ignore&quot; column, we will have a &quot;Delete&quot; column.
32
+
33
+ At the bottom, there should be a Deletar button, just like the &quot;Aplicar&quot; 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>
34
+ </story>
35
+ </stories>
36
+ </activity>
37
+ </activities>
@@ -0,0 +1,66 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe PivotalTrackerClient 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 verstion of the latest activity" do
10
+ client = PivotalTrackerClient.init '123456789'
11
+ client.version.should == 27585
12
+ end
13
+
14
+ it "should request the feed with the token" do
15
+ token = '34g43g4334g43g43'
16
+ PivotalTrackerClient.should_receive(:get) do |url, opts|
17
+ opts[:headers]['X-TrackerToken'].should eql(token)
18
+ latests_activities
19
+ end
20
+ PivotalTrackerClient.init token
21
+ end
22
+
23
+ it "should fetch new activities every 30 seconds" do
24
+ @scheduler.should_receive(:every).with('30s')
25
+ PivotalTrackerClient.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
+ PivotalTrackerClient.should_receive(:get).exactly(2).times { latests_activities }
33
+ PivotalTrackerClient.init 'fegegege'
34
+ end
35
+ end
36
+
37
+ context "on fetch" do
38
+ before :each do
39
+ @client = PivotalTrackerClient.init('fake')
40
+ @client.stub! :system
41
+ end
42
+
43
+ it "should get the feed from the current version and update the version" do
44
+ @client.fetch
45
+ @client.version.should == 28585
46
+ end
47
+
48
+ context "on os x" do
49
+ it "should notifify growl about each activity" do
50
+ @client.should_receive(:system).exactly(2).times
51
+ @client.fetch
52
+ end
53
+
54
+ it "should notify growl calling growlnotify with 'Pivotal Tracker' as the name the application, the author and the action" do
55
+ @client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Superman finished lorem ipsum'")
56
+ @client.fetch
57
+ end
58
+
59
+ it "should notify newer activities at least" do
60
+ @client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Spiderman edited lorem ipsum'").ordered
61
+ @client.should_receive(:system).with("growlnotify -t 'Pivotal Tracker' -m 'Superman finished lorem ipsum'").ordered
62
+ @client.fetch
63
+ end
64
+ end
65
+ end
66
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'pivotal-tracker-client'
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)
24
+ FakeWeb.register_uri(:get, "http://www.pivotaltracker.com/services/v3/activities?newer_than_version=27585", :body => read('newer_than_version'))
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pivotal-tracker-client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Diego Carrion
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-18 00:00:00 -03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httparty
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
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - LICENSE
64
+ - README.textile
65
+ files:
66
+ - .document
67
+ - .gitignore
68
+ - LICENSE
69
+ - README.textile
70
+ - Rakefile
71
+ - VERSION
72
+ - lib/pivotal-tracker-client.rb
73
+ - spec/data/latests_activities.xml
74
+ - spec/data/newer_than_version.xml
75
+ - spec/pivotal-tracker-client_spec.rb
76
+ - spec/spec.opts
77
+ - spec/spec_helper.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/dcrec1/pivotal-tracker-client
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options:
84
+ - --charset=UTF-8
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.6
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: A client that listens to Pivotal Tracker activities and notifies them with Growl.
108
+ test_files:
109
+ - spec/pivotal-tracker-client_spec.rb
110
+ - spec/spec_helper.rb