Class: Rays::Project
- Inherits:
-
Object
- Object
- Rays::Project
- Defined in:
- lib/rays/models/project.rb
Instance Attribute Summary collapse
-
#liferay ⇒ Object
readonly
Returns the value of attribute liferay.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.create(name) ⇒ Object
Create new project with a given name.
-
.init ⇒ Object
Parse current directory and try to initialize rays project on it.
-
.instance ⇒ Object
Get a project instance.
Instance Method Summary collapse
-
#initialize ⇒ Project
constructor
A new instance of Project.
Constructor Details
#initialize ⇒ Project
Returns a new instance of Project.
29 30 31 32 33 34 35 36 |
# File 'lib/rays/models/project.rb', line 29 def initialize project_config_file = "#{$rays_config.project_root}/config/project.yml" project_config = YAML::load_file(project_config_file) @name = project_config['name'] @version = project_config['version'] @liferay = project_config['liferay'] @package = project_config['package'] end |
Instance Attribute Details
#liferay ⇒ Object (readonly)
Returns the value of attribute liferay.
27 28 29 |
# File 'lib/rays/models/project.rb', line 27 def liferay @liferay end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/rays/models/project.rb', line 27 def name @name end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
27 28 29 |
# File 'lib/rays/models/project.rb', line 27 def package @package end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
27 28 29 |
# File 'lib/rays/models/project.rb', line 27 def version @version end |
Class Method Details
.create(name) ⇒ Object
Create new project with a given name
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rays/models/project.rb', line 49 def create(name) project_root = File.join(Dir.pwd, name) raise RaysException.new("Folder name #{name} already exists") if Dir.exist?(project_root) unless rays_exec("mkdir #{project_root}") raise RaysException.new("Cannot create directory #{name}") end copy_template_to project_root init_project(project_root) end |
.init ⇒ Object
Parse current directory and try to initialize rays project on it.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rays/models/project.rb', line 63 def init project_root = Dir.pwd is_a_project = true begin $rays_config.project_root rescue RaysException => e is_a_project = false end if is_a_project raise RaysException.new("this project is already initialized.") end project_name = File.basename(Dir.pwd) $log.info("init project #{project_name}") copy_template_to project_root init_project(project_name) module_types = AppModule::Manager.instance.module_types module_types.values.each do |module_class| names = Utils::FileUtils.find_directories(module_class.base_path) unless names.nil? names.each do |name| AppModule::Manager.instance.create(module_class.type, name) end end end $log.info("done") end |
.instance ⇒ Object
Get a project instance
42 43 44 |
# File 'lib/rays/models/project.rb', line 42 def instance self.new end |