socialization 0.4.0 → 0.5.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/.gitignore +5 -1
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +246 -0
  4. data/demo/{demo_app/.gitignore → .gitignore} +0 -0
  5. data/demo/{demo_app/Gemfile → Gemfile} +1 -1
  6. data/demo/{demo_app/README.rdoc → README.rdoc} +0 -0
  7. data/demo/{demo_app/Rakefile → Rakefile} +0 -0
  8. data/demo/{demo_app/app → app}/assets/images/rails.png +0 -0
  9. data/demo/{demo_app/app → app}/assets/javascripts/application.js +0 -0
  10. data/demo/{demo_app/app → app}/assets/stylesheets/application.css +0 -0
  11. data/demo/{demo_app/app → app}/controllers/application_controller.rb +0 -0
  12. data/demo/{demo_app/app → app}/helpers/application_helper.rb +0 -0
  13. data/demo/{demo_app/app → app}/mailers/.gitkeep +0 -0
  14. data/demo/{demo_app/app → app}/models/.gitkeep +0 -0
  15. data/demo/{demo_app/app → app}/models/celebrity.rb +0 -0
  16. data/demo/{demo_app/app → app}/models/comment.rb +0 -0
  17. data/demo/app/models/follow.rb +2 -0
  18. data/demo/app/models/like.rb +2 -0
  19. data/demo/app/models/mention.rb +2 -0
  20. data/demo/{demo_app/app → app}/models/movie.rb +0 -0
  21. data/demo/{demo_app/app → app}/models/user.rb +0 -0
  22. data/demo/{demo_app/app → app}/views/layouts/application.html.erb +0 -0
  23. data/demo/{demo_app/config.ru → config.ru} +0 -0
  24. data/demo/{demo_app/config → config}/application.rb +0 -0
  25. data/demo/{demo_app/config → config}/boot.rb +0 -0
  26. data/demo/{demo_app/config → config}/database.yml +0 -0
  27. data/demo/{demo_app/config → config}/environment.rb +0 -0
  28. data/demo/{demo_app/config → config}/environments/development.rb +0 -0
  29. data/demo/{demo_app/config → config}/environments/production.rb +0 -0
  30. data/demo/{demo_app/config → config}/environments/test.rb +0 -0
  31. data/demo/{demo_app/config → config}/initializers/backtrace_silencers.rb +0 -0
  32. data/demo/{demo_app/config → config}/initializers/inflections.rb +0 -0
  33. data/demo/{demo_app/config → config}/initializers/mime_types.rb +0 -0
  34. data/demo/{demo_app/config → config}/initializers/secret_token.rb +0 -0
  35. data/demo/{demo_app/config → config}/initializers/session_store.rb +1 -1
  36. data/demo/{demo_app/config → config}/initializers/wrap_parameters.rb +1 -1
  37. data/demo/{demo_app/config → config}/locales/en.yml +0 -0
  38. data/demo/{demo_app/config → config}/routes.rb +0 -0
  39. data/demo/{demo_app/db → db}/migrate/20120115051222_create_users.rb +0 -0
  40. data/demo/{demo_app/db → db}/migrate/20120115051234_create_movies.rb +0 -0
  41. data/demo/{demo_app/db → db}/migrate/20120115051255_create_celebrities.rb +0 -0
  42. data/demo/{demo_app/db → db}/migrate/20120115054646_create_follows.rb +0 -0
  43. data/demo/{demo_app/db → db}/migrate/20120115054647_create_likes.rb +0 -0
  44. data/demo/{demo_app/db → db}/migrate/20120221200644_create_mentions.rb +0 -0
  45. data/demo/{demo_app/db → db}/migrate/20120221202703_create_comments.rb +0 -0
  46. data/demo/{demo_app/db → db}/schema.rb +0 -1
  47. data/demo/{demo_app/db → db}/seeds.rb +0 -0
  48. data/demo/{demo_app/lib → lib}/assets/.gitkeep +0 -0
  49. data/demo/{demo_app/lib → lib}/tasks/.gitkeep +0 -0
  50. data/demo/{demo_app/public → public}/404.html +0 -0
  51. data/demo/{demo_app/public → public}/422.html +0 -0
  52. data/demo/{demo_app/public → public}/500.html +0 -0
  53. data/demo/{demo_app/public → public}/favicon.ico +0 -0
  54. data/demo/{demo_app/public → public}/index.html +0 -0
  55. data/demo/{demo_app/public → public}/robots.txt +0 -0
  56. data/demo/{demo_app/script → script}/rails +0 -0
  57. data/demo/{demo_app/test → test}/fixtures/.gitkeep +0 -0
  58. data/demo/{demo_app/test → test}/fixtures/celebrities.yml +0 -0
  59. data/demo/{demo_app/test → test}/fixtures/movies.yml +0 -0
  60. data/demo/{demo_app/test → test}/fixtures/users.yml +0 -0
  61. data/demo/{demo_app/test → test}/functional/.gitkeep +0 -0
  62. data/demo/{demo_app/test → test}/integration/.gitkeep +0 -0
  63. data/demo/{demo_app/test → test}/performance/browsing_test.rb +0 -0
  64. data/demo/{demo_app/test → test}/test_helper.rb +0 -0
  65. data/demo/{demo_app/test → test}/unit/.gitkeep +0 -0
  66. data/demo/{demo_app/test → test}/unit/celebrity_test.rb +0 -0
  67. data/demo/{demo_app/test → test}/unit/movie_test.rb +0 -0
  68. data/demo/{demo_app/test → test}/unit/user_test.rb +0 -0
  69. data/demo/{demo_app/vendor → vendor}/assets/javascripts/.gitkeep +0 -0
  70. data/demo/{demo_app/vendor → vendor}/assets/stylesheets/.gitkeep +0 -0
  71. data/demo/{demo_app/vendor → vendor}/plugins/.gitkeep +0 -0
  72. data/lib/generators/socialization/socialization_generator.rb +20 -9
  73. data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_follows.rb +0 -0
  74. data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_likes.rb +0 -0
  75. data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_mentions.rb +0 -0
  76. data/lib/generators/socialization/templates/active_record/model_follow.rb +2 -0
  77. data/lib/generators/socialization/templates/active_record/model_like.rb +2 -0
  78. data/lib/generators/socialization/templates/active_record/model_mention.rb +2 -0
  79. data/lib/socialization.rb +3 -5
  80. data/lib/socialization/actors/follower.rb +74 -0
  81. data/lib/socialization/actors/liker.rb +74 -0
  82. data/lib/socialization/actors/mentioner.rb +74 -0
  83. data/lib/socialization/acts_as_helpers.rb +43 -0
  84. data/lib/socialization/config.rb +45 -0
  85. data/lib/socialization/helpers/string.rb +17 -0
  86. data/lib/socialization/stores/active_record/follow_store.rb +143 -0
  87. data/lib/socialization/stores/active_record/like_store.rb +143 -0
  88. data/lib/socialization/stores/active_record/mention_store.rb +143 -0
  89. data/lib/socialization/stores/redis/base.rb +8 -0
  90. data/lib/socialization/stores/redis/config.rb +11 -0
  91. data/lib/socialization/stores/redis/follow_store.rb +126 -0
  92. data/lib/socialization/stores/redis/like_store.rb +126 -0
  93. data/lib/socialization/stores/redis/mention_store.rb +126 -0
  94. data/lib/socialization/version.rb +1 -1
  95. data/lib/socialization/victims/followable.rb +38 -0
  96. data/lib/socialization/victims/likeable.rb +38 -0
  97. data/lib/socialization/victims/mentionable.rb +38 -0
  98. data/socialization.gemspec +3 -3
  99. data/test/actors/follower_test.rb +74 -0
  100. data/test/actors/liker_test.rb +74 -0
  101. data/test/actors/mentioner_test.rb +74 -0
  102. data/test/stores/active_record/follow_store_test.rb +121 -0
  103. data/test/stores/active_record/like_store_test.rb +121 -0
  104. data/test/stores/active_record/mention_store_test.rb +121 -0
  105. data/test/stores/redis/config_test.rb +30 -0
  106. data/test/stores/redis/follow_store_test.rb +153 -0
  107. data/test/stores/redis/like_store_test.rb +153 -0
  108. data/test/stores/redis/mention_store_test.rb +153 -0
  109. data/test/string_test.rb +13 -0
  110. data/test/test_helper.rb +70 -12
  111. data/test/victims/followable_test.rb +34 -0
  112. data/test/victims/likeable_test.rb +34 -0
  113. data/test/victims/mentionable_test.rb +34 -0
  114. data/test/world_test.rb +80 -69
  115. metadata +261 -176
  116. data/README.rdoc +0 -186
  117. data/demo/demo_app/app/models/follow.rb +0 -3
  118. data/demo/demo_app/app/models/like.rb +0 -3
  119. data/demo/demo_app/app/models/mention.rb +0 -3
  120. data/demo/demo_app/doc/README_FOR_APP +0 -2
  121. data/gemfiles/activerecord30.gemfile +0 -6
  122. data/gemfiles/activerecord30.gemfile.lock +0 -23
  123. data/gemfiles/activerecord31.gemfile +0 -6
  124. data/gemfiles/activerecord31.gemfile.lock +0 -25
  125. data/gemfiles/activerecord32.gemfile +0 -6
  126. data/gemfiles/activerecord32.gemfile.lock +0 -25
  127. data/generators/socialization/USAGE +0 -1
  128. data/generators/socialization/socialization_generator.rb +0 -15
  129. data/generators/socialization/templates/model_follow.rb +0 -3
  130. data/generators/socialization/templates/model_like.rb +0 -3
  131. data/generators/socialization/templates/model_mention.rb +0 -3
  132. data/lib/socialization/follow_store.rb +0 -14
  133. data/lib/socialization/followable.rb +0 -34
  134. data/lib/socialization/follower.rb +0 -50
  135. data/lib/socialization/hello.rb +0 -53
  136. data/lib/socialization/like_store.rb +0 -14
  137. data/lib/socialization/likeable.rb +0 -34
  138. data/lib/socialization/liker.rb +0 -54
  139. data/lib/socialization/mention_store.rb +0 -14
  140. data/lib/socialization/mentionable.rb +0 -36
  141. data/lib/socialization/mentioner.rb +0 -54
  142. data/test/follow_test.rb +0 -125
  143. data/test/like_test.rb +0 -125
  144. data/test/mention_test.rb +0 -116
