extraextra 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # gem "candy" #not for now
4
- gem "mongo"
5
- gem "bson_ext"
6
- gem "jeweler"
7
- gem "rake"
4
+ gem "mongo", "~>1.0.8"
5
+ gem "bson_ext", "~>1.0.7"
6
+ gem "jeweler", "~>1.4.0"
7
+ gem "rake", "~>0.8.7"
8
8
 
9
9
  group :test do
10
- gem "rspec"
11
- gem "factory_girl"
10
+ gem "rspec", "~>1.3.0"
11
+ gem "factory_girl", "~>1.3.2"
12
12
  end
data/Gemfile.lock CHANGED
@@ -22,9 +22,9 @@ PLATFORMS
22
22
  ruby
23
23
 
24
24
  DEPENDENCIES
25
- bson_ext
26
- factory_girl
27
- jeweler
28
- mongo
29
- rake
30
- rspec
25
+ bson_ext (~> 1.0.7)
26
+ factory_girl (~> 1.3.2)
27
+ jeweler (~> 1.4.0)
28
+ mongo (~> 1.0.8)
29
+ rake (~> 0.8.7)
30
+ rspec (~> 1.3.0)
data/README.rdoc CHANGED
@@ -1,13 +1,8 @@
1
1
  = EXTRA! EXTRA! READ ALL ABOUT IT!
2
2
 
3
- Need to add a news feed to your application? EXTRA! EXTRA! is just the Gem
4
- for you! This is a common need for many social applications. EXTRA! EXTRA!
5
- uses MongoDB to give you super fast, super convenient feeds.
3
+ 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.
6
4
 
7
- == Quick Note
8
-
9
- Not all of this works yet. This is just a prerelease. README driven
10
- development FTW!
5
+ Oh, and when I say "news feed", think "activity feed," not RSS. The stuff that's on the dashboard of every social app ever.
11
6
 
12
7
  == Install
13
8
 
@@ -29,14 +24,12 @@ It can be cloned via
29
24
 
30
25
  == Requirements
31
26
 
32
- * *Ruby-1.9* Sorry for you 1.8 people, 1.9 is the current version of Ruby.
33
- I test with 1.9.2.
34
- * *mongo* If you're going to use MongoDB...
27
+ * Ruby 1.9: Sorry for you 1.8 people, 1.9 is the current version of Ruby. I test with 1.9.2.
28
+ * mongo: If you're going to use MongoDB...
35
29
 
36
30
  == Usage
37
31
 
38
- The first thing you'll need to do is configure EXTRA! EXTRA! to connect to
39
- your MongoDB:
32
+ The first thing you'll need to do is configure EXTRA! EXTRA! to connect to your MongoDB:
40
33
 
41
34
  Extra::Extra.source :host => "localhost", :port => "1337"
42
35
 
@@ -52,8 +45,7 @@ or
52
45
 
53
46
  $ Extra::Extra.the_scoop user
54
47
 
55
- This returns an array of Extra objects. To find out more about a particular
56
- Extra:
48
+ This returns an array of Extra objects. To find out more about a particular Extra:
57
49
 
58
50
  $ extra = Extra::Extra::! :sports, user, "hit a home run!"
59
51
 
@@ -70,17 +62,13 @@ Extra:
70
62
  $ extra.to_s
71
63
  => "Steve hit a home run"
72
64
 
73
- Two things: 'who' instantiates the object by sending it the find message,
74
- passing an id. So that has to be defined in your user object. Secondly, the
75
- name in to_s comes from user#username. If you use something else... I'll
76
- provide a way to override these eventually.
65
+ Two things: 'who' instantiates the object by sending it the find message, passing an id. So that has to be defined in your user object. Secondly, the name in to_s comes from user#username. If you use something else... I'll provide a way to override these eventually.
77
66
 
78
67
  To only see breaking news:
79
68
 
80
69
  $ Extra::Extra.breaking_news
81
70
 
82
- This will filter out only the news in the 'breaking' category. You can pass an
83
- optional user:
71
+ This will filter out only the news in the 'breaking' category. You can pass an optional user:
84
72
 
85
73
  $ Extra::Extra.breaking_news user
86
74
 
@@ -90,7 +78,7 @@ To find out what interesting things a users's friends have done:
90
78
 
91
79
  $ Extra::Extra.scope_the_scene user
