Sha256: fb38689daa0b20fbee6f6739a740007d8b67b425f7ec01fb2ee9026096c0fb1e

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'
require 'open-uri'
require 'toml'

def mkdir(dir)
  FileUtils.rm_rf(dir)
  FileUtils.mkdir_p(dir)
end

def download_and_write(url, version: '1.0', dir: '', file: 'CODE_OF_CONDUCT.md')
  content = URI.open(url).read
  meta = { 'version' => version }
  toml = TOML::Generator.new(meta).body
  content = ['+++', toml, '+++', content].join("\n")
  path = File.join(dir, 'version', *version.split('.'), file)
  FileUtils.mkdir_p File.dirname(path)
  File.write(path, content)
end

repo = 'ContributorCovenant/contributor_covenant'
dir = File.expand_path '../vendor/contributor-covenant', __dir__
include_path = '*/content/version'

mkdir(dir)

tar_args = "--include=#{include_path} --strip-components=2 -C #{dir}"
`curl -L "https://api.github.com/repos/#{repo}/tarball" | tar xf - #{tar_args}`

repo = 'stumpsyn/policies'
dir = File.expand_path '../vendor/citizen-code-of-conduct', __dir__
file = 'citizen_code_of_conduct.md'
versions = {
  '2.0' => 'd0594789ea324a42e26b495034952b6ce08d9f51',
  '2.1' => 'b7705a4315a5e58fea58ae3d4b1de82bd564ac86',
  '2.2' => '93b7b06f52c9dd526d2395bfa9f5f1723deae32a',
  '2.3' => 'b1eb8deb5da073c2bd02a8e742e017edfc422554'
}

mkdir(dir)

versions.each do |version, sha|
  url = "https://github.com/#{repo}/raw/#{sha}/#{file}"
  download_and_write(url, version: version, dir: dir, file: file)
end

repo = 'domgetter/NCoC'
dir = 'vendor/no-code-of-conduct'
file = 'CODE_OF_CONDUCT.md'

mkdir(dir)

url = "https://github.com/#{repo}/raw/master/#{file}"
download_and_write(url, dir: dir, file: file)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coconductor-0.7.0 script/vendor-codes-of-conduct
coconductor-0.6.2 script/vendor-codes-of-conduct
coconductor-0.6.1 script/vendor-codes-of-conduct
coconductor-0.6.0 script/vendor-codes-of-conduct
coconductor-0.5.6 script/vendor-codes-of-conduct
coconductor-0.5.5 script/vendor-codes-of-conduct
coconductor-0.5.4 script/vendor-codes-of-conduct
coconductor-0.5.3 script/vendor-codes-of-conduct
coconductor-0.5.2 script/vendor-codes-of-conduct
coconductor-0.5.1 script/vendor-codes-of-conduct
coconductor-0.5.0 script/vendor-codes-of-conduct
coconductor-0.4.0 script/vendor-codes-of-conduct