Class: Beet::Executor
- Inherits:
-
Object
- Object
- Beet::Executor
- Includes:
- Capistrano, Execution, FileSystem, Interaction, Rails, SCM
- Defined in:
- lib/beet/executor.rb
Constant Summary collapse
- BEET_DATA_FILE =
"~/.beet.yml"
Instance Attribute Summary collapse
-
#gems ⇒ Object
Returns the value of attribute gems.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#recipes ⇒ Object
Returns the value of attribute recipes.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#todo_items ⇒ Object
Returns the value of attribute todo_items.
Instance Method Summary collapse
-
#initialize(project_name, options = {}) ⇒ Executor
constructor
:nodoc:.
- #log(*args) ⇒ Object
- #run_recipes ⇒ Object
- #start ⇒ Object
- #todo(string = nil, &block) ⇒ Object
Methods included from SCM
Methods included from Capistrano
Methods included from Rails
#environment, #freeze!, #gem, #generate, #initializer, #plugin, #route, #vendor
Methods included from Interaction
Methods included from FileSystem
#add_after, #add_before, #append_file, #file, #gsub_file, #in_root, #inside, #lib, #rakefile
Methods included from Execution
#rake, #run, #run_ruby_script, #sudo
Constructor Details
#initialize(project_name, options = {}) ⇒ Executor
:nodoc:
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/beet/executor.rb', line 18 def initialize(project_name, ={}) # :nodoc: @root = calculate_project_root(project_name) @project_name = ((project_name == '.') ? File.basename(Dir.pwd) : project_name) @logger = Beet::Logger.new @gems = [] @template = [:template] @options = @todo_items = '' @recipes = [] @project_type = [:project_type] @generate = true unless [:generate] == false @display = [:display] end |
Instance Attribute Details
#gems ⇒ Object
Returns the value of attribute gems.
16 17 18 |
# File 'lib/beet/executor.rb', line 16 def gems @gems end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
15 16 17 |
# File 'lib/beet/executor.rb', line 15 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/beet/executor.rb', line 15 def @options end |
#project_name ⇒ Object
Returns the value of attribute project_name.
16 17 18 |
# File 'lib/beet/executor.rb', line 16 def project_name @project_name end |
#recipes ⇒ Object
Returns the value of attribute recipes.
16 17 18 |
# File 'lib/beet/executor.rb', line 16 def recipes @recipes end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/beet/executor.rb', line 15 def root @root end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
15 16 17 |
# File 'lib/beet/executor.rb', line 15 def template @template end |
#todo_items ⇒ Object
Returns the value of attribute todo_items.
16 17 18 |
# File 'lib/beet/executor.rb', line 16 def todo_items @todo_items end |
Instance Method Details
#log(*args) ⇒ Object
87 88 89 |
# File 'lib/beet/executor.rb', line 87 def log(*args) logger.log(*args) end |
#run_recipes ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/beet/executor.rb', line 72 def run_recipes @recipes.each do |recipe| begin code = open(recipe).read if @display puts code else in_root { instance_eval(code)} end rescue LoadError, Errno::ENOENT => e raise "The recipe [#{recipe}] could not be loaded. Error: #{e}" end end end |
#start ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/beet/executor.rb', line 33 def start if @options[:use] puts "Loading saved configuration: #{@options[:use]}" data = load_saved_recipe_file if config = data[@options[:use]] @gems.concat(config[:gems]) if config[:gems] @template = config[:template] if config[:template] @recipes.concat(config[:recipes]) if config[:recipes] end end if @display && @template puts open(TEMPLATE_LOCATIONS[@template]).read else case @project_type when :rails if @generate puts "Generating rails project #{project_name}..." if @template system("rails #{project_name} -m #{TEMPLATE_LOCATIONS[@template]}") else system("rails #{project_name}") end end end add_gems print_todo if @options[:save] save_run end end run_recipes end |
#todo(string = nil, &block) ⇒ Object
91 92 93 |
# File 'lib/beet/executor.rb', line 91 def todo(string=nil, &block) self.todo_items << (string || block.call) end |