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.



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

def initialize(config={})
  @directory = config['directory'] || DEFAULT_DIRECTORY
  @json      = config['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

Returns the value of attribute json.



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

def json
  @json
end

Class Method Details

.setup(bowerrc = nil) ⇒ Object



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

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



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

def install
  run('bower install')
end

#updateObject



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

def update
  run('bower update')
end