Sha256: af636e3d3d0892dd08d649e60907de4b116459ac3a302620ef007133367bc4d3

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

module Deployinator
  module Helpers
    module ViewHelpers

      def username
        @username
      end

      def allowed_to_push_to_prod?
        true
      end

      def groups
        @groups.join(", ")
      end

      def my_url
        "http://#{@host}"
      end

      # TODO: assimilate with plugin
      def logout_url
        raise_event(:logout_url)
      end

      def my_entries
        log_entries(:stack => stack)
      end

      def log_lines
        log_to_hash(:stack => stack)
      end

      def log_to_hash(opts={})
        times = {}
        last_time = 0
        l = log_entries(opts).map do |ll|
          fields = ll.split("|")
          times[fields[1]] ||= []
          times[fields[1]] << fields[0]

          env = fields[1]

          utc_time = Time.parse(fields[0] + "UTC")
          {
            :timestamp => fields[0],
            :time      => utc_time,
            :time_secs => utc_time.to_i,
            :env       => env,
            :who       => fields[2],
            :msg       => hyperlink(fields[3]),
            :old       => fields[3] && fields[3][/old[\s:]*(\w+)/, 1],
            :new       => fields[3] && fields[3][/new[\s:]*(\w+)/, 1],
            :stack     => fields[4],
            :run_log_url => (fields.length < 6) ? false : fields[5],
            :diff_url => true,
            :from_timestamp      => utc_time.to_i - 1800, # + half hour before
            :until_timestamp     => utc_time.to_i + 1800, # + half hour after
            :diff_method => 'diff'
          }
        end
        times.each { |e,t| t.shift }
        l
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
etsy-deployinator-1.1.1 lib/deployinator/helpers/view.rb
etsy-deployinator-1.1.0 lib/deployinator/helpers/view.rb
etsy-deployinator-1.0.2 lib/deployinator/helpers/view.rb
etsy-deployinator-1.0.1 lib/deployinator/helpers/view.rb