Module: Ruboss4Ruby::Configuration
- Defined in:
- lib/ruboss4ruby/configuration.rb
Overview
Computes necessary configuration options from the environment. This can be used in Rails, Merb or standalone from the command line.
Constant Summary collapse
- APP_ROOT =
defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.(".")
Instance Method Summary collapse
-
#extract_names(project = nil) ⇒ Object
Extract project, package, controller names from the environment.
-
#list_as_files(dir_name) ⇒ Object
List files ending in *.as (ActionScript) in a given folder.
-
#list_mxml_files(dir_name) ⇒ Object
List files ending in *.mxml in a given folder.
Instance Method Details
#extract_names(project = nil) ⇒ Object
Extract project, package, controller names from the environment. This will respect config/ruboss.yml if it exists, you can override all of the defaults there. The defaults are:
-
base-package same as project name downcased
-
controller-name ‘ApplicationController’
Here’s a sample ruboss.yml file:
Ruboss code generation configuration options
By default flex models, commands, controllers and components are genearated into app/flex/<your rails project name> folder. If you’d like to customize the target folder (to say append a “com” package before your rails project name) uncomment the line below base-package must follow the usual flex package notation (a string separated by “.”)
base-package: com.pomodo
Main ruboss controller is typically named AppicationController. This controller is created in <base-package>.controllers folder. You can customize the name by uncommenting the following line and changing the controller name.
controller-name: ApplicationController
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ruboss4ruby/configuration.rb', line 43 def extract_names(project = nil) if project project_name = project.camelcase.gsub(/\s/, '') project_name_downcase = project_name.downcase else project_name = APP_ROOT.split("/").last.camelcase.gsub(/\s/, '') project_name_downcase = project_name.downcase end # give a chance to override the settings via ruboss.yml begin config = YAML.load(File.open("#{APP_ROOT}/config/ruboss.yml")) base_package = config['base-package'] || project_name_downcase base_folder = base_package.gsub('.', '/').gsub(/\s/, '') project_name = config['project-name'].camelcase.gsub(/\s/, '') || project_name controller_name = config['controller-name'] || "ApplicationController" rescue base_folder = base_package = project_name_downcase controller_name = "ApplicationController" end [project_name, project_name_downcase, controller_name, base_package, base_folder] end |
#list_as_files(dir_name) ⇒ Object
List files ending in *.as (ActionScript) in a given folder
67 68 69 |
# File 'lib/ruboss4ruby/configuration.rb', line 67 def list_as_files(dir_name) Dir.entries(dir_name).grep(/\.as$/).map { |name| name.sub(/\.as$/, "") }.join(", ") end |
#list_mxml_files(dir_name) ⇒ Object
List files ending in *.mxml in a given folder
72 73 74 |
# File 'lib/ruboss4ruby/configuration.rb', line 72 def list_mxml_files(dir_name) Dir.entries(dir_name).grep(/\.mxml$/).map { |name| name.sub(/\.mxml$/, "") } end |