module Drupid::Drush

A wrapper around drush.

Public Class Methods

bootstrapped?(path, options = {}) click to toggle source

Returns true if a Drupal’s site is bootstrapped at the given path; returns false otherwise.

   # File lib/drupid/drush.rb
30 def self.bootstrapped?(path, options = {})
31   output = ''
32   FileUtils.cd(path) do
33     output = %x|drush core-status --format=yaml|
34   end
35   begin # See self.installed?
36     st = YAML.load(output)
37   rescue Exception
38     return false
39   end
40   return false unless st
41   return false unless st.instance_of?(Hash)
42   return (st['bootstrap'] =~ /Successful/) ? true : false
43 end
installed?(site_path, project_name, project_path, options = {}) click to toggle source

Returns true if the project at the given path is an enabled theme or an installed (enabled or disabled) module in the given site; returns false otherwise. The project’s path must be relative to the Drupal installation (e.g., ‘sites/all/modules’). Note that the project path is necessary because, in general, there may be several copies of the same modules at different locations within a platform (in ‘sites/all’, in ‘profiles/’ and in site-specific locations).

Options: verbose

   # File lib/drupid/drush.rb
54 def self.installed?(site_path, project_name, project_path, options = {})
55   output = nil
56   FileUtils.cd(site_path) do
57     # Redirect stderr to stdout because we do not want to output
58     # Drush's error messages when Drupid is run in verbose mode.
59     output = %x|drush pm-info --format=yaml #{project_name} 2>&1|
60     return false unless $?.success? # site not fully bootstrapped
61   end
62   # If a project is not found, Drush does *not* return a YAML structure,
63   # so we need to catch exceptions here.
64   begin
65     st = YAML.load(output)
66   rescue Exception
67     return false
68   end
69   return false unless st.instance_of?(Hash)
70   return false unless st.has_key?(project_name)
71   type = st[project_name]['type']
72   status = st[project_name]['status']
73   ('module' == type and status !~ /not installed/) or
74   ('theme'  == type and status =~ /^enabled/)
75 end
updatedb(site_path) click to toggle source

Runs drush updatedb at the specified path.

Raises a Drupid:ErrorDuringExecution exception if an error occurs.

   # File lib/drupid/drush.rb
80 def self.updatedb site_path
81   FileUtils.cd(site_path) do
82     return system 'drush updatedb -y'
83   end
84 end