Class: Synx::Project

Inherits:
Xcodeproj::Project show all
Defined in:
lib/synx/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delayed_groups_set_pathObject

Returns the value of attribute delayed_groups_set_path.



13
14
15
# File 'lib/synx/project.rb', line 13

def delayed_groups_set_path
  @delayed_groups_set_path
end

#group_exclusionsObject

Returns the value of attribute group_exclusions.



13
14
15
# File 'lib/synx/project.rb', line 13

def group_exclusions
  @group_exclusions
end

#pruneObject

Returns the value of attribute prune.



13
14
15
# File 'lib/synx/project.rb', line 13

def prune
  @prune
end

#sort_by_nameObject

Returns the value of attribute sort_by_name.



13
14
15
# File 'lib/synx/project.rb', line 13

def sort_by_name
  @sort_by_name
end

Instance Method Details

#has_object_for_pathname?(pathname) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
117
118
119
120
121
122
123
# File 'lib/synx/project.rb', line 114

def has_object_for_pathname?(pathname)
  @unmodified_project ||= Synx::Project.open(path)
  @unmodified_project.objects.any? do |o|
    begin
      o.real_path.cleanpath == pathname.cleanpath
    rescue
      false
    end
  end
end

#pathname_is_inside_root_pathname?(grandchild_pathname) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/synx/project.rb', line 93

def pathname_is_inside_root_pathname?(grandchild_pathname)
  grandchild_pathname.realpath.to_s.start_with?(root_pathname.realpath.to_s)
end

#pathname_to_work_pathname(pathname) ⇒ Object

We build up the new project structure in a temporary workspace, so convert a file path in the project space to one in the temp workspace.



85
86
87
# File 'lib/synx/project.rb', line 85

def pathname_to_work_pathname(pathname)
  work_root_pathname + pathname.relative_path_from(root_pathname)
end

#presync_checkObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/synx/project.rb', line 30

def presync_check
  forward_slash_groups = main_group.groups_containing_forward_slash
  unless forward_slash_groups.empty?
    Synx::Tabber.puts "Synx cannot sync projects with groups that contain '/'. Please rename the following groups before running synx again:".yellow
    Synx::Tabber.increase
    forward_slash_groups.each do |group|
      Synx::Tabber.puts group.hierarchy_path
    end
    abort
  end
end

#root_pathnameObject



67
68
69
# File 'lib/synx/project.rb', line 67

def root_pathname
  @root_pathname ||= Pathname(path).parent
end

#sync(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/synx/project.rb', line 15

def sync(options={})
  set_options(options)
  presync_check
  Synx::Tabber.increase
  Synx::Tabber.puts "Syncing files that are included in Xcode project...".bold.white
  main_group.all_groups.each { |gr| gr.sync(main_group) }
  Synx::Tabber.puts "\n\n"
  Synx::Tabber.puts "Syncing files that are not included in Xcode project..".bold.white
  main_group.all_groups.each(&:move_entries_not_in_xcodeproj)
  main_group.sort_by_name if self.sort_by_name
  transplant_work_project
  Synx::Tabber.decrease
  save
end

#work_pathname_to_pathname(work_pathname) ⇒ Object



89
90
91
# File 'lib/synx/project.rb', line 89

def work_pathname_to_pathname(work_pathname)
  root_pathname + work_pathname.relative_path_from(work_root_pathname)
end

#work_root_pathnameObject



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/synx/project.rb', line 71

def work_root_pathname
  if @work_root_pathname
    @work_root_pathname
  else
    @work_root_pathname = Pathname(File.join(SYNXRONIZE_DIR, root_pathname.basename.to_s))
    # Clean up any previous synx and start fresh
    FileUtils.rm_rf(@work_root_pathname.to_s) if @work_root_pathname.exist?
    @work_root_pathname.mkpath
    @work_root_pathname
  end
end