sharp_social 0.0.1 → 0.1.1
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.
- data/.travis.yml +3 -2
- data/README.md +2 -9
- data/lib/generators/sharp_social/sharp_social_generator.rb +0 -1
- data/lib/generators/sharp_social/templates/migration.rb +0 -9
- data/lib/sharp_social/mixins/actor.rb +0 -14
- data/lib/sharp_social/version.rb +1 -1
- data/sharp_social.gemspec +2 -2
- data/spec/test_actor_spec.rb +0 -23
- data/spec/test_generator_spec.rb +0 -1
- metadata +47 -23
- data/lib/generators/sharp_social/templates/activity.rb +0 -2
- data/lib/sharp_social/models/activity.rb +0 -8
- data/spec/dummy/app/models/activity.rb +0 -3
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Add `acts_as_actor` to your model which need to act as an actor
|
|
27
27
|
```ruby
|
28
28
|
class User < ActiveRecord::Base
|
29
29
|
...
|
30
|
-
|
30
|
+
acts_as_actor
|
31
31
|
...
|
32
32
|
end
|
33
33
|
```
|
@@ -37,7 +37,7 @@ end
|
|
37
37
|
```ruby
|
38
38
|
@user.follow(@other_user)
|
39
39
|
@user.is_following?(@other_user) => true
|
40
|
-
@other_user.
|
40
|
+
@other_user.is_followed(@user) => true
|
41
41
|
|
42
42
|
@user.followings_count => 1
|
43
43
|
@other_user.follower_count => 1
|
@@ -46,13 +46,6 @@ end
|
|
46
46
|
@other_user.is_friend(@other_user) => true
|
47
47
|
@user.is_friend?(@other_user) => true
|
48
48
|
|
49
|
-
|
50
|
-
@user.create_activity({title: 'I create a sharp_social', body: 'sharp_social is in production'})
|
51
|
-
@other_user.followings_activities.count => 1
|
52
|
-
@other_user.followings_activities.each do |activity|
|
53
|
-
puts activity.content[:title.to_s]
|
54
|
-
puts activity.content[:body.to_s]
|
55
|
-
end
|
56
49
|
```
|
57
50
|
|
58
51
|
## Contributing
|
@@ -2,14 +2,6 @@
|
|
2
2
|
class CreateSharpSocial < ActiveRecord::Migration
|
3
3
|
# Create table
|
4
4
|
def self.up
|
5
|
-
create_table :activities do |t|
|
6
|
-
t.references :actor, :polymorphic => true, :null => false
|
7
|
-
t.text :content
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index :activities, [:actor_id, :actor_type]
|
12
|
-
|
13
5
|
create_table :follows, :force => true do |t|
|
14
6
|
t.references :actor, :polymorphic => true, :null => false
|
15
7
|
t.references :follower, :polymorphic => true, :null => false
|
@@ -22,7 +14,6 @@ class CreateSharpSocial < ActiveRecord::Migration
|
|
22
14
|
end
|
23
15
|
|
24
16
|
def self.down
|
25
|
-
drop_table :activities
|
26
17
|
drop_table :follows
|
27
18
|
end
|
28
19
|
end
|
@@ -67,20 +67,6 @@ module SharpSocial
|
|
67
67
|
def followings_count(type=nil)
|
68
68
|
followings(type).count
|
69
69
|
end
|
70
|
-
|
71
|
-
def create_activity(content)
|
72
|
-
Activity.create actor_type: self.class.name, actor_id: self.id, content: content
|
73
|
-
end
|
74
|
-
alias :create_activity! :create_activity
|
75
|
-
|
76
|
-
def activities
|
77
|
-
Activity.where actor_type:self.class.name, actor_id: self.id
|
78
|
-
end
|
79
|
-
|
80
|
-
def followings_activities(type=nil)
|
81
|
-
Activity.where actor_type: type||self.class.name, actor_id: followings(type).map{|f|f.actor_id}
|
82
|
-
end
|
83
|
-
|
84
70
|
end
|
85
71
|
end
|
86
72
|
end
|
data/lib/sharp_social/version.rb
CHANGED
data/sharp_social.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = SharpSocial::VERSION
|
9
9
|
gem.authors = ["sharp"]
|
10
10
|
gem.email = ["liu19850701@gmail.com"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
11
|
+
gem.description = %q{Make actors could follow each other in you application}
|
12
|
+
gem.summary = %q{Make actors could follow each other in you application}
|
13
13
|
gem.homepage = "https://github.com/SharpV/sharp_social"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
data/spec/test_actor_spec.rb
CHANGED
@@ -6,7 +6,6 @@ describe SharpSocial::Mixins::Actor do
|
|
6
6
|
before(:each) do
|
7
7
|
#SharpSocial::Actor.destroy_all
|
8
8
|
User.delete_all
|
9
|
-
Activity.delete_all
|
10
9
|
@user1 = FactoryGirl.create(:user, name: "user one")
|
11
10
|
@user2 = FactoryGirl.create(:user, name: "user two")
|
12
11
|
@user3 = FactoryGirl.create(:user, name: "user three")
|
@@ -59,26 +58,4 @@ describe SharpSocial::Mixins::Actor do
|
|
59
58
|
expect(@user1.followings_count == 1).to be true
|
60
59
|
expect(@user2.followers_count == 1).to be true
|
61
60
|
end
|
62
|
-
|
63
|
-
|
64
|
-
it "can create some activities" do
|
65
|
-
@user1.create_activity title: "post title", body: "post body"
|
66
|
-
@user2.create_activity! title: "post title", body: "post body"
|
67
|
-
expect(@user1.activities.count).to be > 0
|
68
|
-
expect(@user2.activities.count).to eq 1
|
69
|
-
expect(@user3.activities.count).to eq 0
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
it "can see activities of followings" do
|
74
|
-
@user3.follow! @user2
|
75
|
-
@user3.follow! @user1
|
76
|
-
@user1.create_activity title: "post title", body: "post body"
|
77
|
-
@user2.create_activity! title: "post title", body: "post body"
|
78
|
-
expect(@user3.followings_activities.count).to eq 2
|
79
|
-
@user3.followings_activities.each do |activity|
|
80
|
-
expect(activity.content[:title.to_s]).to include("title")
|
81
|
-
expect(activity.content[:body.to_s]).to include("body")
|
82
|
-
end
|
83
|
-
end
|
84
61
|
end
|
data/spec/test_generator_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sharp_social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: factory_girl
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 4.2.0
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 4.2.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec-rails
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: generator_spec
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: shoulda
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,8 +101,13 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Make actors could follow each other in you application
|
81
111
|
email:
|
82
112
|
- liu19850701@gmail.com
|
83
113
|
executables: []
|
@@ -96,13 +126,11 @@ files:
|
|
96
126
|
- Rakefile
|
97
127
|
- lib/generators/sharp_social/USAGE
|
98
128
|
- lib/generators/sharp_social/sharp_social_generator.rb
|
99
|
-
- lib/generators/sharp_social/templates/activity.rb
|
100
129
|
- lib/generators/sharp_social/templates/follow.rb
|
101
130
|
- lib/generators/sharp_social/templates/migration.rb
|
102
131
|
- lib/sharp_social.rb
|
103
132
|
- lib/sharp_social/acts_as_methods.rb
|
104
133
|
- lib/sharp_social/mixins/actor.rb
|
105
|
-
- lib/sharp_social/models/activity.rb
|
106
134
|
- lib/sharp_social/models/follow.rb
|
107
135
|
- lib/sharp_social/railtie.rb
|
108
136
|
- lib/sharp_social/version.rb
|
@@ -116,7 +144,6 @@ files:
|
|
116
144
|
- spec/dummy/app/controllers/application_controller.rb
|
117
145
|
- spec/dummy/app/helpers/application_helper.rb
|
118
146
|
- spec/dummy/app/mailers/.gitkeep
|
119
|
-
- spec/dummy/app/models/activity.rb
|
120
147
|
- spec/dummy/app/models/follow.rb
|
121
148
|
- spec/dummy/app/models/user.rb
|
122
149
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -172,11 +199,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
199
|
version: '0'
|
173
200
|
requirements: []
|
174
201
|
rubyforge_project:
|
175
|
-
rubygems_version: 1.8.
|
202
|
+
rubygems_version: 1.8.25
|
176
203
|
signing_key:
|
177
204
|
specification_version: 3
|
178
|
-
summary:
|
179
|
-
and have activities
|
205
|
+
summary: Make actors could follow each other in you application
|
180
206
|
test_files:
|
181
207
|
- spec/dummy/README.rdoc
|
182
208
|
- spec/dummy/Rakefile
|
@@ -185,7 +211,6 @@ test_files:
|
|
185
211
|
- spec/dummy/app/controllers/application_controller.rb
|
186
212
|
- spec/dummy/app/helpers/application_helper.rb
|
187
213
|
- spec/dummy/app/mailers/.gitkeep
|
188
|
-
- spec/dummy/app/models/activity.rb
|
189
214
|
- spec/dummy/app/models/follow.rb
|
190
215
|
- spec/dummy/app/models/user.rb
|
191
216
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -221,4 +246,3 @@ test_files:
|
|
221
246
|
- spec/spec_helper.rb
|
222
247
|
- spec/test_actor_spec.rb
|
223
248
|
- spec/test_generator_spec.rb
|
224
|
-
has_rdoc:
|