| Class | Sprout::ProjectModel |
| In: |
sprout/lib/sprout/project_model.rb
|
| Parent: | Hash |
The ProjectModel gives you a place to describe your project so that you don‘t need to repeat yourself throughout a rakefile.
The default set of properties are also used from code generators, library tasks and sometimes tools.
The ProjectModel can be configured as follows:
project_model :model do |p|
p.name = 'SomeProject'
p.source_path << 'somedir/otherdir'
p.library_path << 'somedir'
end
This class should have some reasonable default values, but can be modified from any rakefile. If you don‘t find some properties that you‘d like on the ProjectModel, you can simply add new properties and use them however you wish.
Arbitrary properties can be added as follows:
m = project_model :model do |p|
p.unknown_property = 'someValue'
end
puts "Unknown Property: #{m.unknown_property}"
The ProjectModel is typically treated as if it is a Singleton, and many helper tasks will automatically go look for their model at:
Sprout::ProjectModel.instance
Unlike a real Singleton, this static property will actually be populated with the most recently instantiated ProjectModel, and any well-behaved helper task will also allow you to send in a model as a prerequisite.
project_model :model_a project_model :model_b desc 'Compile and run a' debug :debug_a => :model_a desc 'Compile and run b' debug :debug_b => :model_b
| asset_dir | [RW] | Relative path to the folder where compile time assets will be stored |
| background_color | [RW] | The Background Color of the SWF file |
| bin_dir | [RW] | The folder where binary files will be created. Usually this is where any build artifacts like SWF files get placed. |
| compiler_gem_name | [RW] |
If you don‘t want to use the default compiler for your language set
it manually here. Possible values are:
|
| compiler_gem_version | [RW] | The version number of the compiler gem to use |
| contributors | [RW] | Contributors to the SWF file |
| creator | [RW] | The primary creator of the SWF file |
| doc_dir | [RW] | Directory where documentation should be placed. |
| external_css | [RW] | CSS documents that should be individually compiled for runtime stylesheet loading. |
| frame_rate | [RW] | The default frame rate of the SWF file |
| height | [RW] | The default height of the SWF file _(This value is overridden when embedded in an HTML page)_ |
| language | [RW] | The technology language that is being used, right now this value can be ‘as2’, ‘as3’ or ‘mxml’. Code generators take advantage of this setting to determine which templates to use and build tasks use this setting to determin the input file suffix (.as or .mxml). |
| lib_dir | [RW] |
The relative path to your library directory. Defaults to ‘lib‘
Any remote .SWC and source libraries that are referenced in your rakefile will be installed into this directory. Source libraries will be placed in a folder that matches the library name, while SWCs will be simply placed directly into the lib_dir. |
| libraries | [RW] | Array of sprout library symbols |
| library_path | [RW] | The Array of SWC paths to add to all compilation tasks |
| locale | [RW] | The locale for the SWF file |
| modules | [RW] | A collection of Flex Module root source files. If this collection has items added to it, the deploy task will generate a ‘link_report’ from the main application compilation and then consume it as ‘load_externs’ for each module compilation. |
| organization | [RW] | Organization responsible for this SWF file |
| output | [RW] | The production file that this Project will generate |
| preprocessed_path | [RW] | Folder where preprocessed files will be created. Defaults to ’.preprocessed‘ |
| preprocessor | [RW] | Terminal command to preprocessor application that accepts STDIN and returns on STDOUT |
| project_name | [RW] | The real name of the project, usually capitalized like a class name ‘SomeProject‘ |
| skin_dir | [RW] | The folder where compile time skins can be loaded from |
| skin_output | [RW] | The skin file that will be generated |
| source_path | [RW] | The Array of source paths to add to all compilation tasks _Do not add task-specific paths (like lib/asunit) to this value_ |
| src_dir | [RW] | The relative path to your main source directory. Defaults to ‘src‘ |
| strict | [RW] | Enforce strict type checking |
| swc_dir | [RW] | The relative path to the directory where swc files should be kept. This value defaults to lib_dir |
| test_dir | [RW] | Relative path to the folder that contains your test cases |
| test_height | [RW] | The test runner SWF height |
| test_output | [RW] | The test executable |
| test_width | [RW] | The test runner SWF width |
| use_fcsh | [RW] | Tasks that can, will use the Flex Compiler SHell. |
| use_fdb | [RW] | Flash Player Tasks will launch using the Flex Debugger. |
| width | [RW] | The default width of the SWF file _(This value is overridden when embedded in an HTML page)_ |
Static method that returns the most recently instantiated ProjectModel, or instantiates one if none have been created yet.
# File sprout/lib/sprout/project_model.rb, line 139 def self.instance @@instance ||= ProjectModel.new yield @@instance if block_given? return @@instance end
# File sprout/lib/sprout/project_model.rb, line 156 def initialize super @project_name = '' @doc_dir = 'doc' @src_dir = 'src' @lib_dir = 'lib' @swc_dir = 'lib' @bin_dir = 'bin' @test_dir = 'test' @asset_dir = 'assets' @skin_dir = File.join(@asset_dir, 'skins') @frame_rate = 24 @language = 'as3' @external_css = [] @libraries = [] @library_path = [] @modules = [] @source_path = [] @model_dir = nil @view_dir = nil @controller_dir = nil @test_height = 550 @test_width = 900 @@instance = self end
Simple MVC helper for project-wide views if your project is called ‘SomeProject’ this will default to:
SomeProject/src/someproject/controllers
# File sprout/lib/sprout/project_model.rb, line 225 def controller_dir if(@controller_dir.nil?) @controller_dir = File.join(src_dir, project_name.downcase, 'controllers') end return @controller_dir end
# File sprout/lib/sprout/project_model.rb, line 218 def controller_dir=(dir) @controller_dir = dir end
Simple MVC helper for project-wide models if your project is called ‘SomeProject’ this will default to:
SomeProject/src/someproject/models
# File sprout/lib/sprout/project_model.rb, line 197 def model_dir if(@model_dir.nil?) @model_dir = File.join(src_dir, project_name.downcase, 'models') end return @model_dir end
Alias for project_name
# File sprout/lib/sprout/project_model.rb, line 233 def name=(name) @project_name = name end
Path to the project directory from which all other paths are created
# File sprout/lib/sprout/project_model.rb, line 186 def project_path return Sprout.project_path end
# File sprout/lib/sprout/project_model.rb, line 241 def to_s return "[Sprout::ProjectModel project_name=#{project_name}]" end
Simple MVC helper for project-wide views if your project is called ‘SomeProject’ this will default to:
SomeProject/src/someproject/views
# File sprout/lib/sprout/project_model.rb, line 211 def view_dir if(@view_dir.nil?) @view_dir = File.join(src_dir, project_name.downcase, 'views') end return @view_dir end