Class: AsProject::Project

Inherits:
PathFinder show all
Defined in:
lib/project.rb

Direct Known Subclasses

EclipseProject

Constant Summary collapse

@@DEFAULT_TEST_DIR =
'test'
@@DEFAULT_LIBRARY_DIR =
'lib'
@@DEFAULT_BINARY_DIR =
'bin'
@@DEFAULT_AS2_TEMPLATES =
['as2']
@@DEFAULT_AS3_TEMPLATES =
['as3']

Instance Attribute Summary

Attributes inherited from PathFinder

#execution_dir

Attributes inherited from TemplateResolver

#ignore_all, #replace_all

Instance Method Summary collapse

Methods inherited from PathFinder

#asproject_player_trust, #current_project, #current_project=, #downloads, #flash_player_config, #flash_player_config_content, #flash_player_home, #flash_player_log, #flash_player_trust, #gem_asproject_home, #get_available_templates, #get_children, #get_gem_template, #get_project_template, #get_template, #get_user_template, #lib_downloads, #mxmlc, #remote_file_task, #user, #user_asproject_home, #user_home, #user_library

Methods inherited from TemplateResolver

#b, #clean_file_name, #copy_file, #copy_files, #is_binary?, #project_name, #render_file, #should_render?, #write_file?

Constructor Details

#initialize(dir = nil) ⇒ Project

Returns a new instance of Project.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/project.rb', line 18

def initialize(dir=nil)
  @project_name                     = nil
  @source_dir                       = @@DEFAULT_SOURCE_DIR
  @test_dir                         = @@DEFAULT_TEST_DIR
  @library_dir                      = @@DEFAULT_LIBRARY_DIR
  @binary_dir                       = @@DEFAULT_BINARY_DIR
  @default_templates                = @@DEFAULT_AS3_TEMPLATES
  @class_path                       = [@source_dir, @test_dir]
  if(dir.nil?)
    @execution_dir                  = Dir.pwd
  else
    @execution_dir                  = dir
  end
  super(@execution_dir)
  @project_path                   = current_project
end

Instance Method Details

#binary_dirObject



71
72
73
# File 'lib/project.rb', line 71

def binary_dir
  return resolve_location(@binary_dir)
end

#find_project(dir) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/project.rb', line 35

def find_project(dir)
  project = super(dir)
  config_file = File.join(dir, 'config', 'asclass_config.rb')
  rakefile = File.join(dir, 'rakefile.rb')
  if(File.exists?(rakefile))
    require rakefile
    @default_templates = DEFAULT_TEMPLATES
  elsif(File.exists?(File.join(dir, '.as2_classpath')))
    @default_templates = @@DEFAULT_AS2_TEMPLATES
  elsif(File.exists?(File.join(dir, '.actionScriptProperties')))
    @default_templates = @@DEFAULT_AS3_TEMPLATES
  end
  
  # Include the config file if found
  #if(File.exists?(config_file))
  #  require config_file
  #  class << self
  #    include Config
  #  end
  #  initialize_config
  #end
  return project
end

#library_dirObject



67
68
69
# File 'lib/project.rb', line 67

def library_dir
  return resolve_location(@library_dir)
end

#resolve_location(loc) ⇒ Object



75
76
77
78
79
80
# File 'lib/project.rb', line 75

def resolve_location(loc)
  if(!loc.index(@execution_dir))
    return File.join(@execution_dir, loc)
  end
  return loc
end

#source_dirObject



59
60
61
# File 'lib/project.rb', line 59

def source_dir
  return resolve_location(@source_dir)
end

#test_dirObject



63
64
65
# File 'lib/project.rb', line 63

def test_dir
  return resolve_location(@test_dir)
end