Sha256: 25a7c77bafcb8d97b4877eed2ead56fc063524e23db0c82df07f0155fe42af96

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

module Mina
  module Helpers
    module Internal
      include Helpers::Output

      def deploy_script
        yield
        erb Mina.root_path(fetch(:deploy_script))
      end

      def erb(file, b = binding)
        require 'erb'
        erb = ERB.new(File.read(file))
        erb.result b
      end

      def echo_cmd(code, ignore_verbose = false)
        if fetch(:verbose) && !ignore_verbose
          "echo #{Shellwords.escape('$ ' + code)} &&\n#{code}"
        else
          code
        end
      end

      def indent(count, str)
        str.gsub(/^/, ' ' * count)
      end

      def unindent(code)
        if code =~ /^\n([ \t]+)/
          code = code.gsub(/^#{$1}/, '')
        end

        code.strip
      end

      def report_time
        time_start = Time.now
        output = yield
        print_info "Elapsed time: %.2f seconds" % [Time.now - time_start] unless fetch(:skip_report_time)
        output
      end

      def next_version
        case fetch(:version_scheme)
        when :datetime
          Time.now.utc.strftime("%Y%m%d%H%M%S")
        when :sequence
          "$((`ls -1 #{fetch(:releases_path)} | sort -n | tail -n 1`+1))"
        else
          error! 'Unrecognizes version scheme. Use :datetime or :sequence'
        end
      end

      def error!(message)
        print_error message
        exit 1
      end
    end
  end
end
extend Mina::Helpers::Internal

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mina-1.2.3 lib/mina/helpers/internal.rb
mina-1.2.2 lib/mina/helpers/internal.rb
mina-1.2.1 lib/mina/helpers/internal.rb
mina-1.2.0 lib/mina/helpers/internal.rb
mina-1.1.1 lib/mina/helpers/internal.rb
mina-1.1.0 lib/mina/helpers/internal.rb