Class: Awspec::Setup

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

Class Method Summary collapse

Class Method Details

.generate_dotgitignoreObject



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

def self.generate_dotgitignore
  content = "secrets.yml\n"
  if File.exist? 'spec/.gitignore'
    warn '!! spec/.gitignore already exists'
  else
    File.open('spec/.gitignore', 'w') do |f|
      f.puts content
    end
    puts ' + spec/.gitignore'
  end
end

.generate_dotrspecObject



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

def self.generate_dotrspec
  content = "--color\n--format documentation\n"
  if File.exist? '.rspec'
    warn '!! .rspec already exists'
  else
    File.open('.rspec', 'w') do |f|
      f.puts content
    end
    puts ' + .rspec'
  end
end

.generate_rakefileObject



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

def self.generate_rakefile
  content = "require 'rspec/core/rake_task'\nRSpec::Core::RakeTask.new('spec')\ntask :default => :spec\n"

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

.generate_spec_helperObject



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

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

  if File.exist? 'spec/spec_helper.rb'
    warn '!! 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



8
9
10
11
12
13
# File 'lib/awspec/setup.rb', line 8

def self.run
  generate_spec_helper
  generate_rakefile
  generate_dotgitignore
  generate_dotrspec
end