Sha256: 7f4fce0d7e19da98dc320958599bfecee9f096c62cc856b07bd1131fe839f779

Contents?: true

Size: 767 Bytes

Versions: 10

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true
namespace :dev do
  desc "Appends chunks to the last deploy, or specify with DEPLOY=id"
  task stream: :environment do
    require 'faker'
    logger = Logger.new(STDOUT)

    deploy = Shipit::Deploy.find(ENV['DEPLOY']) if ENV['DEPLOY']
    deploy ||= Deploy.last

    raise "Couldn't find Deploy" unless deploy

    deploy.update_attribute(:output, nil)

    logger.info("Starting to stream data to deploy ##{deploy.id}")

    loop do
      sentence = Faker::Lorem.sentence.split.map do |word|
        if rand(4).zero?
          "\e[#{rand(30..37)}m#{word}\e[0m"
        else
          word
        end
      end.join(' ')

      logger.error(sentence)

      deploy.chunks.create(text: sentence + "\n")
      sleep 1
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 lib/tasks/dev.rake
shipit-engine-0.38.0 lib/tasks/dev.rake
shipit-engine-0.37.0 lib/tasks/dev.rake
shipit-engine-0.36.1 lib/tasks/dev.rake
shipit-engine-0.36.0 lib/tasks/dev.rake
shipit-engine-0.35.1 lib/tasks/dev.rake
shipit-engine-0.35.0 lib/tasks/dev.rake
shipit-engine-0.34.0 lib/tasks/dev.rake
shipit-engine-0.33.0 lib/tasks/dev.rake
shipit-engine-0.32.0 lib/tasks/dev.rake