Class: Qspec::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/qspec/config.rb

Constant Summary collapse

DEFAULT_PATH =
'.qspec.yml'

Class Method Summary collapse

Instance Method Summary collapse

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 <<TMPL
# DO NOT check this file into VCS (e.g. git).
# Parallelization setting differs between machines.
no_gc: false
ipc: file         # 'file' or 'redis', if 'redis', gem and server are required
sort_by: time     # 'time' or 'size',  if 'time', store execution time and use it next time
workers: 4        # half of cpu - number of cpu
spork_port: 9240  # specified port..port+N-1 are used
tmp_directory: tmp/qspec # the root directory for temporary files. relative or absolute
TMPL
  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