module DockerizeRails::Helpers
Public Class Methods
ensure_rails_root()
click to toggle source
# File lib/dockerize_rails/helpers.rb, line 27 def self.ensure_rails_root unless PATHS.rails_root? puts "\n'#{`pwd`.strip}' is not a rails application root.\n".red exit(1) end 0 end
help()
click to toggle source
-rubocop:disable Metrics/MethodLength -rubocop:disable Metrics/AbcSize
# File lib/dockerize_rails/helpers.rb, line 48 def self.help [' Usage: dock <command> or: bundle exec dock <command> commands: ', Constants::COMMANDS.keys.map do |key| command = Constants::COMMANDS[key] " #{command[:aliases].map(&:to_s).join(', ').ljust(30, ' ')}" \ " - #{command[:help]}" + params_help(command) end, ' '].join("\n") end
parse_opts()
click to toggle source
# File lib/dockerize_rails/helpers.rb, line 12 def self.parse_opts options = { tiny: false, purge: false, test_env: false } parser = OptionParser.new do |opts| opts.on('--tiny') { options[:tiny] = true } opts.on('--purge') { options[:purge] = true } opts.on('--test-env') { options[:test_env] = true } opts.on('--delete') { options[:delete_containers] = true } opts.on('--log') { options[:stream_log] = true } opts.on('--rebuild') { options[:rebuild] = true } opts.on('--force') { options[:force] = true } end parser.parse! [ARGV[0].to_s, args: options] end
print_formatted_info(name, value)
click to toggle source
-rubocop:enable Metrics/MethodLength -rubocop:enable Metrics/MethodLength
# File lib/dockerize_rails/helpers.rb, line 66 def self.print_formatted_info(name, value) print name.ljust(15, ' ').yellow, value.blue end
processed_commands()
click to toggle source
# File lib/dockerize_rails/helpers.rb, line 6 def self.processed_commands Hash[Constants::COMMANDS.keys.map do |key| [key, Constants::COMMANDS[key][:aliases].map(&:to_s)] end] end
Private Class Methods
params_help(command)
click to toggle source
# File lib/dockerize_rails/helpers.rb, line 35 def self.params_help(command) if command.key? :params [command[:params].keys.map do |param| "\n #{('[' + param.to_s + ']').ljust(15, ' ')} -- #{command[:params][param]}" end, "\n"].join else '' end end