class TokyoMetro::Rake::Rails::Deploy::Heroku::Csv::Command::MetaClass

Attributes

time[R]

Public Class Methods

new( time = nil ) click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 3
def initialize( time = nil )
  # tables_from_file = ::File.open( "#{ ::Rails.root }/db/tables.txt" , "r:utf-8" ).read
  tables_from_file = ::ActiveRecord::Base.connection.tables.sort
  # tables_from_file = open( "#{ ::Rails.root }/db/tables.txt" , "r:utf-8" ).read.split( /\n/ )

  @tables = tables_from_file.map { | table | Table.new( table ) }
  @commands = ::Array.new
  set_time( time )
  optional_setting_of_initializer
  ::FileUtils.mkdir_p( @dirname ) unless ::Dir.exist?( @dirname )

  puts "-" * 32 + " Time: #{ @time }"
  puts "-" * 32 + " Dirname: #{ @dirname }"
  puts ""
end

Public Instance Methods

to_s() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 21
def to_s
  set_first_settings_to_s
  set_commands_for_db

  @commands.flatten
end

Private Instance Methods

first_settings() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 41
def first_settings
  nil
end
optional_setting_of_initializer() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 55
def optional_setting_of_initializer
  raise "Error: This method \'#{ __method__ }\' is not defined yet in this class \'#{ self.class.name }\'."
end
set_commands_for_db() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 63
def set_commands_for_db
  raise "Error: This method \'#{ __method__ }\' is not defined yet in this class \'#{ self.class.name }\'."
end
set_first_settings_to_s() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 49
def set_first_settings_to_s
  if first_settings.present?
    @commands << [ first_settings ].flatten
  end
end
set_time( time , require_time: true ) click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 30
def set_time( time , require_time: true )
  if time.present?
    raise "Error" unless /\A\d{14}\Z/ === time or /\A\d{8}_\d{6}\Z/ === time
    @time = time.gsub( "_" , "" )
  elsif require_time
    raise "Error: The variable \#1 \'time\' is not defined."
  else
    @time = ::Time.now.strftime( "%Y%m%d%H%M%S" )
  end
end
tables_names_added_to_db() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 59
def tables_names_added_to_db
  raise "Error: This method \'#{ __method__ }\' is not defined yet in this class \'#{ self.class.name }\'."
end
tables_without_schema_migrations() click to toggle source
# File lib/tokyo_metro/rake/rails/deploy/heroku/csv/command/meta_class.rb, line 45
def tables_without_schema_migrations
  @tables.delete_if( &:schema_migrations? )
end