Sha256: f6bc0dc55c1627e7f839b622357b36d49de7587c8837fd4bfd1059bfb3fbc9bf

Contents?: true

Size: 1.82 KB

Versions: 178

Compression:

Stored size: 1.82 KB

Contents

require 'fileutils'
require 'yaml'

module Awspec
  class Setup
    def self.run
      generate_spec_helper
      generate_rakefile
      generate_dotgitignore
      generate_dotrspec
    end

    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

    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

    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

    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
  end
end

Version data entries

178 entries across 178 versions & 4 rubygems

Version Path
awspec-1.24.3 lib/awspec/setup.rb
awspec-1.24.2 lib/awspec/setup.rb
awspec-1.24.1 lib/awspec/setup.rb
awspec-1.24.0 lib/awspec/setup.rb
awspec-1.23.0 lib/awspec/setup.rb
awspec-1.22.1 lib/awspec/setup.rb
awspec-1.22.0 lib/awspec/setup.rb
awspec-1.21.1 lib/awspec/setup.rb
awspec-1.21.0 lib/awspec/setup.rb
awspec-1.20.0 lib/awspec/setup.rb
awspec-1.19.2 lib/awspec/setup.rb
awspec-1.19.1 lib/awspec/setup.rb
awspec-1.19.0 lib/awspec/setup.rb
cthiesfork-awspec-1.2.4 lib/awspec/setup.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/setup.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/setup.rb
awspec-1.18.6 lib/awspec/setup.rb
cthiesfork-awspec-1.2.2 lib/awspec/setup.rb
cthiesfork-awspec-1.2.1 lib/awspec/setup.rb
awspec-1.18.5 lib/awspec/setup.rb