Class: Synx::Project
- Inherits:
-
Xcodeproj::Project
- Object
- Xcodeproj::Project
- Synx::Project
- Defined in:
- lib/synx/project.rb
Instance Attribute Summary collapse
-
#delayed_groups_set_path ⇒ Object
Returns the value of attribute delayed_groups_set_path.
-
#group_exclusions ⇒ Object
Returns the value of attribute group_exclusions.
-
#prune ⇒ Object
Returns the value of attribute prune.
-
#sort_by_name ⇒ Object
Returns the value of attribute sort_by_name.
Instance Method Summary collapse
- #has_object_for_pathname?(pathname) ⇒ Boolean
- #pathname_is_inside_root_pathname?(grandchild_pathname) ⇒ Boolean
-
#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.
- #presync_check ⇒ Object
- #root_pathname ⇒ Object
- #sync(options = {}) ⇒ Object
- #work_pathname_to_pathname(work_pathname) ⇒ Object
- #work_root_pathname ⇒ Object
Instance Attribute Details
#delayed_groups_set_path ⇒ Object
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_exclusions ⇒ Object
Returns the value of attribute group_exclusions.
13 14 15 |
# File 'lib/synx/project.rb', line 13 def group_exclusions @group_exclusions end |
#prune ⇒ Object
Returns the value of attribute prune.
13 14 15 |
# File 'lib/synx/project.rb', line 13 def prune @prune end |
#sort_by_name ⇒ Object
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
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
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_check ⇒ Object
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_pathname ⇒ Object
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(={}) () 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_pathname ⇒ Object
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 |