extraextra 0.2.0 → 0.3.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.
@@ -77,13 +77,20 @@ provide a way to override these eventually.
77
77
 
78
78
  To only see breaking news:
79
79
 
80
- $ user.breaking_news
80
+ $ Extra::Extra.breaking_news
81
81
 
82
- This will filter out only the news in the 'breaking' category.
82
+ This will filter out only the news in the 'breaking' category. You can pass an
83
+ optional user:
84
+
85
+ $ Extra::Extra.breaking_news user
86
+
87
+ This will only show breaking news for this specific user.
83
88
 
84
89
  To find out what interesting things a users's friends have done:
85
90
 
86
- $ user.scope_the_scene
91
+ $ Extra::Extra.scope_the_scene user
92
+
93
+ This also takes an optional user, just like *_news.
87
94
 
88
95
  To define what who you're friends with, make a method on your user model
89
96
  named my_peeps. For a (hypothetical) example:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{extraextra}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Steve Klabnik"]
12
- s.date = %q{2010-09-01}
12
+ s.date = %q{2010-09-02}
13
13
  s.description = %q{Need to add a news feed to your application? EXTRA! EXTRA! is just the Gem for you! This is a common need for many social applications. EXTRA! EXTRA! uses MongoDB to give you super fast, super convenient feeds.}
14
14
  s.email = %q{steve@steveklabnik.com}
15
15
  s.extra_rdoc_files = [
@@ -75,6 +75,17 @@ module Extra
75
75
 
76
76
  # aliasing a shorter name
77
77
  alias :the_scoop :read_all_about_it
78
+
79
+ # catches *_news to filter out the news
80
+ def method_missing(m, *args)
81
+ super unless m.to_s =~ /^(\w+)_news$/
82
+ user = args.first
83
+ params = {}
84
+ params = {who_id: user.id, who_class: user.class.to_s} unless user.nil?
85
+ params[:category] = $1
86
+ collection.find(params).collect{|args| Extra.new args }
87
+ end
88
+
78
89
  end
79
90
 
80
91
  end
@@ -75,4 +75,27 @@ describe Extra::Extra do
75
75
  end
76
76
 
77
77
  end
78
+
79
+ describe "#*_news" do
80
+
81
+ it "should filter some breaking news" do
82
+ user = Factory(:user)
83
+ Extra::Extra.source
84
+ extra = Extra::Extra::! :breaking, user, "hit a home run"
85
+ extra = Extra::Extra::! :boooring, user, "just ran a test"
86
+
87
+ Extra::Extra.breaking_news.length.should == 1
88
+ end
89
+
90
+ it "should filter some breaking news with a user" do
91
+ steve = Factory(:user)
92
+ nobody = Factory(:user, :id => "2", :username => "nobody")
93
+ Extra::Extra.source
94
+ extra = Extra::Extra::! :breaking, steve, "hit a home run"
95
+ extra = Extra::Extra::! :breaking, nobody, "hit a home run"
96
+
97
+ Extra::Extra.breaking_news(steve).length.should == 1
98
+ end
99
+
100
+ end
78
101
  end
@@ -1,12 +1,10 @@
1
1
  # we just want a dummy user
2
2
  class User
3
+ attr_accessor :id
4
+ attr_accessor :username
3
5
 
4
6
  def save!; end
5
- def id=(id); end
6
- def id; 1 end
7
- def username=(username); end
8
- def username; "steve" end
9
- def self.find(id); User.new end
7
+ def self.find(id); User.new(:id => id, :username => "somebody") end
10
8
 
11
9
  end
12
10
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Steve Klabnik
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-01 00:00:00 -04:00
17
+ date: 2010-09-02 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- hash: -4125126624120400925
90
+ hash: 1378414745553800960
91
91
  segments:
92
92
  - 0
93
93
  version: "0"