sharp_social 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +136 -0
  6. data/Guardfile +27 -0
  7. data/LICENSE.txt +22 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +64 -0
  10. data/Rakefile +38 -0
  11. data/lib/generators/sharp_social/USAGE +8 -0
  12. data/lib/generators/sharp_social/sharp_social_generator.rb +14 -0
  13. data/lib/generators/sharp_social/templates/activity.rb +2 -0
  14. data/lib/generators/sharp_social/templates/follow.rb +10 -0
  15. data/lib/generators/sharp_social/templates/migration.rb +28 -0
  16. data/lib/sharp_social/acts_as_methods.rb +14 -0
  17. data/lib/sharp_social/mixins/actor.rb +87 -0
  18. data/lib/sharp_social/models/activity.rb +8 -0
  19. data/lib/sharp_social/models/follow.rb +7 -0
  20. data/lib/sharp_social/railtie.rb +9 -0
  21. data/lib/sharp_social/version.rb +3 -0
  22. data/lib/sharp_social.rb +12 -0
  23. data/lib/tasks/sharp_social_tasks.rake +4 -0
  24. data/script/rails +8 -0
  25. data/sharp_social.gemspec +26 -0
  26. data/spec/dummy/README.rdoc +261 -0
  27. data/spec/dummy/Rakefile +7 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/app/mailers/.gitkeep +0 -0
  33. data/spec/dummy/app/models/activity.rb +3 -0
  34. data/spec/dummy/app/models/follow.rb +10 -0
  35. data/spec/dummy/app/models/user.rb +5 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/spec/dummy/config/application.rb +65 -0
  38. data/spec/dummy/config/boot.rb +10 -0
  39. data/spec/dummy/config/database.yml +25 -0
  40. data/spec/dummy/config/environment.rb +5 -0
  41. data/spec/dummy/config/environments/development.rb +37 -0
  42. data/spec/dummy/config/environments/production.rb +67 -0
  43. data/spec/dummy/config/environments/test.rb +37 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/inflections.rb +15 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  48. data/spec/dummy/config/initializers/session_store.rb +8 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/spec/dummy/config/locales/en.yml +5 -0
  51. data/spec/dummy/config/routes.rb +58 -0
  52. data/spec/dummy/config.ru +4 -0
  53. data/spec/dummy/db/migrate/20130416061349_create_posts.rb +10 -0
  54. data/spec/dummy/db/migrate/20130416061831_create_users.rb +8 -0
  55. data/spec/dummy/db/migrate/20130423080539_create_sharp_social.rb +28 -0
  56. data/spec/dummy/db/schema.rb +53 -0
  57. data/spec/dummy/db/test.sqlite3 +0 -0
  58. data/spec/dummy/lib/assets/.gitkeep +0 -0
  59. data/spec/dummy/log/.gitkeep +0 -0
  60. data/spec/dummy/public/404.html +26 -0
  61. data/spec/dummy/public/422.html +26 -0
  62. data/spec/dummy/public/500.html +25 -0
  63. data/spec/dummy/public/favicon.ico +0 -0
  64. data/spec/dummy/script/rails +6 -0
  65. data/spec/factories.rb +6 -0
  66. data/spec/spec_helper.rb +41 -0
  67. data/spec/test_actor_spec.rb +84 -0
  68. data/spec/test_generator_spec.rb +20 -0
  69. metadata +224 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.log
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ script: bundle exec rspec spec
6
+ before_script:
7
+ - pwd
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ #source 'https://rubygems.org'
2
+ source 'http://ruby.taobao.org'
3
+
4
+ gem 'rails', '>= 3.2.0'
5
+
6
+ group :development do
7
+ #gem 'factory_girl_rails'
8
+ gem 'travis-lint'
9
+ end
10
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sharp_social (0.0.1)
5
+
6
+ GEM
7
+ remote: http://ruby.taobao.org/
8
+ specs:
9
+ actionmailer (3.2.13)
10
+ actionpack (= 3.2.13)
11
+ mail (~> 2.5.3)
12
+ actionpack (3.2.13)
13
+ activemodel (= 3.2.13)
14
+ activesupport (= 3.2.13)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.5)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activemodel (3.2.13)
23
+ activesupport (= 3.2.13)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.13)
26
+ activemodel (= 3.2.13)
27
+ activesupport (= 3.2.13)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.13)
31
+ activemodel (= 3.2.13)
32
+ activesupport (= 3.2.13)
33
+ activesupport (3.2.13)
34
+ i18n (= 0.6.1)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ bourne (1.4.0)
38
+ mocha (~> 0.13.2)
39
+ builder (3.0.4)
40
+ diff-lcs (1.2.4)
41
+ erubis (2.7.0)
42
+ factory_girl (4.2.0)
43
+ activesupport (>= 3.0.0)
44
+ generator_spec (0.8.7)
45
+ activerecord (>= 3.0, < 4.0)
46
+ railties (>= 3.0, < 4.0)
47
+ hashr (0.0.22)
48
+ hike (1.2.2)
49
+ i18n (0.6.1)
50
+ journey (1.0.4)
51
+ json (1.7.7)
52
+ mail (2.5.3)
53
+ i18n (>= 0.4.0)
54
+ mime-types (~> 1.16)
55
+ treetop (~> 1.4.8)
56
+ metaclass (0.0.1)
57
+ mime-types (1.23)
58
+ mocha (0.13.3)
59
+ metaclass (~> 0.0.1)
60
+ multi_json (1.7.2)
61
+ polyglot (0.3.3)
62
+ rack (1.4.5)
63
+ rack-cache (1.2)
64
+ rack (>= 0.4)
65
+ rack-ssl (1.3.3)
66
+ rack
67
+ rack-test (0.6.2)
68
+ rack (>= 1.0)
69
+ rails (3.2.13)
70
+ actionmailer (= 3.2.13)
71
+ actionpack (= 3.2.13)
72
+ activerecord (= 3.2.13)
73
+ activeresource (= 3.2.13)
74
+ activesupport (= 3.2.13)
75
+ bundler (~> 1.0)
76
+ railties (= 3.2.13)
77
+ railties (3.2.13)
78
+ actionpack (= 3.2.13)
79
+ activesupport (= 3.2.13)
80
+ rack-ssl (~> 1.3.2)
81
+ rake (>= 0.8.7)
82
+ rdoc (~> 3.4)
83
+ thor (>= 0.14.6, < 2.0)
84
+ rake (10.0.4)
85
+ rdoc (3.12.2)
86
+ json (~> 1.4)
87
+ rspec (2.13.0)
88
+ rspec-core (~> 2.13.0)
89
+ rspec-expectations (~> 2.13.0)
90
+ rspec-mocks (~> 2.13.0)
91
+ rspec-core (2.13.1)
92
+ rspec-expectations (2.13.0)
93
+ diff-lcs (>= 1.1.3, < 2.0)
94
+ rspec-mocks (2.13.1)
95
+ rspec-rails (2.13.0)
96
+ actionpack (>= 3.0)
97
+ activesupport (>= 3.0)
98
+ railties (>= 3.0)
99
+ rspec-core (~> 2.13.0)
100
+ rspec-expectations (~> 2.13.0)
101
+ rspec-mocks (~> 2.13.0)
102
+ shoulda (3.4.0)
103
+ shoulda-context (~> 1.0, >= 1.0.1)
104
+ shoulda-matchers (~> 1.0, >= 1.4.1)
105
+ shoulda-context (1.1.1)
106
+ shoulda-matchers (1.5.6)
107
+ activesupport (>= 3.0.0)
108
+ bourne (~> 1.3)
109
+ sprockets (2.2.2)
110
+ hike (~> 1.2)
111
+ multi_json (~> 1.0)
112
+ rack (~> 1.0)
113
+ tilt (~> 1.1, != 1.3.0)
114
+ sqlite3 (1.3.7)
115
+ thor (0.18.1)
116
+ tilt (1.3.7)
117
+ travis-lint (1.7.0)
118
+ hashr (~> 0.0.22)
119
+ treetop (1.4.12)
120
+ polyglot
121
+ polyglot (>= 0.3.1)
122
+ tzinfo (0.3.37)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ factory_girl (>= 4.2.0)
129
+ generator_spec
130
+ rails (>= 3.2.0)
131
+ rspec
132
+ rspec-rails
133
+ sharp_social!
134
+ shoulda
135
+ sqlite3
136
+ travis-lint
data/Guardfile ADDED
@@ -0,0 +1,27 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
5
+ watch('config/application.rb')
6
+ watch('config/environment.rb')
7
+ watch('config/environments/test.rb')
8
+ watch(%r{^config/initializers/.+\.rb$})
9
+ watch('Gemfile')
10
+ watch('Gemfile.lock')
11
+ watch('spec/spec_helper.rb') { :rspec }
12
+ watch('test/test_helper.rb') { :test_unit }
13
+ watch(%r{features/support/}) { :cucumber }
14
+ end
15
+
16
+ guard 'rspec' do
17
+ watch(%r{^spec/.+_spec\.rb$})
18
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
19
+ watch('spec/spec_helper.rb') { "spec" }
20
+
21
+ # Rails example
22
+ watch(%r{^spec/dummy/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
23
+ watch(%r{^spec/dummy/app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
24
+ watch(%r{^spec/dummy/app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
25
+
26
+ end
27
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 sharp
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
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.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # SharpSocial
2
+
3
+ [![Build Status](https://travis-ci.org/SharpV/sharp_social.png?branch=master)](https://travis-ci.org/SharpV/sharp_social)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sharp_social'
10
+
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+ $ rails g sharp_social install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sharp_social
20
+
21
+ ## Usage
22
+
23
+ ### setup
24
+
25
+ Add `acts_as_actor` to your model which need to act as an actor
26
+
27
+ ```ruby
28
+ class User < ActiveRecord::Base
29
+ ...
30
+ acts_as_followable
31
+ ...
32
+ end
33
+ ```
34
+
35
+ ### API
36
+
37
+ ```ruby
38
+ @user.follow(@other_user)
39
+ @user.is_following?(@other_user) => true
40
+ @other_user.is_follow_by(@user) => true
41
+
42
+ @user.followings_count => 1
43
+ @other_user.follower_count => 1
44
+
45
+ @other_user.follow!(@user)
46
+ @other_user.is_friend(@other_user) => true
47
+ @user.is_friend?(@other_user) => true
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
+ ```
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError
8
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
9
+ end
10
+ begin
11
+ require 'rdoc/task'
12
+ rescue LoadError
13
+ require 'rdoc/rdoc'
14
+ require 'rake/rdoctask'
15
+ RDoc::Task = Rake::RDocTask
16
+ end
17
+
18
+ RDoc::Task.new(:rdoc) do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = 'SharpSocial'
21
+ rdoc.options << '--line-numbers'
22
+ rdoc.rdoc_files.include('README.rdoc')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate sharp_social Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,14 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ class SharpSocialGenerator < ActiveRecord::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def generate_model
7
+ copy_file 'activity.rb', "app/models/activity.rb"
8
+ copy_file 'follow.rb', "app/models/follow.rb"
9
+ end
10
+
11
+ def generate_migration
12
+ migration_template 'migration.rb', "db/migrate/create_sharp_social"
13
+ end
14
+ end
@@ -0,0 +1,2 @@
1
+ class Activity < SharpSocial::Models::Activity
2
+ end
@@ -0,0 +1,10 @@
1
+ class Follow < SharpSocial::Models::Follow
2
+
3
+ belongs_to :actor, polymorphic: true
4
+ belongs_to :follower, polymorphic: true
5
+
6
+ def block!
7
+ self.update_attribute(:blocked, true)
8
+ end
9
+
10
+ end
@@ -0,0 +1,28 @@
1
+ # Migration responsible for creating a table with activities
2
+ class CreateSharpSocial < ActiveRecord::Migration
3
+ # Create table
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
+ create_table :follows, :force => true do |t|
14
+ t.references :actor, :polymorphic => true, :null => false
15
+ t.references :follower, :polymorphic => true, :null => false
16
+ t.boolean :blocked, :default => false, :null => false
17
+ t.timestamps
18
+ end
19
+
20
+ add_index :follows, ["actor_id", "actor_type"]
21
+ add_index :follows, ["follower_id", "follower_type"]
22
+ end
23
+
24
+ def self.down
25
+ drop_table :activities
26
+ drop_table :follows
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ require 'active_support/concern'
2
+
3
+ module SharpSocial
4
+ module ActsAsMethods
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ def acts_as_actor(opts = {})
9
+ include SharpSocial::Mixins::Actor
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,87 @@
1
+ module ActiveRecord
2
+ class Base
3
+ def is_actor?
4
+ false
5
+ end
6
+ alias :is_actor :is_actor?
7
+ end
8
+ end
9
+
10
+ module SharpSocial
11
+ module Mixins
12
+ module Actor
13
+ extend ActiveSupport::Concern
14
+
15
+ included do
16
+ #after_destroy { SharpSocial.follow_model.remove_followables(self) }
17
+
18
+ def is_actor?
19
+ true
20
+ end
21
+ alias :is_actor :is_actor?
22
+
23
+ def follow(actor)
24
+ raise ArgumentError, "#{followable} is not an actor!" unless actor.respond_to?(:is_actor?)
25
+ Follow.where(actor_id: actor.id, actor_type: actor.class.name, follower_id: self.id, follower_type: self.class.name).first_or_create
26
+ end
27
+ alias :follow! :follow
28
+
29
+ def unfollow(actor)
30
+ raise ArgumentError, "#{followable} is not artor!" unless actor.respond_to?(:is_actor?)
31
+ if follow = Follow.where(actor_id: actor.id, actor_type: actor.class.name, follower_id: self.id, follower_type: self.class.name).first
32
+ follow.destroy
33
+ end
34
+ end
35
+ alias :unfollow! :unfollow
36
+
37
+ def is_followed(follower)
38
+ Follow.where(actor_id: self.id, actor_type: self.class.name, follower_id: follower.id, follower_type: follower.class.name).first
39
+ end
40
+ alias :is_followed? :is_followed
41
+
42
+ def is_following(actor)
43
+ raise ArgumentError, "#{followable} is not artor!" unless actor.respond_to?(:is_actor?)
44
+ actor.is_followed? self
45
+ end
46
+ alias :is_following? :is_following
47
+
48
+ def is_friend(actor)
49
+ actor.is_followed(self) and self.is_followed(actor)
50
+ end
51
+ alias :is_friend? :is_friend
52
+
53
+ def followers(type=nil)
54
+ type = type || self.class.name
55
+ Follow.where(actor_id: self.id, actor_type: self.class.name, follower_type: type)
56
+ end
57
+
58
+ def followings(type=nil)
59
+ type ||= self.class.name
60
+ Follow.where(follower_id: self.id, follower_type: self.class.name, actor_type: type)
61
+ end
62
+
63
+ def followers_count(type=nil)
64
+ followers(type).count
65
+ end
66
+
67
+ def followings_count(type=nil)
68
+ followings(type).count
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
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,8 @@
1
+ module SharpSocial
2
+ module Models
3
+ class Activity < ActiveRecord::Base
4
+ attr_accessible :actor_type, :actor_id, :content
5
+ serialize :content, JSON
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module SharpSocial
2
+ module Models
3
+ class Follow < ActiveRecord::Base
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module SharpSocial
2
+ class Railtie < Rails::Engine
3
+ initializer "my_railtie.configure_rails_initialization" do |app|
4
+ ActiveSupport.on_load :active_record do
5
+ ActiveRecord::Base.send :include, SharpSocial::ActsAsMethods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module SharpSocial
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ #$LOAD_PATH.unshift(File.dirname(__FILE__))
2
+
3
+ %w(
4
+ mixins/*.rb
5
+ models/*.rb
6
+ *.rb
7
+ ).each do |path|
8
+ Dir["#{File.dirname(__FILE__)}/sharp_social/#{path}"].each { |f| require(f) }
9
+ end
10
+
11
+ module SharpSocial
12
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :sharp_social do
3
+ # # Task goes here
4
+ # end
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/sharp_social/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sharp_social/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "sharp_social"
8
+ gem.version = SharpSocial::VERSION
9
+ gem.authors = ["sharp"]
10
+ gem.email = ["liu19850701@gmail.com"]
11
+ gem.description = %q{Social engine backed by Riak}
12
+ gem.summary = %q{Social engine backed by Riak, make your actors can follow, like, mention and have activities}
13
+ gem.homepage = "https://github.com/SharpV/sharp_social"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "sqlite3"
21
+ gem.add_development_dependency "factory_girl", '>= 4.2.0'
22
+ gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "rspec-rails"
24
+ gem.add_development_dependency "generator_spec"
25
+ gem.add_development_dependency "shoulda"
26
+ end