Class: HMap::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/hmap/xc/workspace/workspace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(save_setting, projects) ⇒ Workspace

Returns a new instance of Workspace.



29
30
31
32
# File 'lib/hmap/xc/workspace/workspace.rb', line 29

def initialize(save_setting, projects)
  @save_setting = save_setting
  @projects = projects.map { |project| Project.new(project, self) }
end

Instance Attribute Details

#projectsObject (readonly)

Returns the value of attribute projects.



9
10
11
# File 'lib/hmap/xc/workspace/workspace.rb', line 9

def projects
  @projects
end

#save_settingObject (readonly)

Returns the value of attribute save_setting.



9
10
11
# File 'lib/hmap/xc/workspace/workspace.rb', line 9

def save_setting
  @save_setting
end

Class Method Details

.new_from_xcprojects(paths) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/hmap/xc/workspace/workspace.rb', line 21

def self.new_from_xcprojects(paths)
  paths.map do |path|
    ss = ProjectProductPath.new(path)
    projects = PBXHelper.projects(path)
    new(ss, projects)
  end
end

.new_from_xcworkspaces(paths) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/hmap/xc/workspace/workspace.rb', line 11

def self.new_from_xcworkspaces(paths)
  paths.flat_map do |path|
    xc = Xcodeproj::Workspace.new_from_xcworkspace(path)
    schemes = xc.schemes.values.uniq || []
    ss = WorkspaceProductPath.new(path)
    projects = PBXHelper.projects(*schemes)
    new(ss, projects)
  end
end

Instance Method Details

#all_target_headersObject



79
80
81
# File 'lib/hmap/xc/workspace/workspace.rb', line 79

def all_target_headers
  @projects.flat_map(&:targets).flat_map(&:all_target_headers)
end

#build_rootObject



34
35
36
# File 'lib/hmap/xc/workspace/workspace.rb', line 34

def build_root
  save_setting.build_root
end

#hmap_rootObject



50
51
52
53
# File 'lib/hmap/xc/workspace/workspace.rb', line 50

def hmap_root
  dir = build_root.dirname.dirname
  File.join(dir, Constants::HMAP_DIR)
end

#nameObject



42
43
44
# File 'lib/hmap/xc/workspace/workspace.rb', line 42

def name
  save_setting.name
end

#obj_rootObject



38
39
40
# File 'lib/hmap/xc/workspace/workspace.rb', line 38

def obj_root
  save_setting.obj_root
end

#remove_hmap_settings!Object



73
74
75
76
77
# File 'lib/hmap/xc/workspace/workspace.rb', line 73

def remove_hmap_settings!
  UserInterface.puts('[hmapfile] Cleanning hmap settings..............')
  FileUtils.rm_rf(hmap_root) if Dir.exist?(hmap_root)
  projects.each(&:remove_hmap_settings!)
end

#save_hmap_settings!Object



67
68
69
70
71
# File 'lib/hmap/xc/workspace/workspace.rb', line 67

def save_hmap_settings!
  UserInterface.puts('[hmapfile] Saving hmap settings..............')

  projects.each(&:save_hmap_settings!)
end

#workspace_dirObject



46
47
48
# File 'lib/hmap/xc/workspace/workspace.rb', line 46

def workspace_dir
  File.dirname(save_setting.path)
end

#write_hmapfile!Object



62
63
64
65
# File 'lib/hmap/xc/workspace/workspace.rb', line 62

def write_hmapfile!
  UserInterface.puts('[hmapfile] Starting generate hmap file..............')
  projects.each(&:write_hmapfile!)
end

#write_save!Object



55
56
57
58
59
60
# File 'lib/hmap/xc/workspace/workspace.rb', line 55

def write_save!
  UserInterface.puts("[hmapfile] Got workspace/project build directory..............")
  UserInterface.puts("[hmapfile] #{name} Build directory: #{hmap_root} ..............")
  write_hmapfile!
  save_hmap_settings!
end