lib/localtower/status.rb in localtower-0.4.2 vs lib/localtower/status.rb in localtower-0.5.0

- old
+ new

@@ -1,23 +1,28 @@ module Localtower class Status def run files = Dir["#{Rails.root}/db/migrate/*.rb"].sort.reverse - - names = files.map do |file_full_path| - file_full_path.split("/")[-1] + db_migrations = begin + ActiveRecord::Base.connection.execute("select * from schema_migrations;") + rescue => e + [] end - db_migrations = ActiveRecord::Base.connection.execute("select * from schema_migrations;").map { |e| e["version"].to_s }.sort.reverse + db_migrations = db_migrations.map { |e| e["version"].to_s }.sort.reverse - names.map do |name| - time = name.split("_")[0] + files.map do |file_full_path| + name = file_full_path.split("/")[-1] # add_email_to_user.rb + time = name.split("_")[0] # 201203890987 status = db_migrations.include?(time) ? :done : :todo + content = File.open(file_full_path).read { + "file_full_path" => file_full_path, "name" => name, - "time" => time, + "time" => time.to_i, "status" => status, + "content" => content } end end end end