Class: Ruber::Rake::ProjectExtension
- Inherits:
-
Qt::Object
- Object
- Qt::Object
- Ruber::Rake::ProjectExtension
- Includes:
- Extension
- Defined in:
- plugins/rake/rake_extension.rb
Overview
Extension which takes care of storing and rebuilding the task list contained in the rake/tasks project option when one of the rake/rake, rake/rakefile, rake/options or rake/environment changes.
Instance Attribute Summary
Attributes included from Extension
Instance Method Summary (collapse)
-
- (Hash) gather_parameters
private
Retrieves the parameters to run rake with from the associated project.
-
- (ProjectExtension) initialize(prj)
constructor
A new instance of ProjectExtension.
-
- (nil) run_rake(task)
Runs a given task in rake.
-
- (Hash) tasks
The tasks defined in the rakefile associated with the project.
-
- (nil) update_tasks
Updates the
rake/tasks
project option so that the tasks match those reported by rake.
Methods included from Extension
#query_close, #remove_from_project, #save_settings, #shutdown
Signal Summary
Constructor Details
- (ProjectExtension) initialize(prj)
A new instance of ProjectExtension
39 40 41 42 43 44 45 |
# File 'plugins/rake/rake_extension.rb', line 39 def initialize prj super @project = prj @project.connect SIGNAL('option_changed(QString, QString)') do |grp, name| emit tasks_updated if grp == 'rake' and name == 'tasks' end end |
Instance Method Details
- (Hash) gather_parameters (private)
Retrieves the parameters to run rake with from the associated project.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'plugins/rake/rake_extension.rb', line 132 def gather_parameters res = {} res[:rake] = @project[:rake, :rake].dup res[:env] = @project[:rake, :environment].dup res[:options] = @project[:rake, :options].dup sync_stdout = @project[:rake, :sync_stdout] res[:options] << '-E' << '$stdout.sync = true' if sync_stdout rakefile = @project[:rake, :rakefile, :abs] rescue @project.document.path rakefile = rakefile.dup if rakefile if rakefile res[:rakefile] = File.basename rakefile res[:dir] = File.dirname rakefile else res[:dir] = @project.project_directory.dup end res end |
- (nil) run_rake(task)
Runs a given task in rake
The output from rake is displayed in the associated output widget, according to the settings for the associated project.
Before running rake, all the open documents belonging to the project are saved using autosave (this means that if the associated project is a DocumentProject, only the corresponding document will be saved).
default task
81 82 83 84 85 86 87 88 89 90 |
# File 'plugins/rake/rake_extension.rb', line 81 def run_rake task params = gather_parameters files = @project.files docs= Ruber[:world].documents.documents_with_file.select{|d| files.include? d.path} return unless Ruber[:autosave].autosave Ruber[:rake], docs, :on_failure => :ask ruby, *ruby_opts = Ruber[:rake].ruby_command_for @project, params[:dir] params[:ruby_options] = ruby_opts params[:task] = task Ruber[:rake].run_rake ruby, params[:dir], params end |
- (Hash) tasks
The tasks defined in the rakefile associated with the project
This method uses Ruber::Rake::Plugin#tasks to retrieve the list of tasks.
values
57 58 59 60 61 62 |
# File 'plugins/rake/rake_extension.rb', line 57 def tasks pars = gather_parameters ruby, *ruby_opts = Ruber[:rake].ruby_command_for @project, pars[:dir] pars[:ruby_options] = ruby_opts Ruber[:rake].tasks ruby, pars[:dir], pars end |
- (nil) update_tasks
Updates the rake/tasks
project option so that the tasks match those reported
by rake.
by the user
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'plugins/rake/rake_extension.rb', line 103 def update_tasks new_tasks = tasks old_tasks = @project[:rake, :tasks] new_tasks.each_pair do |k, v| data = [v] old_data = old_tasks[k] data << old_data[1] if old_data and old_data[1] new_tasks[k] = data end @project[:rake, :tasks] = new_tasks @project.save emit tasks_updated self end |
Signal Details
- tasks_updated