Module: LocalConfig

Defined in:
lib/localconfig/rake.rb,
lib/localconfig/admin.rb,
lib/localconfig/rails.rb,
lib/localconfig/config.rb,
lib/localconfig/version.rb

Overview

namespace

Defined Under Namespace

Modules: Rake Classes: Config, Railtie

Constant Summary collapse

CONFIGS =
{}
VERSION =
'0.3.3'
DATE =
'2014-10-30'

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

get (new) Config by name



241
242
243
# File 'lib/localconfig/config.rb', line 241

def self.[](name)
  CONFIGS[name] ||= Config.new
end

._branchObject

current git branch



262
263
264
265
266
# File 'lib/localconfig/config.rb', line 262

def self._branch
  c = 'git symbolic-ref -q HEAD 2>/dev/null'
  b = %x[#{c}].chomp.sub %r{^refs/heads/}, ''
  [0,1].include?($?.exitstatus) ? (b.empty? ? '(HEAD)' : b) : nil
end

.branchObject

either the current git branch, '(HEAD)' for a detached head, or nil if not in a git repo; (cached);

to use this in a Gemfile, you will need to have the localconfig gem installed locally before running bundle



250
251
252
# File 'lib/localconfig/config.rb', line 250

def self.branch
  @branch ||= _branch
end

.envObject

like Rails.env; (cached)



255
256
257
# File 'lib/localconfig/config.rb', line 255

def self.env
  @env ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end