<commit_before>#!/usr/bin/env ruby

def check_preconditions
  exit 1 if ENV['TRAVIS_SECURE_ENV_VARS'] != 'true'
  exit 1 if !ENV['GH_TOKEN']
  exit 1 if ENV['CI'] != 'true'
  exit 1 if ENV['TRAVIS_PULL_REQUEST'] != 'false'
  if !ENV['TRAVIS_TAG'] || ENV['TRAVIS_TAG'] !~ /^v\d{1,2}\.\d{1,2}\.\d{1,2}$/
    puts 'Skipping the docs generation because it\'s not a release build.'
    exit 0
  end
end
check_preconditions

def version
  ENV['TRAVIS_TAG'][1..-1]
end

VERSION=version
DOCS_DIR='~/doc'

def switch_branch
  `git checkout gh-pages`
end

def generate_docs
  `yardoc --output-dir #{DOCS_DIR}`
end

def copy_docs
  `cp -r #{DOCS_DIR} docs/#{VERSION}`
  `rm docs/latest`
  `ln -s #{VERSION} docs/latest`
  `echo "      <li><a href='/docs/#{VERSION}'>#{VERSION}</a></li>" >> docs/index.html`
end

def add_to_scm
  `git add -A`
  `git commit -m "Docs for version #{VERSION}."`
  `git remote add ad-hoc-origin https://hawkular-website-bot:#{GH_TOKEN}@github.com/hawkular/hawkular-client-ruby.git`
  `git push ad-hoc-origin gh-pages`
end

def main
  puts 'generating docs for version ' + VERSION
  generate_docs

  puts 'switching branch to gh-pages..'
  switch_branch

  puts 'copying docs..'
  copy_docs
  
  puts 'pushing back to gh-pages..'
  add_to_scm
end

main
<commit_msg>Automation for docs: fixing the URL<commit_after>#!/usr/bin/env ruby

def check_preconditions
  exit 1 if ENV['TRAVIS_SECURE_ENV_VARS'] != 'true'
  exit 1 if !ENV['GH_TOKEN']
  exit 1 if ENV['CI'] != 'true'
  exit 1 if ENV['TRAVIS_PULL_REQUEST'] != 'false'
  if !ENV['TRAVIS_TAG'] || ENV['TRAVIS_TAG'] !~ /^v\d{1,2}\.\d{1,2}\.\d{1,2}$/
    puts 'Skipping the docs generation because it\'s not a release build.'
    exit 0
  end
end
check_preconditions

def version
  ENV['TRAVIS_TAG'][1..-1]
end

VERSION=version
DOCS_DIR='~/doc'

def switch_branch
  `git checkout gh-pages`
end

def generate_docs
  `yardoc --output-dir #{DOCS_DIR}`
end

def copy_docs
  `cp -r #{DOCS_DIR} docs/#{VERSION}`
  `rm docs/latest`
  `ln -s #{VERSION} docs/latest`
  `echo "      <li><a href='/hawkular-client-ruby/docs/#{VERSION}'>#{VERSION}</a></li>" >> docs/index.html`
end

def add_to_scm
  `git add -A`
  `git commit -m "Docs for version #{VERSION}."`
  `git remote add ad-hoc-origin https://hawkular-website-bot:#{GH_TOKEN}@github.com/hawkular/hawkular-client-ruby.git`
  `git push ad-hoc-origin gh-pages`
end

def main
  puts 'generating docs for version ' + VERSION
  generate_docs

  puts 'switching branch to gh-pages..'
  switch_branch

  puts 'copying docs..'
  copy_docs
  
  puts 'pushing back to gh-pages..'
  add_to_scm
end

main

{'fraction_non_alphanumeric': 0.1581573896353167, 'fraction_numerical': 0.009980806142034549, 'mean_word_length': 3.7124773960216997, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '2043729', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1055, 'n_words': 259}