Sha256: d7ab78c3c397b53b20d03a0fd48329149a3b0bbde8ccea184d48176336040561

Contents?: true

Size: 1.42 KB

Versions: 14

Compression:

Stored size: 1.42 KB

Contents

require_relative './logging'
module CapistranoSentinel
  # class that holds the options that are configurable for this gem
  module ApplicationHelper
    include CapistranoSentinel::Logging
    module_function

    # Method that is used to parse a string as JSON , if it fails will return nil
    # @see JSON#parse
    # @param [string] res The string that will be parsed as JSON
    # @return [Hash, nil] Returns Hash object if the json parse succeeds or nil otherwise
    def parse_json(res)
      return if res.blank?
      JSON.parse(res)
    rescue JSON::ParserError
      nil
    end


    def msg_for_stdin?(message)
      message['action'] == 'stdin'
    end

    def message_is_for_stdout?(message)
      message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
    end

    def message_is_about_a_task?(message)
      message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'invoke'
    end

    def message_from_bundler?(message)
      message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'bundle_install'
    end

    def get_question_details(data)
      matches = /(.*)\?*\s*\:*\s*(\([^)]*\))*/m.match(data).captures
      [matches[0], matches[1]]
    end


  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
capistrano_sentinel-0.2.3 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.2.2 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.2.1 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.2.0 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.1.1 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.1.0 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.18 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.17 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.16 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.15 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.14 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.12 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.10 lib/capistrano_sentinel/helpers/application_helper.rb
capistrano_sentinel-0.0.9 lib/capistrano_sentinel/helpers/application_helper.rb