Class: Airake::Project

Inherits:
Object show all
Defined in:
lib/airake/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = nil, base_dir = nil, options = nil) ⇒ Project

Create project.

Options:

env: Environment, such as development, test, production. Defaults to ENV. base_dir: Base (project) directory. Defaults to ENV options: If nil, options are loaded from airake.yml in root. (All paths relative to base directory)

  • src_dirs: Paths to source

  • lib_dir: Path to lib directory

  • swf_path: Path to SWF file

  • debug: “true” or “false”

More options:

  • mxmlc_path

  • asdoc_path

  • mxmlc_extra_opts

  • asdoc_extra_opts



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/airake/project.rb', line 24

def initialize(env = nil, base_dir = nil, options = nil)            
  @env = env
  @env = ENV["AIRAKE_ENV"] if @env.nil?      
  base_dir = ENV["AIRAKE_ROOT"] if base_dir.nil?
  raise "Need to specify an AIRAKE_ROOT (project root)" if base_dir.blank?
  
  @base_dir = base_dir      
  
  if options.nil?
    conf_path = File.join(base_dir, "airake.yml")
    unless File.exist?(conf_path)
      raise <<-EOS 
    
        You are missing your #{conf_path} configuration file.
      
        For existing projects, please regenerate an airake project and look at Rakefile and airake.yml for an example.
      
      EOS
    end
    
    options = YAML.load_file(File.join(@base_dir, "airake.yml"))
    env_options = options[@env]
    options = options.merge(env_options) if env_options
    options.symbolize_keys!
  end
  
  load(options)
        
  ensure_exists([ *@src_dirs ])
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



5
6
7
# File 'lib/airake/project.rb', line 5

def base_dir
  @base_dir
end

#debugObject (readonly)

Returns the value of attribute debug.



5
6
7
# File 'lib/airake/project.rb', line 5

def debug
  @debug
end

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/airake/project.rb', line 5

def env
  @env
end

#lib_dirObject (readonly)

Returns the value of attribute lib_dir.



5
6
7
# File 'lib/airake/project.rb', line 5

def lib_dir
  @lib_dir
end

#src_dirsObject (readonly)

Returns the value of attribute src_dirs.



5
6
7
# File 'lib/airake/project.rb', line 5

def src_dirs
  @src_dirs
end

#swf_pathObject (readonly)

Returns the value of attribute swf_path.



5
6
7
# File 'lib/airake/project.rb', line 5

def swf_path
  @swf_path
end

Instance Method Details

#asdocObject

AS docs



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

def asdoc
  options = { :lib_dir => @lib_dir, :src_dirs => @src_dirs, :asdoc_extra_opts => @asdoc_extra_opts,
    :asdoc_path => @asdoc_path }        
  Airake::Commands::Asdoc.new(options)
end

#cleanObject

Remove files



74
75
76
# File 'lib/airake/project.rb', line 74

def clean
  FileUtils.rm(@swf_path, :verbose => true) if File.exist?(@swf_path)
end

#load(options = {}) ⇒ Object

Load options



56
57
58
59
60
61
62
63
64
# File 'lib/airake/project.rb', line 56

def load(options = {})
  @src_dirs = []      
  @src_dirs = options[:src_dirs].collect { |src_dir| File.join(base_dir, src_dir) } if options[:src_dirs]
    
  @lib_dir = File.join(base_dir, options[:lib_dir]) if options[:lib_dir]      
  @swf_path = File.join(base_dir, options[:swf_path])      
  
  with_keyed_options([ :debug ], options)      
end