Class: LearnGenerate::IosLab

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_generate/ios_lab.rb,
lib/learn_generate/ios_lab/liftoff_backup.rb

Defined Under Namespace

Classes: LiftoffBackup

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lab_name) ⇒ IosLab

Returns a new instance of IosLab.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/learn_generate/ios_lab.rb', line 7

def initialize(lab_name)
  @lab_name = lab_name
  @liftoff_installed = !(`brew ls --versions liftoff 2>/dev/null`.strip.empty?)
  @liftoffrc_exists = File.exists?(File.expand_path('~/.liftoffrc'))
  @liftoff_dir_exists = File.exists?(File.expand_path('~/.liftoff'))
  @liftoff_backup = LearnGenerate::IosLab::LiftoffBackup.new
  templates_path     = File.expand_path('~/.learn-generate/templates')
  templates_git_path = File.expand_path('~/.learn-generate/templates/.git')
  @has_templates_dir = File.exists?(templates_path) && File.directory?(templates_path) && File.exists?(templates_git_path) && File.directory?(templates_git_path)
  @full_templates_path = templates_path + '/templates'
end

Instance Attribute Details

#full_templates_pathObject (readonly)

Returns the value of attribute full_templates_path.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def full_templates_path
  @full_templates_path
end

#has_templates_dirObject (readonly)

Returns the value of attribute has_templates_dir.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def has_templates_dir
  @has_templates_dir
end

#lab_nameObject (readonly)

Returns the value of attribute lab_name.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def lab_name
  @lab_name
end

#liftoff_backupObject (readonly)

Returns the value of attribute liftoff_backup.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def liftoff_backup
  @liftoff_backup
end

#liftoff_dir_existsObject (readonly)

Returns the value of attribute liftoff_dir_exists.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def liftoff_dir_exists
  @liftoff_dir_exists
end

#liftoff_installedObject (readonly)

Returns the value of attribute liftoff_installed.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def liftoff_installed
  @liftoff_installed
end

#liftoffrc_existsObject (readonly)

Returns the value of attribute liftoffrc_exists.



3
4
5
# File 'lib/learn_generate/ios_lab.rb', line 3

def liftoffrc_exists
  @liftoffrc_exists
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
# File 'lib/learn_generate/ios_lab.rb', line 19

def execute
  exit_if_no_liftoff
  backup_if_necessary
  copy_settings_files
  system("liftoff -n #{lab_name}")
  restore_if_necessary
end