92
80
 
93
- This also takes an optional user, just like *_news.
81
+ This also takes a user, just like *_news.
94
82
 
95
83
  To define what who you're friends with, make a method on your user model
96
84
  named my_peeps. For a (hypothetical) example:
@@ -104,6 +92,16 @@ named my_peeps. For a (hypothetical) example:
104
92
  The my_peeps method should return an Array of ids. This method will be
105
93
  called during scope_the_scene to determine what results get returned.
106
94
 
95
+ == Roadmap
96
+
97
+ 1.0.0 was the release that implements the most basic functionality that I needed. I plan on integrating EXTRA! EXTRA! into a few of my projects, and seeing what could be useful. But here's a few things that are rolling around in my brain:
98
+
99
+ * Limits on most queries. This'll probably get added real quick.
100
+ * Generators for Rails that cover common use cases.
101
+ * Possibly allowing for extra metadata to be attached to each Extra.
102
+
103
+ We'll just roll with the punches. I'd love to hear some ideas.
104
+
107
105
  == Note on Patches/Pull Requests
108
106
 
109
107
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 1.0.0
data/extraextra.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{extraextra}
8
- s.version = "0.3.0"
8
+ s.version = "1.0.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"]
data/lib/extra/extra.rb CHANGED
@@ -86,7 +86,16 @@ module Extra
86
86
  collection.find(params).collect{|args| Extra.new args }
87
87
  end
88
88
 
89
- end
89
+ # gets friend stuff
90
+ def scope_the_scene user
91
+ params = {
92
+ who_id: {"$in" => user.my_peeps},
93
+ who_class: user.class.to_s
94
+ }
95
+ collection.find(params).collect{|args| Extra.new args }
96
+ end
97
+
98
+ end #end the class << self
90
99
 
91
100
  end
92
101
  end
@@ -89,7 +89,7 @@ describe Extra::Extra do
89
89
 
90
90
  it "should filter some breaking news with a user" do
91
91
  steve = Factory(:user)
92
- nobody = Factory(:user, :id => "2", :username => "nobody")
92
+ nobody = Factory(:user, :id => 2, :username => "nobody")
93
93
  Extra::Extra.source
94
94
  extra = Extra::Extra::! :breaking, steve, "hit a home run"
95
95
  extra = Extra::Extra::! :breaking, nobody, "hit a home run"
@@ -98,4 +98,25 @@ describe Extra::Extra do
98
98
  end
99
99
 
100
100
  end
101
+
102
+ describe "self#scope_the_scene" do
103
+ it "should exist" do
104
+ Extra::Extra.respond_to?(:scope_the_scene).should == true
105
+ end
106
+
107
+ it "should properly filter news" do
108
+ steve = Factory(:user)
109
+ maria = Factory(:user, :id => 2, :username => "maria")
110
+ nobody = Factory(:user, :id => 3, :username => "nobody")
111
+ steve.friends = [2]
112
+ Extra::Extra.source
113
+ extra = Extra::Extra::! :breaking, nobody, "hit a home run"
114
+ extra = Extra::Extra::! :breaking, nobody, "hit a home run"
115
+ extra = Extra::Extra::! :breaking, maria, "hit a home run"
116
+ extra = Extra::Extra::! :breaking, maria, "hit a home run"
117
+ extra = Extra::Extra::! :breaking, maria, "hit a home run"
118
+
119
+ Extra::Extra.scope_the_scene(steve).length.should == 3
120
+ end
121
+ end
101
122
  end
@@ -2,9 +2,17 @@
2
2
  class User
3
3
  attr_accessor :id
4
4
  attr_accessor :username
5
+ attr_accessor :friends
5
6
 
6
7
  def save!; end
7
- def self.find(id); User.new(:id => id, :username => "somebody") end
8
+
9
+ def self.find(id)
10
+ User.new(:id => id, :username => "somebody", :friends => [])
11
+ end
12
+
13
+ def my_peeps
14
+ friends
15
+ end
8
16
 
9
17
  end
10
18
 
metadata CHANGED
@@ -3,10 +3,10 @@ name: extraextra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 3
8
8
  - 0
9
- version: 0.3.0
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Steve Klabnik
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- hash: 1378414745553800960
90
+ hash: 4230050462933773545
91
91
  segments:
92
92
  - 0
93
93
  version: "0"