Sha256: 53fbfb37c7352128c06716af0d2148eef572369f723a779fc3f2909bcaaedac4

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

module Bobot
  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)
          if override_if_present_value.present?
            display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value
          else
            ask("           ?  #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value
          end
        end
      end
      module ClassMethods
        def next_migration_number(dirname)
          if ActiveRecord::Base.timestamped_migrations
            migration_number = Time.current.strftime("%Y%m%d%H%M%S").to_i
            migration_number += 1
            migration_number.to_s
          else
            format("%.3d", current_migration_number(dirname) + 1)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bobot-1.0.53 lib/generators/bobot/utils.rb
bobot-1.0.52 lib/generators/bobot/utils.rb