Permalink
Browse files

Plugin and Engine support, hook_for devise:install generator

  • Loading branch information...
atd committed Oct 15, 2010
1 parent e54c3cd commit beff4d69ee336ce5e86f89d095bddf080ef27556
View
@@ -0,0 +1 @@
+pkg/*gem
View
@@ -22,20 +22,15 @@ application towards a well-known compatible data model design.
= 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 'devise'
+ gem 'social_stream'
-and
+and run:
bundle update
-Then install the plugin with:
-
- rails plugin install http://github.com/ging/social_stream.git
-
-And run:
+Then, execute:
rails generate social_stream:install
@@ -45,6 +40,7 @@ This will generate the following:
* A database seeds file for defining Social Stream relations. You must add:
SocialStream.seed!
to your db/seeds.rb
+* A devise:install generation for authentication support
== Actors and Activity Objects
View
@@ -6,6 +6,9 @@ require 'rake/gempackagetask'
require 'rspec/core'
require 'rspec/core/rake_task'
+require File.join(File.dirname(__FILE__), 'lib', 'social_stream', 'version')
+
+
Rspec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ["--color"]
end
@@ -22,16 +25,19 @@ end
spec = Gem::Specification.new do |s|
s.name = "social_stream"
+ s.version = SocialStream::VERSION.dup
s.summary = "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.version = "0.0.1"
+ s.authors = ['Antonio Tapiador', 'Diego Carrera']
+ s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
+ s.add_dependency('atd-ancestry', '~> 1.3.0')
+ s.add_dependency('devise', '~> 1.1.3')
end
Rake::GemPackageTask.new(spec) do |pkg|
end
desc "Install the gem #{spec.name}-#{spec.version}.gem"
-task :install do
- system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
+task :install => :gem do
+ system("sudo gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
end
View
@@ -1,5 +1,3 @@
-ActiveSupport::Inflector.inflections do |inflect|
- inflect.singular /^([Tt]ie)s$/, '\1'
-end
-
require 'social_stream'
+
+SocialStream::Rails::Common.inflections
@@ -22,4 +22,5 @@ def create_migration_file
migration_template 'migration.rb', 'db/migrate/create_social_stream.rb'
end
+ hook_for :authentication
end
View
@@ -1,8 +1,13 @@
-require 'social_stream/railtie'
require 'social_stream/seed'
# Provides your Rails application with social network and activity stream support
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
@@actors = []
@@ -15,7 +20,9 @@ def setup
end
def seed!
- Seed.new("#{ Rails.root }/db/seeds/social_stream.yml")
+ Seed.new("#{ ::Rails.root }/db/seeds/social_stream.yml")
end
end
end
+
+require 'social_stream/rails'
View
@@ -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
@@ -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
+
@@ -0,0 +1,7 @@
+module SocialStream
+ module Rails
+ class Engine < ::Rails::Engine #:nodoc:
+ include Common
+ end
+ end
+end
@@ -0,0 +1,7 @@
+module SocialStream
+ module Rails
+ class Railtie < ::Rails::Railtie #:nodoc:
+ include Common
+ end
+ end
+end
@@ -1,14 +0,0 @@
-module SocialStream
- class Railtie < Rails::Railtie
- 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
- end
-end
@@ -0,0 +1,3 @@
+module SocialStream
+ VERSION = "0.0.1".freeze
+end

0 comments on commit beff4d6

Please sign in to comment.