Module: ServerspecLauncher

Defined in:
lib/serverspec_launcher.rb,
lib/serverspec_launcher/version.rb

Overview

Main Class

Constant Summary collapse

VERSION =
'0.7.1'

Class Method Summary collapse

Class Method Details

.check_args(args) ⇒ Object



71
72
73
74
75
76
# File 'lib/serverspec_launcher.rb', line 71

def self.check_args(args)
  if args.length.zero?
    puts 'Usage: serverspec_launcher init'
    exit 1
  end
end

.create_repoObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/serverspec_launcher.rb', line 57

def self.create_repo
  if which 'git'
    name = `git config user.name`.chomp
    email = `git config user.email`.chomp

    system('git init .') unless Dir.exists? '.git'
    return {
        name: name == '' ? nil : name,
        email: email == '' ? nil : email,
    }
  end
  {}
end

.generate_examplespecObject



25
26
27
28
# File 'lib/serverspec_launcher.rb', line 25

def self.generate_examplespec
  properties = ExampleSpecGenerator.new
  properties.generate
end

.generate_gemspec(options = {}) ⇒ Object



40
41
42
43
# File 'lib/serverspec_launcher.rb', line 40

def self.generate_gemspec(options = {})
  gemspec = GemspecGenerator.new options
  gemspec.generate
end

.generate_propertiesObject



14
15
16
17
# File 'lib/serverspec_launcher.rb', line 14

def self.generate_properties
  properties = PropertiesGenerator.new
  properties.generate
end

.generate_rakefileObject



35
36
37
38
# File 'lib/serverspec_launcher.rb', line 35

def self.generate_rakefile
  properties = RakefileGenerator.new
  properties.generate
end

.generate_rolespecObject



19
20
21
22
# File 'lib/serverspec_launcher.rb', line 19

def self.generate_rolespec
  properties = RoleSpecGenerator.new
  properties.generate
end

.generate_spec_helperObject



30
31
32
33
# File 'lib/serverspec_launcher.rb', line 30

def self.generate_spec_helper
  properties = SpecHelperGenerator.new
  properties.generate
end

.initObject



78
79
80
81
82
83
84
85
86
# File 'lib/serverspec_launcher.rb', line 78

def self.init
  generate_properties 
  generate_rolespec 
  generate_examplespec
  generate_spec_helper
  generate_rakefile 
  generate_rolespec 
  generate_gemspec create_repo
end

.process_command(args) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/serverspec_launcher.rb', line 88

def self.process_command(args)
  check_args args
  command = args.shift
  parameters = args

  case command
  when 'init'
    init
  when 'version'
    puts "Serverspec Launcher version #{ServerspecLauncher::VERSION}"
  when 'reshape'

    ReShaper.reshape_report args[0]
  end

end

.which(cmd) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/serverspec_launcher.rb', line 46

def self.which(cmd)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each { |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if File.executable?(exe) && !File.directory?(exe)
    }
  end
  return nil
end