Class: RefinerycmsImageRotatorsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/refinerycms_image_rotators_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.



34
35
36
37
38
39
40
41
# File 'lib/generators/refinerycms_image_rotators_generator.rb', line 34

def self.next_migration_number(dirname) #:nodoc:
  next_migration_number = current_migration_number(dirname) + 1
  if ActiveRecord::Base.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

Instance Method Details

#generateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/refinerycms_image_rotators_generator.rb', line 10

def generate
  migration_template('db/migrate/create_image_rotators.rb', 'db/migrate/create_image_rotators.rb')
  %w(
    db/seeds/image_rotators.rb
    public/images/arrows.png
    public/images/bullets.png
    public/images/loading.gif
    public/javascripts/jquery.image-rotators.js
    public/stylesheets/image-rotators.css
  ).each { |path| copy_file path, Rails.root.join(path) }

  puts <<-EOS
------------------------
Now run:
rake db:migrate
------------------------
Put the following in your layout:
stylesheet_link_tag    'image-rotators.css'
javascript_include_tag 'jquery.image-rotators.js'
------------------------
  EOS
end