jsmestad-gripht 0.1.2 → 0.2.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/Rakefile CHANGED
@@ -10,6 +10,7 @@ begin
10
10
  gem.email = "justin.smestad@gmail.com"
11
11
  gem.homepage = "http://github.com/jsmestad/gripht"
12
12
  gem.authors = ["Justin Smestad"]
13
+ gem.rubyforge_project = "gripht"
13
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
15
 
15
16
  gem.add_dependency "sinatra", ">= 0.9.1.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/gripht.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gripht}
5
- s.version = "0.1.2"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Justin Smestad"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "lib/gripht/views/failed.haml",
28
28
  "lib/gripht/views/index.haml",
29
29
  "lib/gripht/views/layout.haml",
30
+ "lib/gripht/views/stories.haml",
30
31
  "spec/fixtures.rb",
31
32
  "spec/gripht_spec.rb",
32
33
  "spec/spec_helper.rb"
@@ -34,6 +35,7 @@ Gem::Specification.new do |s|
34
35
  s.homepage = %q{http://github.com/jsmestad/gripht}
35
36
  s.rdoc_options = ["--charset=UTF-8"]
36
37
  s.require_paths = ["lib"]
38
+ s.rubyforge_project = %q{gripht}
37
39
  s.rubygems_version = %q{1.3.3}
38
40
  s.summary = %q{TODO}
39
41
  s.test_files = [
data/lib/gripht/app.rb CHANGED
@@ -3,35 +3,43 @@ module Gripht
3
3
  set :views, File.dirname(__FILE__) + '/views'
4
4
 
5
5
  helpers do
6
- # something goes here...
6
+ def resource
7
+ RestClient::Resource.new 'http://www.pivotaltracker.com/services/v2/projects', :headers => { 'X-TrackerToken' => ENV['TRACKER_TOKEN']}
8
+ end
9
+
10
+ def fetch_stories(project_id)
11
+ stories = Nokogiri::XML(resource["#{project_id}/stories?limit=10&filter=state%3Astarted"].get).xpath('//story')
12
+ { :stories => stories.collect do |story|
13
+ {
14
+ :name => story.at('name').content,
15
+ :owner => story.at('owned_by').content,
16
+ :created_at => story.at('created_at').content,
17
+ :description => story.at('description').nil? ? "" : story.at('description').content,
18
+ :url => story.at('url').content,
19
+ :type => story.at('story_type').content
20
+ }
21
+ end
22
+ }
23
+ end
7
24
  end
8
25
 
9
26
  errors do
10
27
  Gripht::Log.logger.info env['sinatra.error'].message
11
28
  haml :failed
12
29
  end
30
+
31
+ get '/update_project/:id' do
32
+ @stories = fetch_stories(params[:id])
33
+ haml :stories, :layout => false
34
+ end
13
35
 
14
36
  get '/application.js' do
15
37
  @application_js ||= File.read(File.dirname(__FILE__) + '/views/application.js')
16
38
  end
17
39
 
18
- get '/' do
19
- resource = RestClient::Resource.new 'http://www.pivotaltracker.com/services/v2/projects', :headers => { 'X-TrackerToken' => ENV['TRACKER_TOKEN']}
40
+ get '/' do
20
41
  @projects = Nokogiri::XML(resource.get).xpath('//project').collect { |r| { :id => r.at('id').content, :name => r.at('name').content } }
21
- @projects.each do |project|
22
- project.merge!({ :stories => Nokogiri::XML(resource["#{project[:id]}/stories?limit=10&filter=state%3Astarted"].get).xpath('//story').collect do |story|
23
- {
24
- :name => story.at('name').content,
25
- :owner => story.at('owned_by').content,
26
- :created_at => story.at('created_at').content,
27
- :description => story.at('description').nil? ? "" : story.at('description').content,
28
- :url => story.at('url').content,
29
- :type => story.at('story_type').content
30
- }
31
- end
32
- })
33
- end
34
-
42
+ @projects.each { |project| project.merge!(fetch_stories(project[:id])) }
35
43
  haml :index
36
44
  end
37
45
 
@@ -1,3 +1,32 @@
1
+ function callMeOften(id)
2
+ {
3
+ return function() {
4
+ $.ajax({
5
+ method: 'get',
6
+ url: '/update_project/' + id,
7
+ dataType : 'text',
8
+ success: function (text) { $('h4 a#' + id).parents('h4').next().fadeOut('slow').html(text).fadeIn('slow'); }
9
+ });
10
+ }
11
+ }
12
+
13
+
14
+
1
15
  jQuery(document).ready(function($) {
16
+ $.fn.slowEach = function( interval, callback ) {
17
+ var array = this;
18
+ if( ! array.length ) return;
19
+ var i = 0;
20
+ next();
21
+ function next() {
22
+ if( callback.call( array[i], i, array[i] ) !== false )
23
+ if( ++i < array.length )
24
+ setTimeout( next, interval );
25
+ }
26
+ };
27
+
2
28
  $('.story a').live('click', function(){ $(this).next('p').slideToggle('slow'); });
29
+ $('h4 a').slowEach(8000, function(){
30
+ setInterval(callMeOften(this.id), 20000);
31
+ });
3
32
  });
@@ -0,0 +1,10 @@
1
+ / This is a partial only used for rendering updates.
2
+ - @stories[:stories].each do |story|
3
+ %li.story
4
+ %a{:href => "#"}
5
+ = story[:name]
6
+ "(#{story[:owner]})"
7
+ %p.hidden
8
+ = story[:description] != "" ? story[:description] : "No Description Provided."
9
+ %br
10
+ %a{:href => story[:url]} Open story on Pivotal Tracker.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsmestad-gripht
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Smestad
@@ -116,6 +116,7 @@ files:
116
116
  - lib/gripht/views/failed.haml
117
117
  - lib/gripht/views/index.haml
118
118
  - lib/gripht/views/layout.haml
119
+ - lib/gripht/views/stories.haml
119
120
  - spec/fixtures.rb
120
121
  - spec/gripht_spec.rb
121
122
  - spec/spec_helper.rb
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  version:
141
142
  requirements: []
142
143
 
143
- rubyforge_project:
144
+ rubyforge_project: gripht
144
145
  rubygems_version: 1.2.0
145
146
  signing_key:
146
147
  specification_version: 3