Skip to content

Commit

Permalink
Plugin and Engine support, hook_for devise:install generator
Browse files Browse the repository at this point in the history
  • Loading branch information
atd committed Oct 15, 2010
1 parent e54c3cd commit beff4d6
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
pkg/*gem
14 changes: 5 additions & 9 deletions README.rdoc
Expand Up @@ -22,20 +22,15 @@ application towards a well-known compatible data model design.


= Installation = Installation


It requires Rails 3. A gem for strength hierarchies in relations is required. Add to your Gemfile: Add to your Gemfile:


gem 'atd-ancestry', :require => 'ancestry' gem 'social_stream'
gem 'devise'


and and run:


bundle update bundle update


Then install the plugin with: Then, execute:

rails plugin install http://github.com/ging/social_stream.git

And run:


rails generate social_stream:install rails generate social_stream:install


Expand All @@ -45,6 +40,7 @@ This will generate the following:
* A database seeds file for defining Social Stream relations. You must add: * A database seeds file for defining Social Stream relations. You must add:
SocialStream.seed! SocialStream.seed!
to your db/seeds.rb to your db/seeds.rb
* A devise:install generation for authentication support


== Actors and Activity Objects == Actors and Activity Objects


Expand Down
14 changes: 10 additions & 4 deletions Rakefile
Expand Up @@ -6,6 +6,9 @@ require 'rake/gempackagetask'
require 'rspec/core' require 'rspec/core'
require 'rspec/core/rake_task' require 'rspec/core/rake_task'


require File.join(File.dirname(__FILE__), 'lib', 'social_stream', 'version')


Rspec::Core::RakeTask.new(:spec) do |t| Rspec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ["--color"] t.rspec_opts = ["--color"]
end end
Expand All @@ -22,16 +25,19 @@ end


spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.name = "social_stream" s.name = "social_stream"
s.version = SocialStream::VERSION.dup
s.summary = "Social networking features and activity streams." s.summary = "Social networking features and activity streams."
s.description = "Ruby on Rails plug-in supporting social networking features and activity streams." s.description = "Ruby on Rails plug-in supporting social networking features and activity streams."
s.files = FileList["[A-Z]*", "lib/**/*"] s.authors = ['Antonio Tapiador', 'Diego Carrera']
s.version = "0.0.1" s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
s.add_dependency('atd-ancestry', '~> 1.3.0')
s.add_dependency('devise', '~> 1.1.3')
end end


Rake::GemPackageTask.new(spec) do |pkg| Rake::GemPackageTask.new(spec) do |pkg|
end end


desc "Install the gem #{spec.name}-#{spec.version}.gem" desc "Install the gem #{spec.name}-#{spec.version}.gem"
task :install do task :install => :gem do
system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc") system("sudo gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
end end
6 changes: 2 additions & 4 deletions init.rb
@@ -1,5 +1,3 @@
ActiveSupport::Inflector.inflections do |inflect|
inflect.singular /^([Tt]ie)s$/, '\1'
end

require 'social_stream' require 'social_stream'

SocialStream::Rails::Common.inflections
1 change: 1 addition & 0 deletions lib/generators/social_stream/install_generator.rb
Expand Up @@ -22,4 +22,5 @@ def create_migration_file
migration_template 'migration.rb', 'db/migrate/create_social_stream.rb' migration_template 'migration.rb', 'db/migrate/create_social_stream.rb'
end end


hook_for :authentication
end end
11 changes: 9 additions & 2 deletions lib/social_stream.rb
@@ -1,8 +1,13 @@
require 'social_stream/railtie'
require 'social_stream/seed' require 'social_stream/seed'


# Provides your Rails application with social network and activity stream support # Provides your Rails application with social network and activity stream support
module SocialStream module SocialStream
module Models
autoload :Supertype, 'social_stream/models/supertype'
autoload :Actor, 'social_stream/models/actor'
autoload :ActivityObject, 'social_stream/models/activity_object'
end

mattr_accessor :actors mattr_accessor :actors
@@actors = [] @@actors = []


Expand All @@ -15,7 +20,9 @@ def setup
end end


def seed! def seed!
Seed.new("#{ Rails.root }/db/seeds/social_stream.yml") Seed.new("#{ ::Rails.root }/db/seeds/social_stream.yml")
end end
end end
end end

require 'social_stream/rails'
10 changes: 10 additions & 0 deletions lib/social_stream/rails.rb
@@ -0,0 +1,10 @@
require 'social_stream/rails/common'
File.expand_path(__FILE__) =~ /#{ File.join('vendor', 'plugins') }/ ?
require('social_stream/rails/railtie') :
require('social_stream/rails/engine')

module SocialStream
# Common methods for Railtie and Engine
module Rails #:nodoc:
end
end
34 changes: 34 additions & 0 deletions lib/social_stream/rails/common.rb
@@ -0,0 +1,34 @@
module SocialStream
module Rails
# Common methods for Rails::Railtie and Rails::Engine
module Common #:nodoc:
class << self
def inflections
ActiveSupport::Inflector.inflections do |inflect|
inflect.singular /^([Tt]ie)s$/, '\1'
end
end

def included(base)
base.class_eval do
config.generators.authentication :devise

config.to_prepare do
%w( actor activity_object ).each do |supertype|
supertype.classify.constantize.load_subtype_features
end

# https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
ApplicationController.helper ActivitiesHelper
end

initializer "social_stream.inflections" do
Common.inflections
end
end
end
end
end
end
end

7 changes: 7 additions & 0 deletions lib/social_stream/rails/engine.rb
@@ -0,0 +1,7 @@
module SocialStream
module Rails
class Engine < ::Rails::Engine #:nodoc:
include Common
end
end
end
7 changes: 7 additions & 0 deletions lib/social_stream/rails/railtie.rb
@@ -0,0 +1,7 @@
module SocialStream
module Rails
class Railtie < ::Rails::Railtie #:nodoc:
include Common
end
end
end
14 changes: 0 additions & 14 deletions lib/social_stream/railtie.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/social_stream/version.rb
@@ -0,0 +1,3 @@
module SocialStream
VERSION = "0.0.1".freeze
end

0 comments on commit beff4d6

Please sign in to comment.