Class: Tzispa::Command::Project
- Inherits:
-
Object
- Object
- Tzispa::Command::Project
- Defined in:
- lib/tzispa/command/project.rb
Constant Summary collapse
- PROJECT_STRUCTURE =
[ 'apps', 'config', 'config/locales', 'data', 'data/session', 'logs', 'public', 'public/css', 'public/css/fonts', 'public/css/less', 'public/img', 'public/js', 'repository', 'tmp' ]
- PROJECT_FILE =
'.tzispaprj'
- START_FILE =
'start.ru'
- PUMA_CONFIG_FILE =
'puma.rb'
- DEFAULT_MOUNT_PATH =
'/'
Instance Attribute Summary collapse
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#created ⇒ Object
Returns the value of attribute created.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #generate ⇒ Object
-
#initialize(name) ⇒ Project
constructor
A new instance of Project.
- #to_h ⇒ Object
Constructor Details
#initialize(name) ⇒ Project
Returns a new instance of Project.
34 35 36 37 |
# File 'lib/tzispa/command/project.rb', line 34 def initialize(name) @name = name @apps = Array.new end |
Instance Attribute Details
#apps ⇒ Object
Returns the value of attribute apps.
32 33 34 |
# File 'lib/tzispa/command/project.rb', line 32 def apps @apps end |
#created ⇒ Object
Returns the value of attribute created.
32 33 34 |
# File 'lib/tzispa/command/project.rb', line 32 def created @created end |
#name ⇒ Object
Returns the value of attribute name.
32 33 34 |
# File 'lib/tzispa/command/project.rb', line 32 def name @name end |
Class Method Details
.check? ⇒ Boolean
49 50 51 |
# File 'lib/tzispa/command/project.rb', line 49 def self.check? File.exist? "#{PROJECT_FILE}" end |
.open ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/tzispa/command/project.rb', line 53 def self.open raise "This command must be runned in a Tzispa project base dir" unless self.check? hpj = JSON.parse String.new.tap { |ptxt| File.open("#{PROJECT_FILE}","r") do |f| while line = f.gets ptxt << line end end } self.new(hpj['name']).tap { |project| project.apps = hpj['apps'] project.created = hpj['created'] } end |
Instance Method Details
#close ⇒ Object
68 69 70 |
# File 'lib/tzispa/command/project.rb', line 68 def close save to_h end |
#generate ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/tzispa/command/project.rb', line 40 def generate if create_structure create_project create_start create_pumaconfig create_i18n 'en' end end |
#to_h ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/tzispa/command/project.rb', line 72 def to_h Hash.new.tap { |h| h['name'] = name h['apps'] = apps h['created'] = created } end |