Class: Omnisocial::Generators::OmnisocialGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/omnisocial/omnisocial_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Implement the required interface for Rails::Generators::Migration: github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb



17
18
19
20
21
22
23
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 17

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

.source_rootObject



11
12
13
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 11

def self.source_root
  File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#copy_assetsObject



37
38
39
40
41
42
43
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 37

def copy_assets
  copy_file 'assets/stylesheets/omnisocial.css',  'public/stylesheets/omnisocial.css'
  copy_file 'assets/images/twitter.gif',          'public/images/omnisocial/twitter.gif'
  copy_file 'assets/images/facebook.png',         'public/images/omnisocial/facebook.png'
  copy_file 'assets/images/signin_twitter.png',   'public/images/omnisocial/signin_twitter.png'
  copy_file 'assets/images/signin_facebook.png',  'public/images/omnisocial/signin_facebook.png'
end

#copy_initializerObject



29
30
31
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 29

def copy_initializer
  template 'omnisocial.rb', 'config/initializers/omnisocial.rb'
end

#copy_user_modelObject



33
34
35
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 33

def copy_user_model
  template 'user.rb', 'app/models/user.rb'
end

#create_migration_fileObject



25
26
27
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 25

def create_migration_file
  migration_template 'migration.rb', 'db/migrate/create_omnisocial_tables.rb'
end

#show_readmeObject



45
46
47
# File 'lib/generators/omnisocial/omnisocial_generator.rb', line 45

def show_readme
  readme 'README' if behavior == :invoke
end