Class: Cockroach::Config

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Defined in:
lib/cockroach/config.rb,
lib/cockroach/config/loader.rb

Defined Under Namespace

Classes: ConfigNotExistsError, Loader, MissingRootPathError

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_config) ⇒ Config

Returns a new instance of Config.



29
30
31
32
33
34
# File 'lib/cockroach/config.rb', line 29

def initialize path_to_config
  @config_path = File.expand_path path_to_config, self.class.root
  @profile, @options = Cockroach::Config::Loader.parse(@config_path)
  @fixturer_def = get_option('fixturer') || self.class.fixturer || 'factory_girl'
  @fixtures_path = self.class.fixtures_path if self.class.fixtures_path
end

Class Attribute Details

.config_pathObject

Returns the value of attribute config_path.



12
13
14
# File 'lib/cockroach/config.rb', line 12

def config_path
  @config_path
end

.fixturerObject

Returns the value of attribute fixturer.



12
13
14
# File 'lib/cockroach/config.rb', line 12

def fixturer
  @fixturer
end

.fixtures_pathObject

Returns the value of attribute fixtures_path.



12
13
14
# File 'lib/cockroach/config.rb', line 12

def fixtures_path
  @fixtures_path
end

.rootObject

Returns root folder for the project, of if one is missing it tries to return Rails.root, if Rails is not defined it will raise an error.



16
17
18
19
20
21
22
23
24
# File 'lib/cockroach/config.rb', line 16

def root
  @root ||= begin
    if defined?(Rails)
      File.join Rails.root
    else
      "./"
    end
  end
end

Instance Attribute Details

#fixtures_pathObject (readonly)

Returns the value of attribute fixtures_path.



27
28
29
# File 'lib/cockroach/config.rb', line 27

def fixtures_path
  @fixtures_path
end

#optionsObject (readonly)

Returns the value of attribute options.



27
28
29
# File 'lib/cockroach/config.rb', line 27

def options
  @options
end

#profileObject (readonly)

Returns the value of attribute profile.



27
28
29
# File 'lib/cockroach/config.rb', line 27

def profile
  @profile
end

Instance Method Details

#fixturerObject



36
37
38
# File 'lib/cockroach/config.rb', line 36

def fixturer
  @fixturer ||= @fixturer_def.to_s.camelize.to_sym
end

#profilerObject



40
41
42
43
44
# File 'lib/cockroach/config.rb', line 40

def profiler
  @profiler ||= begin
    Cockroach.const_get(fixturer)::Profiler.new
  end
end