Class: Kibou::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Kibou::RakeTask
- Includes:
- Utility::Helpers
- Defined in:
- lib/kibou/rake_task.rb
Instance Attribute Summary collapse
-
#recipes ⇒ Object
Returns the value of attribute recipes.
-
#recipes_path ⇒ Object
Returns the value of attribute recipes_path.
Instance Method Summary collapse
- #build_tasks! ⇒ Object
-
#initialize(name = :kibou) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #packages_sync(recipes) ⇒ Object
- #require_tree(pattern) ⇒ Object
Methods included from Utility::Helpers
#brew, #brew_installed?, #capture, #info, #outdated, #package_included?, #package_install, #package_installed?, #package_outdated?, #package_upgrade, #run, #search, #update!
Constructor Details
#initialize(name = :kibou) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
11 12 13 14 15 16 17 |
# File 'lib/kibou/rake_task.rb', line 11 def initialize(name = :kibou) @name = name @recipes = [] @recipes_path = "recipes/*.rb" yield self if block_given? build_tasks! end |
Instance Attribute Details
#recipes ⇒ Object
Returns the value of attribute recipes.
9 10 11 |
# File 'lib/kibou/rake_task.rb', line 9 def recipes @recipes end |
#recipes_path ⇒ Object
Returns the value of attribute recipes_path.
9 10 11 |
# File 'lib/kibou/rake_task.rb', line 9 def recipes_path @recipes_path end |
Instance Method Details
#build_tasks! ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kibou/rake_task.rb', line 19 def build_tasks! desc "start Kibou -- run package installations via Homebrew" task @name do raise "Homebrew is not installed!" unless brew_installed? require_tree @recipes_path recipes = @recipes.map &Recipe.method(:new) packages_sync(recipes) end self end |
#packages_sync(recipes) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kibou/rake_task.rb', line 34 def packages_sync(recipes) brew :update recipes.each do |recipe| puts "#{recipe.name} (#{recipe.packages.size} packages)" recipe.run_before_tasks recipe.packages.each do |package| package.dependencies.each do |dep| pkg = recipe.find_package(dep.dependency) raise "Missing dependencies: #{dep.dependency}" unless pkg pkg.perform unless pkg.completed? end package.perform unless package.completed? end recipe.run_after_tasks end end |
#require_tree(pattern) ⇒ Object
30 31 32 |
# File 'lib/kibou/rake_task.rb', line 30 def require_tree(pattern) Dir[pattern].map(&File.method(:expand_path)).each &method(:require) end |