Class: Bower::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/bower/environment.rb

Constant Summary collapse

DEFAULT_DIRECTORY =
'bower_components'
DEFAULT_JSON =
'bower.json'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Environment

Returns a new instance of Environment.



20
21
22
23
# File 'lib/bower/environment.rb', line 20

def initialize(config={})
  @directory = config['directory'] || DEFAULT_DIRECTORY
  @json      = DEFAULT_JSON
end

Instance Attribute Details

#directoryObject

Returns the value of attribute directory.



5
6
7
# File 'lib/bower/environment.rb', line 5

def directory
  @directory
end

#jsonObject (readonly)

Returns the value of attribute json.



6
7
8
# File 'lib/bower/environment.rb', line 6

def json
  @json
end

Class Method Details

.setup(bowerrc = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/bower/environment.rb', line 11

def self.setup(bowerrc=nil)
  if bowerrc && File.exists?(bowerrc)
    conf = MultiJson.load(File.open(bowerrc))
    Environment.new(conf)
  else
    Environment.new
  end
end

Instance Method Details

#installObject



25
26
27
# File 'lib/bower/environment.rb', line 25

def install
  run('bower install')
end

#updateObject



29
30
31
# File 'lib/bower/environment.rb', line 29

def update
  run('bower update')
end