Class: Bowdler::Rake

Inherits:
Object
  • Object
show all
Defined in:
lib/bowdler/rake.rb

Constant Summary collapse

DEPENDENCY_FILES =
%w{Bowerfile}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Rake

Returns a new instance of Rake.



8
9
10
# File 'lib/bowdler/rake.rb', line 8

def initialize(options)
  @options = options
end

Instance Method Details

#commandObject



39
40
41
42
43
44
45
# File 'lib/bowdler/rake.rb', line 39

def command
  if update?
    'bower update'
  else
    'bower install'
  end
end

#dependency_fileObject



12
13
14
15
# File 'lib/bowdler/rake.rb', line 12

def dependency_file
  entries = Dir.entries(Dir.pwd)
  DEPENDENCY_FILES.detect { |file| entries.include?(file) }
end

#performObject



17
18
19
20
21
# File 'lib/bowdler/rake.rb', line 17

def perform
  case dependency_file
    when 'Bowerfile'  then perform_simple_dsl('Bowerfile')
  end
end

#perform_simple_dsl(file) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bowdler/rake.rb', line 23

def perform_simple_dsl(file)
  dsl = Bowdler::SimpleDsl.evalute(file)

  dsl.write_bower_json
  dsl.write_dotbowerrc

  system(command)
  system('bower list')

  dsl.delete_bower_json
end

#update?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/bowdler/rake.rb', line 35

def update?
  @options['update']
end