Sha256: ea6c7c0910763a0cb588cf0eaaceb26c623cc08e1cb611e1b3361b43a1aa04db

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

module DockerizeRails
  module CommandLineMethods
    require 'colorize'

    # -rubocop:disable Metrics/MethodLength
    def self.invoke(options)
      commands = Helpers.processed_commands
      case options[0]
      when *(commands[:configure])
        return configure options[1][:args]
      when *(commands[:dockerize])
        return dockerize
      when *(commands[:undockerize])
        return undockerize options[1][:args]
      when *(commands[:docker_info])
        return docker_info
      when *(commands[:help])
        return help
      else
        return help 1
      end
    end
    # -rubocop:enable Metrics/MethodLength

    def self.dockerize
      Helpers.ensure_rails_root
      DRNameSpace.load
      ConfigGenerator.dockerize
    end

    def self.undockerize(args)
      Helpers.ensure_rails_root
      ConfigGenerator.undockerize args
    end

    def self.configure(args)
      Helpers.ensure_rails_root
      ConfigGenerator.configure args
    end

    def self.help(status = 0)
      puts "\nCommand not found".red if status != 0
      puts Helpers.help.white
      status
    end

    def self.docker_info
      docker_version = DockerHelper.version

      puts
      Helpers.print_formatted_info 'Docker Version', "#{docker_version['Version']}\n"
      Helpers.print_formatted_info 'API', "#{docker_version['ApiVersion']} : #{docker_version['MinAPIVersion']}\n"
      Helpers.print_formatted_info 'Git Commit', "#{docker_version['GitCommit']}\n"
      Helpers.print_formatted_info 'Go Version', "#{docker_version['GoVersion']}\n"
      # Helpers.print_formatted_info 'OS', "#{v['Os']}_#{v['Arch']}_#{v['KernelVersion']}\n"
      Helpers.print_formatted_info 'Experimental', "#{docker_version['Experimental']}\n"
      Helpers.print_formatted_info 'Build Time',
                                   "#{DateTime.parse(docker_version['BuildTime']).strftime('%b %d, %Y %I:%M %p')}\n"
      puts
      0
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dockerize_rails-1.0.3.beta.3 lib/dockerize_rails/command_line_methods.rb
dockerize_rails-1.0.3.beta.2 lib/dockerize_rails/command_line_methods.rb
dockerize_rails-1.0.3.beta.1 lib/dockerize_rails/command_line_methods.rb