Class: Repo

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/norad_cli/cli/secrepo.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/norad_cli/cli/secrepo.rb', line 10

def self.source_root
  File.join(File.dirname(File.expand_path(__FILE__)), '../templates/')
end

Instance Method Details

#create(repo_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/norad_cli/cli/secrepo.rb', line 17

def create(repo_name)
  say 'Initializing a new norad security test repository'

  # Initialize a new git repository
  Git.init(repo_name)

  # Create the necessary directories
  %w[base spec sectests].each do |dirrepo_name|
    empty_directory "#{repo_name}/#{dirrepo_name}"
  end

  # Ask about licensing
  if yes?('License the repo under Apache 2?')
    options[:year] = Date.today.year
    options[:company] = ask('Who is the copyright holder (Default: Cisco Systems, Inc.)?')
    options[:company] = 'Cisco Systems, Inc.' if options[:company].empty?
    template 'LICENSE.erb', "#{repo_name}/LICENSE"
  end

  # Copy the necessary root files
  copy_file 'ci/.gitlab.ci.yml', "#{repo_name}/.gitlab.ci.yml"
  copy_file '.gitignore', "#{repo_name}/.gitignore"
  copy_file 'CONTRIBUTING.md', "#{repo_name}/CONTRIBUTING.md"
  copy_file 'README.md', "#{repo_name}/README.md"

  # Copy the spec helper
  copy_file 'spec/spec_helper.rb', "#{repo_name}/spec/spec_helper.rb"
end