data/test/mention_test.rb DELETED
@@ -1,116 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__))+'/test_helper'
2
-
3
- class MentionTest < Test::Unit::TestCase
4
- context "a Mentioner" do
5
- setup do
6
- seed
7
- end
8
-
9
- should "be mentioner" do
10
- assert_equal true, @mentioner1.is_mentioner?
11
- end
12
-
13
- should "be able to mention a Mentionable" do
14
- assert @mentioner1.mention!(@mentionable1)
15
- assert_equal true, @mentioner1.mentions?(@mentionable1)
16
- assert_equal false, @mentioner2.mentions?(@mentionable1)
17
- end
18
-
19
- should "be able to unmention a Mentionable" do
20
- Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
21
- assert @mentioner1.unmention!(@mentionable1)
22
- assert_equal false, @mentioner1.mentions?(@mentionable1)
23
- end
24
-
25
- should "not be able to mention the same thing twice" do
26
- assert @mentioner1.mention!(@mentionable1)
27
-
28
- assert_raise ActiveRecord::RecordInvalid do
29
- @mentioner1.mention!(@mentionable1)
30
- end
31
- end
32
-
33
- should "not be able to unmention something that is not mentionned" do
34
- assert_raise ActiveRecord::RecordNotFound do
35
- @mentioner1.unmention!(@mentionable1)
36
- end
37
- end
38
-
39
- should "be able to mention itself" do
40
- @mentioner_and_mentionable.mention!(@mentioner_and_mentionable)
41
- end
42
-
43
- should "expose a list of its mentionees" do
44
- Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
45
- assert @mentioner1.mentionees(ImAMentioner).is_a?(ActiveRecord::Relation)
46
- assert_equal [@mentionable1], @mentioner1.mentionees(ImAMentionable).all
47
-
48
- assert_equal @mentioner1.mentionees(ImAMentionable), @mentioner1.mentionees(:im_a_mentionables)
49
- assert_equal @mentioner1.mentionees(ImAMentionable), @mentioner1.mentionees("im_a_mentionable")
50
- end
51
- end
52
-
53
- context "a Mentionable" do
54
- setup do
55
- seed
56
- end
57
-
58
- should "be mentionable" do
59
- assert_equal true, @mentionable1.is_mentionable?
60
- end
61
-
62
- should "be able to determine who mentions it" do
63
- Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
64
- assert_equal true, @mentionable1.mentioned_by?(@mentioner1)
65
- assert_equal false, @mentionable1.mentioned_by?(@mentioner2)
66
- end
67
-
68
- should "expose a list of its mentioners" do
69
- Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
70
- assert @mentionable1.mentioners(ImAMentioner).is_a?(ActiveRecord::Relation)
71
- assert_equal [@mentioner1], @mentionable1.mentioners(ImAMentioner).all
72
-
73
- assert_equal @mentionable1.mentioners(ImAMentioner), @mentionable1.mentioners(:im_a_mentioners)
74
- assert_equal @mentionable1.mentioners(ImAMentioner), @mentionable1.mentioners("im_a_mentioner")
75
- end
76
-
77
- should "expose mentionings" do
78
- Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
79
- mentionings = @mentionable1.mentionings
80
- assert_equal 1, mentionings.size
81
- assert mentionings.first.is_a?(Mention)
82
- end
83
- end
84
-
85
- context "Deleting a mentioner" do
86
- setup do
87
- seed
88
- @mentioner1.mention!(@mentionable1)
89
- end
90
-
91
- should "delete its Mention records" do
92
- @mentioner1.destroy
93
- assert_equal false, @mentionable1.mentioned_by?(@mentioner1)
94
- end
95
- end
96
-
97
- context "Deleting a Mentionable" do
98
- setup do
99
- seed
100
- @mentioner1.mention!(@mentionable1)
101
- end
102
-
103
- should "delete its Mention records" do
104
- @mentionable1.destroy
105
- assert_equal false, @mentioner1.mentions?(@mentionable1)
106
- end
107
- end
108
-
109
- def seed
110
- @mentioner1 = ImAMentioner.create
111
- @mentioner2 = ImAMentioner.create
112
- @mentionable1 = ImAMentionable.create
113
- @mentionable2 = ImAMentionable.create
114
- @mentioner_and_mentionable = ImAMentionerAndMentionable.create
115
- end
116
- end