class Drupid::PlatformProject

Attributes

platform[R]

Public Class Methods

new(proj_platform, project_or_info_path) click to toggle source
Calls superclass method
   # File lib/drupid/platform_project.rb
26 def initialize proj_platform, project_or_info_path
27   pi = ProjectInfo.new(project_or_info_path)
28   super(pi.project_name, pi.project_core)
29   @info_file = pi.info_file
30   @local_path = pi.project_dir
31   @version = pi.project_version if pi.project_version
32   @proj_type = pi.project_type
33   @core_project = pi.core_project?
34   @platform = proj_platform
35 end

Public Instance Methods

installed?(site = nil) click to toggle source

Returns true if this is an enabled theme or an installed (enabled or disabled) module in the specified site, or in at least one site in the platform if no site is specified; returns false otherwise. Note that the project’s path must be defined, because this method uses the path to determine whether the project is installed in a site. Consider, for example, a Drupal platform that contains two distinct copies of a module called Foo, one in ./sites/www.mysite.org/modules/foo and another in ./profiles/fooprofile/modules/foo. Suppose that the former is used by the site www.mysite.org, and the latter is used by another site, say www.othersite.org, installed using the fooprofile installation profile. If p is a Drupid::PlatformProject object associated to ./sites/www.mysite.org/modules/foo and q is another Drupid::PlatformProject object associated to ./profiles/fooprofile/modules/foo and both modules are installed in their respective sites, then the result of invoking this method will be as follows:

p.installed?('www.mysite.org')     # true
p.installed?('www.othersite.org')  # false
q.installed?('www.mysite.org')     # false
q.installed?('www.othersite.org')  # true
p.installed?                       # true
q.installed?                       # true
   # File lib/drupid/platform_project.rb
79 def installed? site = nil
80   site_list = (site) ? [site] : platform.site_names
81   site_list.each do |s|
82     site_path = platform.sites_path + s
83     next unless site_path.exist?
84     return true if Drush.installed?(site_path, name, relative_path)
85   end
86   return false
87 end
relative_path() click to toggle source

Returns the path of this project relative to the path of the containing platform.

   # File lib/drupid/platform_project.rb
39 def relative_path
40   @local_path.relative_path_from(@platform.local_path)
41 end
subdir() click to toggle source

A subdirectory where this project is installed. For example, for ‘sites/all/modules/specialmodules/mymodule’, this method returns ‘specialmodules’; for ‘profiles/custom_profiles/myprofile’, this method returns ‘custom_profiles’; for ‘modules/node/tests/’, returns ‘node’.

   # File lib/drupid/platform_project.rb
48 def subdir
49   if core_project? or 'profile' == proj_type
50     return @local_path.parent.relative_path_from(@platform.local_path + (proj_type + 's'))
51   else
52     return @local_path.parent.relative_path_from(@platform.local_path + @platform.contrib_path + (proj_type + 's'))
53   end
54 end