Module: Drupid::Drush
- Defined in:
- lib/drupid/drush.rb
Overview
A wrapper around drush.
Class Method Summary collapse
-
.bootstrapped?(path, options = {}) ⇒ Boolean
Returns true if a Drupal’s site is bootstrapped at the given path; returns false otherwise.
-
.installed?(site_path, project_name, project_path, options = {}) ⇒ Boolean
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.
-
.updatedb(site_path) ⇒ Object
Runs drush updatedb at the specified path.
Class Method Details
.bootstrapped?(path, options = {}) ⇒ Boolean
Returns true if a Drupal’s site is bootstrapped at the given path; returns false otherwise.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/drupid/drush.rb', line 31 def self.bootstrapped?(path, = {}) output = '' FileUtils.cd(path) do output = %x|drush core-status --format=yaml| end begin # See self.installed? st = YAML.load(output) rescue Exception return false end return false unless st return false unless st.instance_of?(Hash) return (st['bootstrap'] =~ /Successful/) ? true : false end |
.installed?(site_path, project_name, project_path, options = {}) ⇒ Boolean
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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/drupid/drush.rb', line 55 def self.installed?(site_path, project_name, project_path, = {}) output = nil FileUtils.cd(site_path) do # Redirect stderr to stdout because we do not want to output # Drush's error messages when Drupid is run in verbose mode. output = %x|drush pm-info --format=yaml #{project_name} 2>&1| return false unless $?.success? # site not fully bootstrapped end # If a project is not found, Drush does *not* return a YAML structure, # so we need to catch exceptions here. begin st = YAML.load(output) rescue Exception return false end return false unless st.instance_of?(Hash) return false unless st.has_key?(project_name) type = st[project_name]['type'] status = st[project_name]['status'] ('module' == type and status !~ /not installed/) or ('theme' == type and status =~ /^enabled/) end |
.updatedb(site_path) ⇒ Object
Runs drush updatedb at the specified path.
Raises a Drupid:ErrorDuringExecution exception if an error occurs.
81 82 83 84 85 |
# File 'lib/drupid/drush.rb', line 81 def self.updatedb site_path FileUtils.cd(site_path) do return system 'drush updatedb -y' end end |