Class: Awspec::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/awspec/setup.rb

Class Method Summary collapse

Class Method Details

.generate_dotgitignoreObject



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/awspec/setup.rb', line 55

def self.generate_dotgitignore
  content = <<-'EOF'
secrets.yml
EOF
  if File.exist? 'spec/.gitignore'
    $stderr.puts '!! spec/.gitignore already exists'
  else
    File.open('spec/.gitignore', 'w') do |f|
      f.puts content
    end
    puts ' + spec/.gitignore'
  end
end

.generate_dotrspecObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/awspec/setup.rb', line 69

def self.generate_dotrspec
  content = <<-'EOF'
--color
--format documentation
EOF
  if File.exist? '.rspec'
    $stderr.puts '!! .rspec already exists'
  else
    File.open('.rspec', 'w') do |f|
      f.puts content
    end
    puts ' + .rspec'
  end
end

.generate_rakefileObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/awspec/setup.rb', line 38

def self.generate_rakefile
  content = <<-'EOF'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new('spec')
task :default => :spec
EOF

  if File.exist? 'Rakefile'
    $stderr.puts '!! Rakefile already exists'
  else
    File.open('Rakefile', 'w') do |f|
      f.puts content
    end
    puts ' + Rakefile'
  end
end

.generate_spec_helperObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/awspec/setup.rb', line 13

def self.generate_spec_helper
  content = <<-'EOF'
require 'awspec'
Awsecrets.load(secrets_path: File.expand_path('./secrets.yml', File.dirname(__FILE__)))
EOF
  dir = 'spec'
  if File.exist? dir
    unless File.directory? dir
      $stderr.puts '!! #{dir} already exists and is not a directory'
    end
  else
    FileUtils.mkdir dir
    puts " + #{dir}/"
  end

  if File.exist? 'spec/spec_helper.rb'
    $stderr.puts '!! spec/spec_helper.rb already exists'
  else
    File.open('spec/spec_helper.rb', 'w') do |f|
      f.puts content
    end
    puts ' + spec/spec_helper.rb'
  end
end

.runObject



6
7
8
9
10
11
# File 'lib/awspec/setup.rb', line 6

def self.run
  generate_spec_helper
  generate_rakefile
  generate_dotgitignore
  generate_dotrspec
end