<commit_before>#
# Cookbook:: build_cookbook
# Recipe:: provision
#
# Copyright:: 2017, <NAME>, All Rights Reserved.
ruby_block 'Set Package URL for current environment' do
  block do 
    with_server_config do  
      build_config = ab_load_config(node['apache_build']['config_file'])
      begin
        publish_info = data_bag_item('build_apache', 'publish_info')
      rescue 
        publish_info = nil
      end
      unless publish_info.nil? 
      package_url = "http://#{publish_info['host']}/custom-httpd-#{build_config['build_number']}.tar.gz"
        env_name = if node['delivery']['change']['stage'] == 'acceptance'
                    get_acceptance_environment
                  else 
                    node['delivery']['change']['stage']
                  end
        
        cur_env = ::DeliveryTruck::Helpers::Provision.fetch_or_create_environment(env_name) # Helper method from delivery-truck's provision stage
        cur_env.default_attributes['apache_build']['package_url'] = package_url
        cur_env.save
      end # unless
    end # with_server_config
  end # block do
end # ruby block<commit_msg>Make sure we init the top level attribute before setting a lower one<commit_after>#
# Cookbook:: build_cookbook
# Recipe:: provision
#
# Copyright:: 2017, <NAME>, All Rights Reserved.
ruby_block 'Set Package URL for current environment' do
  block do 
    with_server_config do  
      build_config = ab_load_config(node['apache_build']['config_file'])
      begin
        publish_info = data_bag_item('build_apache', 'publish_info')
      rescue 
        publish_info = nil
      end
      unless publish_info.nil? 
      package_url = "http://#{publish_info['host']}/custom-httpd-#{build_config['build_number']}.tar.gz"
        env_name = if node['delivery']['change']['stage'] == 'acceptance'
                    get_acceptance_environment
                  else 
                    node['delivery']['change']['stage']
                  end
        
        cur_env = ::DeliveryTruck::Helpers::Provision.fetch_or_create_environment(env_name) # Helper method from delivery-truck's provision stage
        cur_env.default_attributes['apache_build'] = {} if cur_env.default_attributes['apache_build'].nil? # Init top level, if not already present
        cur_env.default_attributes['apache_build']['package_url'] = package_url
        cur_env.save
      end # unless
    end # with_server_config
  end # block do
end # ruby block
{'fraction_non_alphanumeric': 0.10866910866910867, 'fraction_numerical': 0.003256003256003256, 'mean_word_length': 3.0097879282218596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1075261', 'n_tokens_mistral': 709, 'n_tokens_neox': 684, 'n_words': 153}