Sha256: f45c83f25742604abf6981fe9092d65951e81e2c52e0aeec2ba001c58ae5e9cc

Contents?: true

Size: 692 Bytes

Versions: 4

Compression:

Stored size: 692 Bytes

Contents

# encoding: utf-8
require 'singleton'
require 'yaml'

module Sonar
  class RCFile
    include Singleton

    attr_accessor :path
    FILENAME = 'sonar.rc'

    def initialize
      @path = File.join(File.expand_path('~'), FILENAME)
      @data = load_file
    end

    def create_file
      File.open(@path, 'w') do |f|
        f.puts 'email: YOUR_EMAIL'
        f.puts 'access_token: SONAR_TOKEN'
        f.puts 'api_url: https://sonar.labs.rapid7.com'
        f.puts 'format: flat'
        f.puts 'record_limit: 10000'
      end
      puts "Config file setup at: #{@path}"
    end

    def load_file
      create_file unless File.exist?(@path)
      YAML.load_file(@path)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sonar-client-0.0.5 lib/sonar/cli/rcfile.rb
sonar-client-0.0.4 lib/sonar/cli/rcfile.rb
sonar-client-0.0.3 lib/sonar/cli/rcfile.rb
sonar-client-0.0.2 lib/sonar/cli/rcfile.rb