Module: XcodeYamlizer

Defined in:
lib/xcode-yamlizer.rb,
lib/xcode-yamlizer/cli.rb,
lib/xcode-yamlizer/version.rb

Defined Under Namespace

Classes: Cli

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.convert_directory(dir, to_xcode) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/xcode-yamlizer.rb', line 127

def self.convert_directory(dir, to_xcode)
  puts "Conventering directory '#{dir}'..."
  files = []
  formats = to_xcode ? YAML_FORMATS : XCODE_FORMATS

  Dir.glob(dir+"**/*").each do |filename|
    if formats.include_filename? filename
      files += [filename]
  
    end
  end
  
  puts "Found:"
  puts files
  new_files = files.map do |file|
    convert_file file
  end
  puts "Finished!"
  return files, new_files
end

.convert_file(input) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/xcode-yamlizer.rb', line 148

def self.convert_file(input)
  result = nil
  if YAML_FORMATS.include_filename? input
    output = input.chomp(File.extname(input))
  elsif XCODE_FORMATS.include_filename? input
    output = "#{input}.yaml"

  end
  result = load(input)
  dump(output, result)
  if result
    puts "#{input} => #{output}"
    return output
  else
    puts "Don't know what to do with '#{input}'"
  end
end

.make_filepaths_non_relative(files) ⇒ Object



170
171
172
173
174
# File 'lib/xcode-yamlizer.rb', line 170

def self.make_filepaths_non_relative files
  files.map do |file|
    file.sub(/^\.\//,"")
  end
end

.rootObject



166
167
168
# File 'lib/xcode-yamlizer.rb', line 166

def self.root
  return File.expand_path('../..', __FILE__)
end

.run_post_mergeObject



187
188
189
190
# File 'lib/xcode-yamlizer.rb', line 187

def self.run_post_merge
  chroot_to_repo()
  convert_directory('./', true)
end

.run_pre_commitObject



176
177
178
179
180
181
182
183
184
185
# File 'lib/xcode-yamlizer.rb', line 176

def self.run_pre_commit
  chroot_to_repo()
  files_remove, files_add = convert_directory('./', false)
  files_remove = make_filepaths_non_relative files_remove
  files_add = make_filepaths_non_relative files_add
  repo_add_files files_add

  repo_remove_files files_remove
  repo_gitignore_add_files files_remove
end