class ProjectTools

A collection of utility methods to help working with ActionScript source.

Public Class Methods

common_src_dirs() click to toggle source

Returns an array of directory names that are commonly used as the root directory for source files.

# File lib/shed/project_tools.rb, line 12
def self.common_src_dirs
  ['src','source','test','lib']
end
flex_file_regx() click to toggle source

Regular expression to match files we expect to find in a ActionScript/Flex project.

# File lib/shed/project_tools.rb, line 56
def self.flex_file_regx
  /\.(as|mxml|asdoc|fxg)$/
end
import(path) click to toggle source

Takes a file path and converts it to a import path using conventionally named source folders as the root marker.

# File lib/shed/project_tools.rb, line 48
def self.import(path)
  truncate_to_src(path).gsub('/','.').sub(flex_file_regx,'')
end
package(path) click to toggle source

Takes a file path and converts it to a package path using conventionally named source folders as the root marker.

# File lib/shed/project_tools.rb, line 38
def self.package(path)
  path = remove_relative_prefix(path)
  path = File.dirname(path) if path =~ flex_file_regx
  truncate_to_src(path).gsub('/','.')
end
remove_relative_prefix(path) click to toggle source

Removes any relative prefixes found in the provided path.

# File lib/shed/project_tools.rb, line 30
def self.remove_relative_prefix(path)
  path.sub(/^\W+\b/, '')
end
truncate_to_src(path) click to toggle source

Takes a file path and truncates it to the last matching conventionally named source directory.

# File lib/shed/project_tools.rb, line 20
def self.truncate_to_src(path)
  common_src_dirs.each do |remove|
    path = path.gsub(/^.*\b#{remove}\b(\/|$)/, '');
  end
  path
end