rating/lib/generators/rating/install_generator.rb

25 lines
591 B
Ruby
Raw Normal View History

2017-10-30 01:44:23 +00:00
# frozen_string_literal: true
module Rating
class InstallGenerator < Rails::Generators::Base
2019-10-03 22:07:50 +00:00
source_root File.expand_path('templates', __dir__)
2017-10-30 01:44:23 +00:00
2018-02-08 21:50:11 +00:00
desc 'Creates Rating migration'
2017-10-30 01:44:23 +00:00
def create_migration
template 'db/migrate/create_rating_table.rb', "db/migrate/#{timestamp(0)}_create_rating_table.rb"
template 'db/migrate/create_rate_table.rb', "db/migrate/#{timestamp(1)}_create_rate_table.rb"
2017-11-02 15:30:22 +00:00
end
private
2017-10-30 01:44:23 +00:00
def time
@time ||= Time.current
end
def timestamp(seconds)
(time + seconds.seconds).strftime '%Y%m%d%H%M%S'
2017-10-30 01:44:23 +00:00
end
end
end