relevant-github 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ Github Widget for Relevant
@@ -0,0 +1,42 @@
1
+ require "relevant/widget"
2
+ require "feedzirra"
3
+
4
+ module Relevant
5
+ class Github
6
+ Version = "0.0.1"
7
+ include Relevant::Widget
8
+
9
+ available_options :title => :string,
10
+ :rss_feed => :string,
11
+ :limit => :string
12
+
13
+ refresh_every 1.minute
14
+
15
+ template_format :haml
16
+ template %q[
17
+ %h2 Github - #{@options[:title]}
18
+ %ul.github-activity
19
+ - activities.each do |activity|
20
+ %li
21
+ %img.avatar{:src => activity.gravatar }
22
+ = activity.title
23
+ :css
24
+ ul.github-activity li { padding-left: 28px; margin-bottom: 0.4em; clear: left }
25
+ ul.github-activity img.avatar { float: left; margin-left: -28px; width: 18px; height: 18px; border: 1px solid #505050; }
26
+ ]
27
+
28
+ Feedzirra::Feed.add_common_feed_entry_element("media:thumbnail", :as => :gravatar, :value => :url)
29
+
30
+ def activities
31
+ options[:limit] ? feed.entries.first(options[:limit].to_i) : feed.entries
32
+ end
33
+
34
+ def feed
35
+ raise ArgumentError, "Github RSS feed is not set" unless options[:rss_feed].present?
36
+ @feed ||= Feedzirra::Feed.fetch_and_parse(options[:rss_feed])
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ Relevant.register Relevant::Github
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Relevant::Github do
4
+ describe "options" do
5
+ it "raises ArgumentError if rss feed is not set" do
6
+ lambda {
7
+ Relevant::Github.setup.feed
8
+ }.should raise_error(ArgumentError, "Github RSS feed is not set")
9
+ end
10
+
11
+ it "retrieves feed via Feedzilla" do
12
+ Feedzirra::Feed.expects(:fetch_and_parse).with("http://example.com/feed.atom")
13
+ Relevant::Github.setup(:rss_feed => "http://example.com/feed.atom").feed
14
+ end
15
+ end
16
+
17
+ describe "limit" do
18
+ context "limit is set" do
19
+ it "only pulls the first _limit_ items" do
20
+ Feedzirra::Feed.stubs(:fetch_and_parse).returns(
21
+ stub('feed', :entries => [stub_everything, stub_everything])
22
+ )
23
+ widget = Relevant::Github.setup(
24
+ :rss_feed => "http://example.com/feed.atom",
25
+ :limit => "1")
26
+ widget.activities.length.should == 1
27
+ end
28
+ end
29
+
30
+ context "limit not set" do
31
+ it "passes through all entries" do
32
+ entries = 3.times.inject([]) {|collection| collection << stub_everything }
33
+ Feedzirra::Feed.stubs(:fetch_and_parse).returns(
34
+ stub('feed', :entries => entries)
35
+ )
36
+ widget = Relevant::Github.setup(
37
+ :rss_feed => "http://example.com/feed.atom")
38
+ widget.activities.should == entries
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ require 'rspec'
2
+ require 'rspec/autorun'
3
+
4
+ $LOAD_PATH.unshift "../lib"
5
+ require "relevant/github"
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ config.mock_with :mocha
10
+
11
+ config.formatter = :progress
12
+ config.color_enabled = true
13
+ config.filter_run :focused => true
14
+ config.run_all_when_everything_filtered = true
15
+ config.alias_example_to :fit, :focused => true
16
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relevant-github
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jared Pace
13
+ - Rob Sanheim
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-08 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: relevant-widget
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 0
32
+ - 7
33
+ version: 0.0.7
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: feedzirra
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 2
59
+ - 0
60
+ - 0
61
+ - rc
62
+ version: 2.0.0.rc
63
+ type: :development
64
+ version_requirements: *id003
65
+ description: Parses github activity feeds
66
+ email: opensource@thinkrelevance.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - README.md
73
+ files:
74
+ - lib/relevant/github.rb
75
+ - spec/relevant/github_spec.rb
76
+ - spec/spec_helper.rb
77
+ - README.md
78
+ has_rdoc: true
79
+ homepage: http://github.com/relevance/relevant-github
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
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
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.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Github commit widget for Relevant
110
+ test_files:
111
+ - spec/relevant/github_spec.rb
112
+ - spec/spec_helper.rb