pfeed 0.1.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.
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,21 @@
1
+ module ParolkarInnovationLab
2
+ module SocialNet
3
+ module PfeedUtils
4
+ extend self
5
+ def attempt_pass_tense str_obj
6
+ #What can it do?
7
+ # it can automagically transform
8
+ # "addFriend" => "added_friend"
9
+ # "fightWithFriend" => "faught_with_friend"
10
+ # "buy_item" => "baught_item"
11
+ #the magic trick "abhishekParolkar hu hu".underscore.parameterize.underscore.to_s
12
+ str = str_obj.dup
13
+ str = str.underscore.parameterize.underscore.to_s
14
+ str_arr = str.split("_")
15
+ str_arr[0] = str_arr[0].to_past_tense # this is from infectionist ( script/plugin install git://github.com/parolkar/inflectionist.git )
16
+ str = str_arr.join("_")
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,21 @@
1
+ module ParolkarInnovationLab
2
+ module SocialNet
3
+ module PfeedUtils
4
+ extend self
5
+ def attempt_pass_tense str_obj
6
+ #What can it do?
7
+ # it can automagically transform
8
+ # "addFriend" => "added_friend"
9
+ # "fightWithFriend" => "faught_with_friend"
10
+ # "buy_item" => "baught_item"
11
+ #the magic trick "abhishekParolkar hu hu".underscore.parameterize.underscore.to_s
12
+ str = str_obj.dup
13
+ str = str.underscore.parameterize.underscore.to_s
14
+ str_arr = str.split("_")
15
+ str_arr[0] = str_arr[0].to_past_tense # this is from infectionist ( script/plugin install git://github.com/parolkar/inflectionist.git )
16
+ str = str_arr.join("_")
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,54 @@
1
+ namespace :pfeed do
2
+
3
+ desc 'Sets up parolkar\'s pfeed plugin '
4
+ task :setup do
5
+ root = "#{Rails.root}"
6
+ raise 'pfeed plugin was only tested on unix & windows' if ! Rake.application.unix? && ! Rake.application.windows?
7
+
8
+ if ! File.exists?("#{root}/vendor/plugins/inflectionist")
9
+ puts "Inflectionist plugin is required by pfeed, while you dont seem to have it installed \n Attempting to install..."
10
+ system "#{root}/script/rails plugin install git://github.com/parolkar/inflectionist.git "
11
+ end
12
+
13
+ raise '...something went wrong please install http://github.com/parolkar/inflectionist first!' if ! File.exists?("#{root}/vendor/plugins/inflectionist")
14
+
15
+
16
+ files_to_be_copied = [
17
+ {:source => "/vendor/plugins/pfeed/db/migrate/0000_create_pfeed_items.rb", :target => "/db/migrate/#{migration_timestamp}_create_pfeed_items.rb" },
18
+ {:source => "/vendor/plugins/pfeed/db/migrate/0001_create_pfeed_deliveries.rb", :target => "/db/migrate/#{migration_timestamp}_create_pfeed_deliveries.rb" }
19
+ ]
20
+
21
+
22
+ FileUtils.mkdir_p("#{root}/db/migrate") unless File.exists?("#{root}/db/migrate")
23
+ files_to_be_copied.each {|ftbc|
24
+ FileUtils.cp_r(root+ftbc[:source], root+ftbc[:target]) #:force => true)
25
+ puts "Created : #{ftbc[:target]}"
26
+ }
27
+
28
+ puts "Running \"rake db:migrate\" for you..."
29
+ Rake::Task["db:migrate"].invoke
30
+
31
+
32
+
33
+ welcome_screen
34
+
35
+ end
36
+
37
+ def migration_timestamp
38
+ sleep (1)
39
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
40
+
41
+ end
42
+
43
+ def welcome_screen
44
+
45
+ mesg = <<HERE
46
+ Congratulations for setting the plugin!
47
+
48
+
49
+ HERE
50
+
51
+ puts mesg
52
+ end
53
+
54
+ end
@@ -0,0 +1,93 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{pfeed}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Naveed Ahmad"]
12
+ s.date = %q{2011-12-21}
13
+ s.description = %q{}
14
+ s.email = %q{naveed.ahmad@7vals.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.markdown",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "MIT-LICENSE",
26
+ "README.markdown",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "app/models/pfeed_delivery.rb",
31
+ "app/models/pfeed_item.rb",
32
+ "app/models/pfeeds/user_updated_attribute.rb",
33
+ "app/views/pfeeds/_pfeed.html.erb",
34
+ "app/views/pfeeds/_pfeed_item.html.erb",
35
+ "app/views/pfeeds/_user_updated_attribute.html.erb",
36
+ "db/migrate/0000_create_pfeed_items.rb",
37
+ "db/migrate/0001_create_pfeed_deliveries.rb",
38
+ "init.rb",
39
+ "install.rb",
40
+ "lib/generator/pfeed_customization/USAGE",
41
+ "lib/generator/pfeed_customization/pfeed_customization_generator.rb",
42
+ "lib/generator/pfeed_customization/templates/pfeed_model.rb",
43
+ "lib/generator/pfeed_customization/templates/pfeed_view.html.erb",
44
+ "lib/pfeed.rb",
45
+ "lib/pfeed/pfeed.rb",
46
+ "lib/pfeed/pfeed_utils.rb",
47
+ "lib/pfeed_utils.rb",
48
+ "lib/tasks/pfeed.rake",
49
+ "pfeed.gemspec",
50
+ "pfeed/.document",
51
+ "pfeed/Gemfile",
52
+ "pfeed/LICENSE.txt",
53
+ "pfeed/Rakefile",
54
+ "pfeed/test/helper.rb",
55
+ "pfeed/test/test_pfeed.rb",
56
+ "test/bk_lib/pfeed_test.rb",
57
+ "test/bk_lib/pfeed_utils_test.rb",
58
+ "test/helper.rb",
59
+ "test/lib/pfeed_test.rb",
60
+ "test/lib/pfeed_utils_test.rb",
61
+ "test/test_helper.rb",
62
+ "test/test_pfeed.rb",
63
+ "uninstall.rb"
64
+ ]
65
+ s.homepage = %q{http://github.com/naveed-ahmad/pfeed}
66
+ s.licenses = ["MIT"]
67
+ s.require_paths = ["lib"]
68
+ s.rubygems_version = %q{1.3.6}
69
+ s.summary = %q{Automagically create fancy logs / activity updates in your rails app, asynchronously}
70
+
71
+ if s.respond_to? :specification_version then
72
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
73
+ s.specification_version = 3
74
+
75
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
77
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
78
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
79
+ s.add_development_dependency(%q<rcov>, [">= 0"])
80
+ else
81
+ s.add_dependency(%q<shoulda>, [">= 0"])
82
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
83
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
84
+ s.add_dependency(%q<rcov>, [">= 0"])
85
+ end
86
+ else
87
+ s.add_dependency(%q<shoulda>, [">= 0"])
88
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
89
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
90
+ s.add_dependency(%q<rcov>, [">= 0"])
91
+ end
92
+ end
93
+
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -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
+ 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,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "pfeed"
18
+ gem.homepage = "http://github.com/naveed-ahmad/pfeed"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TODO: one-line summary of your gem}
21
+ gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = "naveed.ahmad@7vals.com"
23
+ gem.authors = ["Naveed Ahmad"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "pfeed #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'pfeed'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestPfeed < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,57 @@
1
+ require 'test_helper'
2
+
3
+ load_schema
4
+
5
+ def pfeed
6
+ PfeedItem.find_by_originator_id(topic.id)
7
+ end
8
+
9
+ class Emitter < ActiveRecord::Base
10
+ def if_false_ping; end
11
+ def if_false; false end
12
+ def if_true_ping; end
13
+ def if_true; true end
14
+
15
+ def unless_false_ping; end
16
+ def unless_false; false end
17
+ def unless_true_ping; end
18
+ def unless_true; true end
19
+
20
+ receives_pfeed
21
+ end
22
+
23
+ context 'an emitter not satisfying an if or unless condition' do
24
+ setup do
25
+ Emitter.class_eval do
26
+ emits_pfeeds :on => :if_false_ping, :if => :if_false, :for => :itself
27
+ emits_pfeeds :on => :unless_true_ping, :unless => :unless_true, :for => :itself
28
+ end
29
+ Emitter.new.if_false_ping
30
+ Emitter.new.unless_true_ping
31
+ end
32
+ should("not create a pfeed item") { PfeedItem.all.empty? }
33
+ end
34
+
35
+ context 'an emitter satisfying an if condition' do
36
+ setup do
37
+ Emitter.class_eval do
38
+ emits_pfeeds :on => :if_true_ping, :if => :if_true, :for => :itself
39
+ end
40
+ returning(Emitter.create!(:name => 'bob')) do |e|
41
+ e.if_true_ping
42
+ end
43
+ end
44
+ should("create a pfeed item") { !PfeedItem.all.empty? }
45
+ should("guess the name") { pfeed.data[:originator_identity] }.equals('bob')
46
+ end
47
+
48
+ context 'an emitter satisfying an unless condition' do
49
+ setup do
50
+ Emitter.class_eval do
51
+ emits_pfeeds :on => :unless_false_ping, :unless => :unless_false, :for => :itself
52
+ end
53
+ e = Emitter.create!
54
+ e.unless_false_ping
55
+ end
56
+ should("create a pfeed item") { !PfeedItem.all.empty? }
57
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ context 'attempting past tense' do
4
+ def _(verb, past_tense)
5
+ asserts('') {ParolkarInnovationLab::SocialNet::PfeedUtils.attempt_pass_tense(verb)}.equals(past_tense)
6
+ end
7
+
8
+ _ "addFriend", "added_friend"
9
+ _ "fightWithFriend", "fought_with_friend"
10
+ _ "buy_item", "bought_item"
11
+ end
@@ -0,0 +1,20 @@
1
+ =begin
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'test/unit'
12
+ require 'shoulda'
13
+
14
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
+ require 'pfeed'
17
+
18
+ class Test::Unit::TestCase
19
+ end
20
+ =end
@@ -0,0 +1,57 @@
1
+ require 'test_helper'
2
+
3
+ load_schema
4
+
5
+ def pfeed
6
+ PfeedItem.find_by_originator_id(topic.id)
7
+ end
8
+
9
+ class Emitter < ActiveRecord::Base
10
+ def if_false_ping; end
11
+ def if_false; false end
12
+ def if_true_ping; end
13
+ def if_true; true end
14
+
15
+ def unless_false_ping; end
16
+ def unless_false; false end
17
+ def unless_true_ping; end
18
+ def unless_true; true end
19
+
20
+ receives_pfeed
21
+ end
22
+
23
+ context 'an emitter not satisfying an if or unless condition' do
24
+ setup do
25
+ Emitter.class_eval do
26
+ emits_pfeeds :on => :if_false_ping, :if => :if_false, :for => :itself
27
+ emits_pfeeds :on => :unless_true_ping, :unless => :unless_true, :for => :itself
28
+ end
29
+ Emitter.new.if_false_ping
30
+ Emitter.new.unless_true_ping
31
+ end
32
+ should("not create a pfeed item") { PfeedItem.all.empty? }
33
+ end
34
+
35
+ context 'an emitter satisfying an if condition' do
36
+ setup do
37
+ Emitter.class_eval do
38
+ emits_pfeeds :on => :if_true_ping, :if => :if_true, :for => :itself
39
+ end
40
+ returning(Emitter.create!(:name => 'bob')) do |e|
41
+ e.if_true_ping
42
+ end
43
+ end
44
+ should("create a pfeed item") { !PfeedItem.all.empty? }
45
+ should("guess the name") { pfeed.data[:originator_identity] }.equals('bob')
46
+ end
47
+
48
+ context 'an emitter satisfying an unless condition' do
49
+ setup do
50
+ Emitter.class_eval do
51
+ emits_pfeeds :on => :unless_false_ping, :unless => :unless_false, :for => :itself
52
+ end
53
+ e = Emitter.create!
54
+ e.unless_false_ping
55
+ end
56
+ should("create a pfeed item") { !PfeedItem.all.empty? }
57
+ end