class GitHelper

Public Class Methods

new() click to toggle source
# File lib/git_helper.rb, line 109
def initialize
  if Dir['*.xcodeproj'].empty?
    puts 'Could not find an Xcode project file. You need to run me from a valid project directory.'
    exit
  end
end

Public Instance Methods

generate_files() click to toggle source
# File lib/git_helper.rb, line 116
def generate_files
  generate_gitignore
  generate_gitattributes
end

Private Instance Methods

generate_gitattributes() click to toggle source
# File lib/git_helper.rb, line 127
def generate_gitattributes
  write_unique_contents_to_file(GITATTRIBUTES_CONTENTS, '.gitattributes')
end
generate_gitignore() click to toggle source
# File lib/git_helper.rb, line 123
def generate_gitignore
  write_unique_contents_to_file(GITIGNORE_CONTENTS, '.gitignore')
end
write_unique_contents_to_file(contents, filename) click to toggle source
# File lib/git_helper.rb, line 131
def write_unique_contents_to_file(contents, filename)
  if File.exists? filename
    current_file_contents = File.read(filename).split("\n")
  else
    current_file_contents = []
  end

  new_contents = current_file_contents + contents.split("\n")
  File.open(filename, 'w') do |file|
    file.write(new_contents.uniq.join("\n"))
  end
end