Class: Drupid::PlatformProject

Inherits:
Project show all
Defined in:
lib/drupid/platform_project.rb

Instance Attribute Summary collapse

Attributes inherited from Project

#core, #l10n_path, #l10n_url, #location, #proj_type

Attributes inherited from Component

#download_specs, #download_type, #download_url, #ignore_paths, #local_path, #name, #overwrite

Instance Method Summary collapse

Methods inherited from Project

#<=>, #==, #best_release, #core_project=, #core_project?, #dependencies, #drupal?, #extended_name, #extensions, #fetch, #fetch_release_history, #file_level_compare_with, from_s, #has_version?, #makefile, #profile?, #reload_project_info, #target_path, #update_download_url, #update_version, #version, #version=

Methods inherited from Component

#add_download_spec, #add_patch, #cached_location, #clear_patches, #clone, #directory_name, #directory_name=, #each_patch, #exist?, #extended_name, #fetch, #file_level_compare_with, #get_patch, #has_patches?, #ignore_path, #patch, #patched?, #patched_location, #subdir=, #to_s

Methods included from Utils

#blah, #bzr, #compare_paths, #curl, #cvs, #debug, #dont_debug, #git, #hg, #ignore_interrupts, #interactive_shell, #odie, #ofail, #ohai, #owarn, #runBabyRun, #svn, #tempdir, #uncompress, #which, #writeFile

Constructor Details

#initialize(proj_platform, project_or_info_path) ⇒ PlatformProject

Returns a new instance of PlatformProject.



27
28
29
30
31
32
33
34
35
36
# File 'lib/drupid/platform_project.rb', line 27

def initialize proj_platform, project_or_info_path
  pi = ProjectInfo.new(project_or_info_path)
  super(pi.project_name, pi.project_core)
  @info_file = pi.info_file
  @local_path = pi.project_dir
  @version = pi.project_version if pi.project_version
  @proj_type = pi.project_type
  @core_project = pi.core_project?
  @platform = proj_platform
end

Instance Attribute Details

#platformObject (readonly)

Returns the value of attribute platform.



25
26
27
# File 'lib/drupid/platform_project.rb', line 25

def platform
  @platform
end

Instance Method Details

#installed?(site = nil) ⇒ Boolean

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

Returns:

  • (Boolean)


80
81
82
83
84
85
86
87
88
# File 'lib/drupid/platform_project.rb', line 80

def installed? site = nil
  site_list = (site) ? [site] : platform.site_names
  site_list.each do |s|
    site_path = platform.sites_path + s
    next unless site_path.exist?
    return true if Drush.installed?(site_path, name, relative_path)
  end
  return false
end

#relative_pathObject

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



40
41
42
# File 'lib/drupid/platform_project.rb', line 40

def relative_path
  @local_path.relative_path_from(@platform.local_path)
end

#subdirObject

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’.



49
50
51
52
53
54
55
# File 'lib/drupid/platform_project.rb', line 49

def subdir
  if core_project? or 'profile' == proj_type
    return @local_path.parent.relative_path_from(@platform.local_path + (proj_type + 's'))
  else
    return @local_path.parent.relative_path_from(@platform.local_path + @platform.contrib_path + (proj_type + 's'))
  end
end