pfeed 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE.txt +20 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.markdown +115 -0
  7. data/README.rdoc +231 -0
  8. data/Rakefile +44 -0
  9. data/VERSION +1 -0
  10. data/app/models/pfeed_delivery.rb +4 -0
  11. data/app/models/pfeed_item.rb +172 -0
  12. data/app/models/pfeeds/user_updated_attribute.rb +14 -0
  13. data/app/views/pfeeds/_pfeed.html.erb +14 -0
  14. data/app/views/pfeeds/_pfeed_item.html.erb +3 -0
  15. data/app/views/pfeeds/_user_updated_attribute.html.erb +4 -0
  16. data/db/migrate/0000_create_pfeed_items.rb +18 -0
  17. data/db/migrate/0001_create_pfeed_deliveries.rb +15 -0
  18. data/init.rb +18 -0
  19. data/install.rb +1 -0
  20. data/lib/generator/pfeed_customization/USAGE +10 -0
  21. data/lib/generator/pfeed_customization/pfeed_customization_generator.rb +29 -0
  22. data/lib/generator/pfeed_customization/templates/pfeed_model.rb +5 -0
  23. data/lib/generator/pfeed_customization/templates/pfeed_view.html.erb +5 -0
  24. data/lib/pfeed.rb +29 -0
  25. data/lib/pfeed/pfeed.rb +102 -0
  26. data/lib/pfeed/pfeed_utils.rb +21 -0
  27. data/lib/pfeed_utils.rb +21 -0
  28. data/lib/tasks/pfeed.rake +54 -0
  29. data/pfeed.gemspec +93 -0
  30. data/pfeed/.document +5 -0
  31. data/pfeed/Gemfile +13 -0
  32. data/pfeed/LICENSE.txt +20 -0
  33. data/pfeed/Rakefile +53 -0
  34. data/pfeed/test/helper.rb +18 -0
  35. data/pfeed/test/test_pfeed.rb +7 -0
  36. data/test/bk_lib/pfeed_test.rb +57 -0
  37. data/test/bk_lib/pfeed_utils_test.rb +11 -0
  38. data/test/helper.rb +20 -0
  39. data/test/lib/pfeed_test.rb +57 -0
  40. data/test/lib/pfeed_utils_test.rb +11 -0
  41. data/test/test_helper.rb +71 -0
  42. data/test/test_pfeed.rb +9 -0
  43. data/uninstall.rb +1 -0
  44. metadata +164 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2.2)
