Class: Qspec::Config
- Inherits:
-
Object
- Object
- Qspec::Config
- Defined in:
- lib/qspec/config.rb
Constant Summary collapse
- DEFAULT_PATH =
'.qspec.yml'
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(path = DEFAULT_PATH) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path = DEFAULT_PATH) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 13 14 15 |
# File 'lib/qspec/config.rb', line 7 def initialize(path = DEFAULT_PATH) @path = path if File.exists?(path) @config = YAML.load_file(path) else STDERR.puts "You do not have #{path}. Initialize with `qspec-helper init`" exit 1 end end |
Class Method Details
.create_template(path = DEFAULT_PATH) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/qspec/config.rb', line 21 def self.create_template(path = DEFAULT_PATH) if File.exists?(path) STDERR.puts "You already have a template file #{path}. Remove it if you want to reset." exit 1 end File.open(path, 'w') do |f| f.write "# DO NOT check this file into VCS (e.g. git).\n# Parallelization setting differs between machines.\nno_gc: false\nipc: file # 'file' or 'redis', if 'redis', gem and server are required\nsort_by: time # 'time' or 'size', if 'time', store execution time and use it next time\nworkers: 4 # half of cpu - number of cpu\nspork_port: 9240 # specified port..port+N-1 are used\ntmp_directory: tmp/qspec # the root directory for temporary files. relative or absolute\n" end puts "Config file created in #{path}. Check it before run `qspec spec`." end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/qspec/config.rb', line 17 def [](key) @config[key] end |