Module: SimpleDataMigrations::Utils

Defined in:
lib/simple_data_migrations/utils.rb

Class Method Summary collapse

Class Method Details

.humanize_filename(filename) ⇒ Object



21
22
23
24
25
# File 'lib/simple_data_migrations/utils.rb', line 21

def self.humanize_filename(filename)
  return "********** NO FILE **********" unless filename

  filename.delete_prefix(version(filename)).delete_suffix(".rb").humanize
end

.ran_versionsObject



9
10
11
# File 'lib/simple_data_migrations/utils.rb', line 9

def self.ran_versions
  Entry.pluck(:version)
end

.rootObject



13
14
15
# File 'lib/simple_data_migrations/utils.rb', line 13

def self.root
  Rails.root.join("db/data")
end

.script_filesObject



5
6
7
# File 'lib/simple_data_migrations/utils.rb', line 5

def self.script_files
  Dir.children(root).sort
end

.version(filename) ⇒ Object



17
18
19
# File 'lib/simple_data_migrations/utils.rb', line 17

def self.version(filename)
  filename.split("_", 2).first
end