Class: Sonar::RCFile
- Inherits:
-
Object
- Object
- Sonar::RCFile
- Includes:
- Singleton
- Defined in:
- lib/sonar/cli/rcfile.rb
Constant Summary collapse
- FILENAME =
'sonar.rc'
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #create_file ⇒ Object
-
#initialize ⇒ RCFile
constructor
A new instance of RCFile.
- #load_file ⇒ Object
Constructor Details
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/sonar/cli/rcfile.rb', line 9 def path @path end |
Instance Method Details
#create_file ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sonar/cli/rcfile.rb', line 17 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 warn = "Please set your email and API token in sonar.rc" puts "=" * warn.size puts "Config file setup at: #{@path}" puts warn puts "=" * warn.size end |
#load_file ⇒ Object
32 33 34 35 |
# File 'lib/sonar/cli/rcfile.rb', line 32 def load_file create_file unless File.exist?(@path) YAML.load_file(@path) end |