socialization-cassandra 0.0.1.pre.alpha

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 (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +0 -0
  5. data/Gemfile +9 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +144 -0
  8. data/Rakefile +10 -0
  9. data/init.rb +1 -0
  10. data/lib/generators/socialization/socialization_generator.rb +17 -0
  11. data/lib/generators/socialization/templates/cassandra/model_comment.rb +2 -0
  12. data/lib/generators/socialization/templates/cassandra/model_follow.rb +2 -0
  13. data/lib/generators/socialization/templates/cassandra/model_like.rb +2 -0
  14. data/lib/generators/socialization/templates/cassandra/model_share.rb +2 -0
  15. data/lib/generators/socialization/templates/socialization_cassandra_migrations.rake +141 -0
  16. data/lib/socialization/actors/commenter.rb +79 -0
  17. data/lib/socialization/actors/follower.rb +79 -0
  18. data/lib/socialization/actors/liker.rb +79 -0
  19. data/lib/socialization/actors/mentioner.rb +79 -0
  20. data/lib/socialization/actors/sharer.rb +79 -0
  21. data/lib/socialization/config/config.rb +51 -0
  22. data/lib/socialization/helpers/acts_as_helpers.rb +49 -0
  23. data/lib/socialization/helpers/string.rb +17 -0
  24. data/lib/socialization/lib/exceptions.rb +3 -0
  25. data/lib/socialization/stores/cassandra/base.rb +149 -0
  26. data/lib/socialization/stores/cassandra/comment.rb +28 -0
  27. data/lib/socialization/stores/cassandra/config.rb +29 -0
  28. data/lib/socialization/stores/cassandra/follow.rb +36 -0
  29. data/lib/socialization/stores/cassandra/like.rb +35 -0
  30. data/lib/socialization/stores/cassandra/mixins/base.rb +8 -0
  31. data/lib/socialization/stores/cassandra/share.rb +28 -0
  32. data/lib/socialization/stores/mixins/base.rb +22 -0
  33. data/lib/socialization/stores/mixins/follow.rb +39 -0
  34. data/lib/socialization/stores/mixins/like.rb +40 -0
  35. data/lib/socialization/stores/mixins/mention.rb +40 -0
  36. data/lib/socialization/version.rb +3 -0
  37. data/lib/socialization/victims/commentable.rb +51 -0
  38. data/lib/socialization/victims/followable.rb +50 -0
  39. data/lib/socialization/victims/likeable.rb +51 -0
  40. data/lib/socialization/victims/shareable.rb +51 -0
  41. data/lib/socialization.rb +17 -0
  42. data/socialization-cassandra.gemspec +30 -0
  43. data/test/actors/follower_test.rb +129 -0
  44. data/test/actors/liker_test.rb +121 -0
  45. data/test/stores/cassandra/base_test.rb +186 -0
  46. data/test/stores/cassandra/config_test.rb +36 -0
  47. data/test/stores/cassandra/follow_store_test.rb +28 -0
  48. data/test/stores/cassandra/like_store_test.rb +26 -0
  49. data/test/string_test.rb +13 -0
  50. data/test/test_helper.rb +259 -0
  51. data/test/victims/followable_test.rb +65 -0
  52. data/test/victims/likeable_test.rb +67 -0
  53. data/test/world_test.rb +107 -0
  54. metadata +209 -0
@@ -0,0 +1,107 @@
1
+ require File.expand_path(File.dirname(__FILE__))+'/test_helper'
2
+
3
+ # Test Socialization as it would be used in a "real world" scenario
4
+ class WorldTest < Minitest::Test
5
+ cattr_reader :users, :movies, :celebs
6
+
7
+ context "The World" do
8
+ setup do
9
+ seed
10
+ end
11
+
12
+ # context "Cassandra store" do
13
+ # setup { use_cassandra_store }
14
+ # should "be social" do
15
+ # test_the_world
16
+ # end
17
+ # end
18
+
19
+ end
20
+
21
+ # def test_the_world
22
+ # john.like!(pulp)
23
+ # john.follow!(jane)
24
+ # john.follow!(travolta)
25
+
26
+ # assert john.likes?(pulp)
27
+ # assert john.follows?(jane)
28
+ # assert john.follows?(travolta)
29
+
30
+ # assert pulp.liked_by?(john)
31
+ # assert travolta.followed_by?(john)
32
+
33
+ # carl.like!(pulp)
34
+ # camilo.like!(pulp)
35
+ # assert_equal 3, pulp.likers(User).size
36
+
37
+ # assert pulp.likers(User).include?(carl)
38
+ # assert pulp.likers(User).include?(john)
39
+ # assert pulp.likers(User).include?(camilo)
40
+ # assert !pulp.likers(User).include?(mat)
41
+
42
+ # carl.follow!(mat)
43
+ # mat.follow!(carl)
44
+ # camilo.follow!(carl)
45
+
46
+ # assert carl.follows?(mat)
47
+ # assert mat.followed_by?(carl)
48
+ # assert mat.follows?(carl)
49
+ # assert carl.followed_by?(mat)
50
+ # assert camilo.follows?(carl)
51
+ # assert !carl.follows?(camilo)
52
+
53
+ # assert_raise Socialization::ArgumentError do
54
+ # john.like!(travolta) # Can't like a Celeb
55
+ # end
56
+
57
+ # assert_raise Socialization::ArgumentError do
58
+ # john.follow!(kill_bill) # Can't follow a movie
59
+ # end
60
+
61
+ # # You can even follow or like yourself if your ego is that big.
62
+ # assert john.follow!(john)
63
+ # assert john.like!(john)
64
+
65
+ # comment = john.comments.create(:body => "I think Tami and Carl would like this movie!", :movie_id => pulp.id)
66
+ # comment.mention!(tami)
67
+ # comment.mention!(carl)
68
+ # assert comment.mentions?(carl)
69
+ # assert carl.mentioned_by?(comment)
70
+ # assert comment.mentions?(tami)
71
+ # assert tami.mentioned_by?(comment)
72
+ # end
73
+
74
+ def seed
75
+ @@users = {}
76
+ @@celebs = {}
77
+ @@movies = {}
78
+ @@comments = {}
79
+
80
+ @@users[:john] = User.create :name => 'John Doe'
81
+ @@users[:jane] = User.create :name => 'Jane Doe'
82
+ @@users[:mat] = User.create :name => 'Mat'
83
+ @@users[:carl] = User.create :name => 'Carl'
84
+ @@users[:camilo] = User.create :name => 'Camilo'
85
+ @@users[:tami] = User.create :name => 'Tami'
86
+
87
+ @@movies[:pulp] = Movie.create :name => 'Pulp Fiction'
88
+ @@movies[:reservoir] = Movie.create :name => 'Reservoir Dogs'
89
+ @@movies[:kill_bill] = Movie.create :name => 'Kill Bill'
90
+
91
+ @@celebs[:willis] = Celebrity.create :name => 'Bruce Willis'
92
+ @@celebs[:travolta] = Celebrity.create :name => 'John Travolta'
93
+ @@celebs[:jackson] = Celebrity.create :name => 'Samuel L. Jackson'
94
+ end
95
+
96
+ # def method_missing(meth, *args, &block)
97
+ # sym = meth.to_sym
98
+ # puts "#{meth} ---- #{sym}"
99
+ # return users[sym] if users && users[sym]
100
+ # return celebs[sym] if celebs && celebs[sym]
101
+ # return movies[sym] if movies && movies[sym]
102
+ # return comments[sym] if comments && comments[sym]
103
+ # require 'pry'; binding.pry
104
+ # super
105
+ # end
106
+
107
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: socialization-cassandra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Amrit Singh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cassandra-driver
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: logger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '4.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '4.0'
125
+ description: Socialization allows any model to Follow and/or Like any other model.
126
+ This is accomplished through a double polymorphic relationship on the Follow and
127
+ Like models. But you don't need to know that since all the complexity is hidden
128
+ from you.
129
+ email: amrit0403@gmail.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .travis.yml
136
+ - CHANGELOG.md
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - init.rb
142
+ - lib/generators/socialization/socialization_generator.rb
143
+ - lib/generators/socialization/templates/cassandra/model_comment.rb
144
+ - lib/generators/socialization/templates/cassandra/model_follow.rb
145
+ - lib/generators/socialization/templates/cassandra/model_like.rb
146
+ - lib/generators/socialization/templates/cassandra/model_share.rb
147
+ - lib/generators/socialization/templates/socialization_cassandra_migrations.rake
148
+ - lib/socialization.rb
149
+ - lib/socialization/actors/commenter.rb
150
+ - lib/socialization/actors/follower.rb
151
+ - lib/socialization/actors/liker.rb
152
+ - lib/socialization/actors/mentioner.rb
153
+ - lib/socialization/actors/sharer.rb
154
+ - lib/socialization/config/config.rb
155
+ - lib/socialization/helpers/acts_as_helpers.rb
156
+ - lib/socialization/helpers/string.rb
157
+ - lib/socialization/lib/exceptions.rb
158
+ - lib/socialization/stores/cassandra/base.rb
159
+ - lib/socialization/stores/cassandra/comment.rb
160
+ - lib/socialization/stores/cassandra/config.rb
161
+ - lib/socialization/stores/cassandra/follow.rb
162
+ - lib/socialization/stores/cassandra/like.rb
163
+ - lib/socialization/stores/cassandra/mixins/base.rb
164
+ - lib/socialization/stores/cassandra/share.rb
165
+ - lib/socialization/stores/mixins/base.rb
166
+ - lib/socialization/stores/mixins/follow.rb
167
+ - lib/socialization/stores/mixins/like.rb
168
+ - lib/socialization/stores/mixins/mention.rb
169
+ - lib/socialization/version.rb
170
+ - lib/socialization/victims/commentable.rb
171
+ - lib/socialization/victims/followable.rb
172
+ - lib/socialization/victims/likeable.rb
173
+ - lib/socialization/victims/shareable.rb
174
+ - socialization-cassandra.gemspec
175
+ - test/actors/follower_test.rb
176
+ - test/actors/liker_test.rb
177
+ - test/stores/cassandra/base_test.rb
178
+ - test/stores/cassandra/config_test.rb
179
+ - test/stores/cassandra/follow_store_test.rb
180
+ - test/stores/cassandra/like_store_test.rb
181
+ - test/string_test.rb
182
+ - test/test_helper.rb
183
+ - test/victims/followable_test.rb
184
+ - test/victims/likeable_test.rb
185
+ - test/world_test.rb
186
+ homepage: https://github.com/amritsingh/socialization-cassandra
187
+ licenses: []
188
+ metadata: {}
189
+ post_install_message:
190
+ rdoc_options: []
191
+ require_paths:
192
+ - lib
193
+ required_ruby_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - '>'
201
+ - !ruby/object:Gem::Version
202
+ version: 1.3.1
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 2.4.5
206
+ signing_key:
207
+ specification_version: 4
208
+ summary: Easily socialize your app with Likes and Follows
209
+ test_files: []