<commit_before>module Cfer::Core

  # Defines the structure of a CloudFormation stack
  class Stack < Cfer::Block
    include Cfer::Core
    include Cfer::Cfn

    # The parameters strictly as passed via command line
    attr_reader :input_parameters

    # The fully resolved parameters, including defaults and parameters fetched from an existing stack during an update
    attr_reader :parameters

    attr_reader :options

    def converge!
      if @options[:client]
        @options[:client].converge self
      end
    end

    def tail!(&block)
      if @options[:client]
        @options[:client].tail self, &block
      end
    end

    def initialize(options = {})
      self[:AWSTemplateFormatVersion] = '2010-09-09'
      self[:Description] = ''

      @options = options

      self[:Metadata] = {
        :Cfer => {
          :Version => Cfer::SEMANTIC_VERSION.to_h.delete_if { |k, v| v === nil }
        }
      }

      self[:Parameters] = {}
      self[:Mappings] = {}
      self[:Conditions] = {}
      self[:Resources] = {}
      self[:Outputs] = {}

      if git = options[:client].git
        self[:Metadata][:Cfer][:Git] = {
          Rev: git.object('HEAD^').sha,
          Clean: git.status.changed.empty?
        }
      end

      @parameters = HashWithIndifferentAccess.new
      @input_parameters = HashWithIndifferentAccess.new

      if options[:client]
        begin
          @parameters.merge! options[:client].fetch_parameters
        rescue Cfer::Util::StackDoesNotExistError
          Cfer::LOGGER.debug "Can't include current stack parameters because the stack doesn't exist yet."
        end
      end

      if options[:parameters]
        options[:parameters].each do |key, val|
          @input_parameters[key] = @parameters[key] = val
        end
      end
    end<commit_msg>Bugfix for when there is no client<commit_after>module Cfer::Core

  # Defines the structure of a CloudFormation stack
  class Stack < Cfer::Block
    include Cfer::Core
    include Cfer::Cfn

    # The parameters strictly as passed via command line
    attr_reader :input_parameters

    # The fully resolved parameters, including defaults and parameters fetched from an existing stack during an update
    attr_reader :parameters

    attr_reader :options

    def converge!
      if @options[:client]
        @options[:client].converge self
      end
    end

    def tail!(&block)
      if @options[:client]
        @options[:client].tail self, &block
      end
    end

    def initialize(options = {})
      self[:AWSTemplateFormatVersion] = '2010-09-09'
      self[:Description] = ''

      @options = options

      self[:Metadata] = {
        :Cfer => {
          :Version => Cfer::SEMANTIC_VERSION.to_h.delete_if { |k, v| v === nil }
        }
      }

      self[:Parameters] = {}
      self[:Mappings] = {}
      self[:Conditions] = {}
      self[:Resources] = {}
      self[:Outputs] = {}

      if options[:client] && git = options[:client].git
        self[:Metadata][:Cfer][:Git] = {
          Rev: git.object('HEAD^').sha,
          Clean: git.status.changed.empty?
        }
      end

      @parameters = HashWithIndifferentAccess.new
      @input_parameters = HashWithIndifferentAccess.new

      if options[:client]
        begin
          @parameters.merge! options[:client].fetch_parameters
        rescue Cfer::Util::StackDoesNotExistError
          Cfer::LOGGER.debug "Can't include current stack parameters because the stack doesn't exist yet."
        end
      end

      if options[:parameters]
        options[:parameters].each do |key, val|
          @input_parameters[key] = @parameters[key] = val
        end
      end
    end
{'fraction_non_alphanumeric': 0.10905629589339136, 'fraction_numerical': 0.004351373402230079, 'mean_word_length': 2.408711770157553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1166920', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1020, 'n_words': 264}