Sha256: 8faa10701c316dfafd03d5b4b7a2b0283891f5679af9a4d4d616084b0251924b

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

module RailsAdmin
  module Generators
    module Utils
      module InstanceMethods
        def display(output, color = :green)
          say("           -  #{output}", color)
        end

        def ask_for(wording, default_value = nil, override_if_present_value = nil)
          override_if_present_value.present? ?
            display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value :
            ask("           ?  #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value
        end
      end

      module ClassMethods
        def next_migration_number(dirname)
          if ActiveRecord::Base.timestamped_migrations
            migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
            migration_number += 1
            migration_number.to_s
          else
            "%.3d" % (current_migration_number(dirname) + 1)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elucid-rails_admin-0.0.1 lib/generators/rails_admin/utils.rb