<commit_before># encoding: UTF-8
#
# Cookbook Name:: wergstation
#
# Recipe:: xfce
#
# Copyfree (F) 2014 <NAME>
#

ns = node["wergstation"]

# user's id, group, home
id, grp, home = %w{ id group home }.map { |k| ns["user"][k] }

cfgs = %w{ helpers.rc
           terminal/terminalrc }.
  map { |cfg| ".config/xfce4/#{cfg}" }

## Create directory structure for xfce4 config files
#
cfgs.map { |cfg| cfg.rpartition("/").first }.
  each do |dir|
    directory ::File.join(home, dir) do
      group grp
      mode "0750"
      owner "id"
      action :create
    end
  end

## Render xfce4 config files
#
cfgs.each do |cfg|
  template ::File.join(home, cfg) do
    group grp
    mode "0640"
    owner id
    source "home/#{cfg.sub(/^\./, "dot")}.erb"
    variables(:font => "Source Code Pro Medium 12")
    action :create
  end
end<commit_msg>download source code pro font and install<commit_after># encoding: UTF-8
#
# Cookbook Name:: wergstation
#
# Recipe:: xfce
#
# Copyfree (F) 2014 <NAME>
#

ns = node["wergstation"]

# user's id, group, home
id, grp, home = %w{ id group home }.map { |k| ns["user"][k] }

# ~/.fonts dir
dotfonts = ::File.join(home, ".fonts")

# config files for xfce4
cfgs = %w{ helpers.rc
           terminal/terminalrc }.
  map { |cfg| ".config/xfce4/#{cfg}" }

## Create directory structure for xfce4 config files
#
cfgs.map { |cfg| cfg.rpartition("/").first }.
  each do |dir|
    directory ::File.join(home, dir) do
      group grp
      mode "0750"
      owner "id"
      action :create
    end
  end

## Render xfce4 config files
#
cfgs.each do |cfg|
  template ::File.join(home, cfg) do
    group grp
    mode "0640"
    owner id
    source "home/#{cfg.sub(/^\./, "dot")}.erb"
    variables(:font => "Source Code Pro Medium 12")
    action :create
  end
end

## Install unzip
#
package "unzip" do
  action :install
end

## Create ~/.fonts
#
diretory dotfonts do
  group grp
  mode "0640"
  owner id
  action :create
end

## Download fonts
#
font = "SourceCodePro_FontsOnly-1.017"
zip_dir = ::File.join(Chef::Config[:file_cache_path], font)
zip = "#{zip_dir}.zip"

remote_file zip do
  group grp
  mode "0640"
  owner id
  source "http://sourceforge.net/projects/sourcecodepro.adobe/files/#{font}.zip"
  action :create_if_missing
  notifies :run, "execute[unzip #{zip}]", :immediately
end

execute "unzip #{zip}" do
  creates zip_dir
  cwd Chef::Config[:file_cache_path]
  group grp
  user id
  action :nothing
end

execute "cp -v #{::File.join(zip_dir, "OTF")}/* #{dotfonts}" do
  cwd zip_dir
  group grp
  user id
  action :nothing
  subscribes :run, "unzip #{zip}", :immediately
end
{'fraction_non_alphanumeric': 0.15166602834163156, 'fraction_numerical': 0.01876675603217158, 'mean_word_length': 3.192616372391653, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3462730', 'n_tokens_mistral': 1022, 'n_tokens_neox': 978, 'n_words': 284}