Class: Drupid::ProjectInfo

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/drupid/project.rb

Overview

A convenience class that encapsulates methods for detecting some project’s properties from a local copy of a project.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(project_or_info_path) ⇒ ProjectInfo

The argument must be the path to a .info file or a project directory. If the path to a directory is passed, then this object will try automatically detect the .info file inside the directory, which is not a trivial task because, among the rest,

  • the .info file may be located in some sub-directory;

  • there may be more than one .info file;

  • the .info file name may be unrelated to the name of its containing directories.

Faithful to its name, Drupid won’t try to be too keen, and it will raise an exception if it cannot reliably detect a .info file.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/drupid/project.rb', line 57

def initialize(project_or_info_path)
  p = Pathname.new(project_or_info_path).realpath # must exist
  @project_core = nil
  @project_type = nil
  @project_version = nil
  if '.info' == p.extname
    @project_name = p.basename('.info').to_s
    @info_file = p
    grandparent = @info_file.parent.parent
    if grandparent.basename.to_s == @project_name
      @project_dir = grandparent
    else
      @project_dir = @info_file.parent
    end
  else
    @project_name = p.basename.to_s
    @project_dir = p
    @info_file = _identify_main_info_file
  end
  debug "Parsing project info from #{@info_file}"
  _parse_info_file
end

Instance Attribute Details

#info_fileObject (readonly)

The full path to the main .info file of this project



43
44
45
# File 'lib/drupid/project.rb', line 43

def info_file
  @info_file
end

#project_coreObject (readonly)

The project’s core compatibility number. See Drupid::VersionCore.



35
36
37
# File 'lib/drupid/project.rb', line 35

def project_core
  @project_core
end

#project_dirObject (readonly)

The full path to the project’s directory.



41
42
43
# File 'lib/drupid/project.rb', line 41

def project_dir
  @project_dir
end

#project_nameObject (readonly)

The project’s name.



33
34
35
# File 'lib/drupid/project.rb', line 33

def project_name
  @project_name
end

#project_typeObject (readonly)

The project’s type (‘core’, ‘module’, ‘theme’, ‘profile’).



39
40
41
# File 'lib/drupid/project.rb', line 39

def project_type
  @project_type
end

#project_versionObject (readonly)

The project’s version. See Drupid::Version.



37
38
39
# File 'lib/drupid/project.rb', line 37

def project_version
  @project_version
end

Instance Method Details

#core_project?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/drupid/project.rb', line 80

def core_project?
  @is_core_project
end