10
+ rcov (0.9.11)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Naveed Ahmad
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Er Abhishek Parolkar ( abhishek [at] parolkar.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,115 @@
1
+ Pfeed
2
+ ======
3
+
4
+ You need Pfeed when you want to automagically create fancy logs / activity updates in your rails app, asynchronously.
5
+
6
+
7
+ ### What's so magical here?
8
+ Lets assume you have a model that looks like
9
+
10
+ <pre>
11
+ <code>
12
+ class User < ActiveRecord::Base
13
+ has_many :friends
14
+ has_one :company
15
+ def buy(x)
16
+ ...
17
+ end
18
+
19
+ def sell(x)
20
+ ...
21
+ end
22
+
23
+ def find_friends
24
+ ...
25
+ end
26
+ end
27
+ </code>
28
+ </pre>
29
+
30
+ Now lets add two lines at bottom of model definition
31
+
32
+ <pre>
33
+ <code>
34
+ emits_pfeeds :on => [:buy,:sell,:find_friends,:update_attribute] , :for => [:itself , :friends] # Note: if feed needs to be received by all users , you could use :for => [:all_in_its_class]
35
+ receives_pfeed
36
+ </code>
37
+ </pre>
38
+
39
+
40
+ And you perform regular operations, like this
41
+
42
+ <pre>
43
+ <code>
44
+ u1 = User.first
45
+ u1.buy(10)
46
+ u1.sell(5)
47
+ u2 = User.last
48
+ list = u2.find_friends
49
+ u2.update_attribute(:nick_name, "alice")
50
+ u2.buy (1)
51
+ </code>
52
+ </pre>
53
+ your application now emits feed without any other additional piece of code, and feed will look like this in view.
54
+ <pre><code>
55
+ parolkar sold item about 6 minutes ago
56
+ parolkar bought item about 4 minutes ago
57
+ foo found friends about 2 minutes ago
58
+ foo updated attribute nick name about 2 minutes ago
59
+ alice bought item about 2 minutes ago
60
+ </code></pre>
61
+
62
+ Isn't it magical? that it guesses the identity of model object (parolkar or foo in this case) and methods being called are treated as verbs to form a simple past tense.
63
+
64
+ Even more, each feed can be customized and skinned the way you want. You can easily extend the functionality to suit your requirements.
65
+
66
+ If all this excites you, check out the tutorials [here](http://wiki.github.com/parolkar/pfeed "pfeed's Wiki") or explore some more advanced techniques [here](http://wiki.github.com/parolkar/pfeed/customizing-the-pfeed-item "pfeed customisation techniques")
67
+
68
+
69
+ ## Performance
70
+
71
+ *How efficient is feed generation and delivery?*
72
+
73
+ If your app has mechanisms for asynchronous processing, like delayed_job , pfeed plugin will automatically figure out how to schedule the delivery in the queue so that your request loop remains efficient and workers can perform deliveries. [Find out more](http://wiki.github.com/parolkar/pfeed/pfeed-delivery-as-background-job "pfeed delivery as background job")
74
+
75
+ ## More Details
76
+
77
+ *What is feed?*
78
+ Feed is the collection of activity logs which is generated while you perform actions on model objects.
79
+
80
+ *Whats so special?, Why should I bother about it?*
81
+
82
+ Imagine you want to create admin console for your app to monitor functional activities in your web apps ,i.e how users are using different parts of application. You will need to think of mechanism to capture the logs and then display in some logical manner.
83
+
84
+ OR
85
+
86
+ Imagine you are building an app like facebook and you want to capture all activity user is performing and display it to her friends/group member/admin , Its a whole new feature whose implementation will force you to dig into design of your app and see where all the logs get generated and then to whom all the logs are going to be published.
87
+
88
+ What if I give you a generalized information model which will allow you to create such feature by keeping it completely isolated from your existing logic? and What if it is really scalable enough?
89
+
90
+ (more content to come here...)
91
+
92
+
93
+ ## Installation
94
+
95
+ <pre>
96
+ <code>
97
+ $ rails plugin install git://github.com/parolkar/pfeed.git # or use script/plugin for older version of rails
98
+ $ rake pfeed:setup
99
+ </code>
100
+ </pre>
101
+
102
+ ## Custom pfeed model and view
103
+ if you wants to customize your views generate custom model and model with pfeed_customization, Generator and update model to collect and persist data,
104
+ And update view accoring to your requirements
105
+ <pre>
106
+ <code>
107
+ $ rails g pfeed_customization user create
108
+ </code>
109
+ will create your custom pfeed model and view
110
+ app/model/pfeeds/user_created.rb
111
+ app/views/pfeeds/_user_created.html.erb
112
+ </pre>
113
+
114
+
115
+ Copyright (c) 2009 [Abhishek Parolkar] abhishek[at]parolkar.com , released under the MIT license
@@ -0,0 +1,231 @@
1
+ Pfeed
2
+ ======
3
+
4
+ You need Pfeed when you want to automagically create fancy logs / activity updates in your rails app, asynchronously.
5
+
6
+
7
+ ### What's so magical here?
8
+ Lets assume you have a model that looks like
9
+
10
+ <pre>
11
+ <code>
12
+ class User < ActiveRecord::Base
13
+ has_many :friends
14
+ has_one :company
15
+ def buy(x)
16
+ ...
17
+ end
18
+
19
+ def sell(x)
20
+ ...
21
+ end
22
+
23
+ def find_friends
24
+ ...
25
+ end
26
+ end
27
+ </code>
28
+ </pre>
29
+
30
+ Now lets add two lines at bottom of model definition
31
+
32
+ <pre>
33
+ <code>
34
+ emits_pfeeds :on => [:buy,:sell,:find_friends,:update_attribute] , :for => [:itself , :friends] # Note: if feed needs to be received by all users , you could use :for => [:all_in_its_class]
35
+ receives_pfeed
36
+ </code>
37
+ </pre>
38
+
39
+
40
+ And you perform regular operations, like this
41
+
42
+ <pre>
43
+ <code>
44
+ u1 = User.first
45
+ u1.buy(10)
46
+ u1.sell(5)
47
+ u2 = User.last
48
+ list = u2.find_friends
49
+ u2.update_attribute(:nick_name, "alice")
50
+ u2.buy (1)
51
+ </code>
52
+ </pre>
53
+ your application now emits feed without any other additional piece of code, and feed will look like this in view.
54
+ <pre><code>
55
+ parolkar sold item about 6 minutes ago
56
+ parolkar bought item about 4 minutes ago
57
+ foo found friends about 2 minutes ago
58
+ foo updated attribute nick name about 2 minutes ago
59
+ alice bought item about 2 minutes ago
60
+ </code></pre>
61
+
62
+ Isn't it magical? that it guesses the identity of model object (parolkar or foo in this case) and methods being called are treated as verbs to form a simple past tense.
63
+
64
+ Even more, each feed can be customized and skinned the way you want. You can easily extend the functionality to suit your requirements.
65
+
66
+ If all this excites you, check out the tutorials [here](http://wiki.github.com/parolkar/pfeed "pfeed's Wiki") or explore some more advanced techniques [here](http://wiki.github.com/parolkar/pfeed/customizing-the-pfeed-item "pfeed customisation techniques")
67
+
68
+
69
+ ## Performance
70
+
71
+ *How efficient is feed generation and delivery?*
72
+
73
+ If your app has mechanisms for asynchronous processing, like delayed_job , pfeed plugin will automatically figure out how to schedule the delivery in the queue so that your request loop remains efficient and workers can perform deliveries. [Find out more](http://wiki.github.com/parolkar/pfeed/pfeed-delivery-as-background-job "pfeed delivery as background job")
74
+
75
+ ## More Details
76
+
77
+ *What is feed?*
78
+ Feed is the collection of activity logs which is generated while you perform actions on model objects.
79
+
80
+ *Whats so special?, Why should I bother about it?*
81
+
82
+ Imagine you want to create admin console for your app to monitor functional activities in your web apps ,i.e how users are using different parts of application. You will need to think of mechanism to capture the logs and then display in some logical manner.
83
+
84
+ OR
85
+
86
+ Imagine you are building an app like facebook and you want to capture all activity user is performing and display it to her friends/group member/admin , Its a whole new feature whose implementation will force you to dig into design of your app and see where all the logs get generated and then to whom all the logs are going to be published.
87
+
88
+ What if I give you a generalized information model which will allow you to create such feature by keeping it completely isolated from your existing logic? and What if it is really scalable enough?
89
+
90
+ (more content to come here...)
91
+
92
+
93
+ ## Installation
94
+
95
+ <pre>
96
+ <code>
97
+ $ rails plugin install git://github.com/parolkar/pfeed.git # or use script/plugin for older version of rails
98
+ $ rake pfeed:setup
99
+ </code>
100
+ </pre>
101
+
102
+ ## Custom pfeed model and view
103
+ if you wants to customize your views generate custom model and model with pfeed_customization generator, update model to collect and persist data,
104
+ And update view accoring to your requirements
105
+ <pre>
106
+ <code>
107
+ $ rails g pfeed_customization user create
108
+ </code>
109
+ will create your custom pfeed model and view
110
+ app/model/pfeeds/user_created.rb
111
+ app/views/pfeeds/_user_created.html.erb
112
+ </pre>
113
+
114
+ Thanks to
115
+ Pfeed
116
+ ======
117
+
118
+ You need Pfeed when you want to automagically create fancy logs / activity updates in your rails app, asynchronously.
119
+
120
+
121
+ ### What's so magical here?
122
+ Lets assume you have a model that looks like
123
+
124
+ <pre>
125
+ <code>
126
+ class User < ActiveRecord::Base
127
+ has_many :friends
128
+ has_one :company
129
+ def buy(x)
130
+ ...
131
+ end
132
+
133
+ def sell(x)
134
+ ...
135
+ end
136
+
137
+ def find_friends
138
+ ...
139
+ end
140
+ end
141
+ </code>
142
+ </pre>
143
+
144
+ Now lets add two lines at bottom of model definition
145
+
146
+ <pre>
147
+ <code>
148
+ emits_pfeeds :on => [:buy,:sell,:find_friends,:update_attribute] , :for => [:itself , :friends] # Note: if feed needs to be received by all users , you could use :for => [:all_in_its_class]
149
+ receives_pfeed
150
+ </code>
151
+ </pre>
152
+
153
+
154
+ And you perform regular operations, like this
155
+
156
+ <pre>
157
+ <code>
158
+ u1 = User.first
159
+ u1.buy(10)
160
+ u1.sell(5)
161
+ u2 = User.last
162
+ list = u2.find_friends
163
+ u2.update_attribute(:nick_name, "alice")
164
+ u2.buy (1)
165
+ </code>
166
+ </pre>
167
+ your application now emits feed without any other additional piece of code, and feed will look like this in view.
168
+ <pre><code>
169
+ parolkar sold item about 6 minutes ago
170
+ parolkar bought item about 4 minutes ago
171
+ foo found friends about 2 minutes ago
172
+ foo updated attribute nick name about 2 minutes ago
173
+ alice bought item about 2 minutes ago
174
+ </code></pre>
175
+
176
+ Isn't it magical? that it guesses the identity of model object (parolkar or foo in this case) and methods being called are treated as verbs to form a simple past tense.
177
+
178
+ Even more, each feed can be customized and skinned the way you want. You can easily extend the functionality to suit your requirements.
179
+
180
+ If all this excites you, check out the tutorials [here](http://wiki.github.com/parolkar/pfeed "pfeed's Wiki") or explore some more advanced techniques [here](http://wiki.github.com/parolkar/pfeed/customizing-the-pfeed-item "pfeed customisation techniques")
181
+
182
+
183
+ ## Performance
184
+
185
+ *How efficient is feed generation and delivery?*
186
+
187
+ If your app has mechanisms for asynchronous processing, like delayed_job , pfeed plugin will automatically figure out how to schedule the delivery in the queue so that your request loop remains efficient and workers can perform deliveries. [Find out more](http://wiki.github.com/parolkar/pfeed/pfeed-delivery-as-background-job "pfeed delivery as background job")
188
+
189
+ ## More Details
190
+
191
+ *What is feed?*
192
+ Feed is the collection of activity logs which is generated while you perform actions on model objects.
193
+
194
+ *Whats so special?, Why should I bother about it?*
195
+
196
+ Imagine you want to create admin console for your app to monitor functional activities in your web apps ,i.e how users are using different parts of application. You will need to think of mechanism to capture the logs and then display in some logical manner.
197
+
198
+ OR
199
+
200
+ Imagine you are building an app like facebook and you want to capture all activity user is performing and display it to her friends/group member/admin , Its a whole new feature whose implementation will force you to dig into design of your app and see where all the logs get generated and then to whom all the logs are going to be published.
201
+
202
+ What if I give you a generalized information model which will allow you to create such feature by keeping it completely isolated from your existing logic? and What if it is really scalable enough?
203
+
204
+ (more content to come here...)
205
+
206
+
207
+ ## Installation
208
+
209
+ <pre>
210
+ <code>
211
+ $ rails plugin install git://github.com/parolkar/pfeed.git # or use script/plugin for older version of rails
212
+ $ rake pfeed:setup
213
+ </code>
214
+ </pre>
215
+
216
+ ## Custom pfeed model and view
217
+ if you wants to customize your views generate custom model and model with pfeed_customization generator, update model to collect and persist data,
218
+ And update view accoring to your requirements
219
+ <pre>
220
+ <code>
221
+ $ rails g pfeed_customization user create
222
+ </code>
223
+ will create your custom pfeed model and view
224
+ app/model/pfeeds/user_created.rb
225
+ app/views/pfeeds/_user_created.html.erb
226
+ </pre>
227
+
228
+
229
+ Copyright (c) 2009 [Abhishek Parolkar] abhishek[at]parolkar.com , released under the MIT license
230
+ further details.
231
+
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+ require 'rake'
14
+
15
+ require 'jeweler'
16
+ Jeweler::Tasks.new do |gem|
17
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
+ gem.name = "pfeed"
19
+ gem.homepage = "http://github.com/naveed-ahmad/pfeed"
20
+ gem.license = "MIT"
21
+ gem.summary = 'Automagically create fancy logs / activity updates in your rails app, asynchronously'
22
+ gem.description = ''
23
+ gem.email = "naveed.ahmad@7vals.com"
24
+ gem.authors = ["Naveed Ahmad"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test