Top Level Namespace

Defined Under Namespace

Modules: Enumerable, XcodeYamlizer Classes: Dumper, PlistDumper, XmlDumper, YamlDumper

Constant Summary collapse

YAML_FORMATS =
[".yaml", ".yml"]
PLIST_FORMATS =
[".pbxproj"]
XML_FORMATS =
[".xib", ".storyboard", \
    /(.*).xcdatamodeld\/(.*).xcdatamodel\/contents$/, \
    /(.*).xccurrentversion$/
]
XCODE_FORMATS =
PLIST_FORMATS + XML_FORMATS
DUMPERS =
[
  [YAML_FORMATS, YamlDumper],
  [PLIST_FORMATS, PlistDumper],
  [XML_FORMATS, XmlDumper],
]

Instance Method Summary collapse

Instance Method Details

#chroot_to_repoObject



109
110
111
112
# File 'lib/xcode-yamlizer.rb', line 109

def chroot_to_repo
  root = File.expand_path("..",Rugged::Repository.discover(Dir.pwd))
  Dir.chdir(root)
end

#dump(output, object) ⇒ Object



52
53
54
55
56
57
# File 'lib/xcode-yamlizer.rb', line 52

def dump(output, object)
  dumper = dumper_for_filename(output)
  if dumper
    dumper.dump(object)
  end
end

#dumper_for_filename(filename) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/xcode-yamlizer.rb', line 42

def dumper_for_filename(filename)
  DUMPERS.each do |formats, dumper|
    if formats.include_filename? filename
      return dumper.new(filename)
    end
  end
  return nil
end

#load(input) ⇒ Object



58
59
60
61
62
63
# File 'lib/xcode-yamlizer.rb', line 58

def load(input)
  dumper = dumper_for_filename(input)
  if dumper
    return dumper.load()
  end
end

#repo_add_files(files) ⇒ Object



67
68
69
70
71
# File 'lib/xcode-yamlizer.rb', line 67

def repo_add_files(files)
  files.each do |file|
    `git add '#{file}'`
  end
end

#repo_gitignore_add_files(files) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/xcode-yamlizer.rb', line 79

def repo_gitignore_add_files(files)
  begin
    already_ignored = IO.foreach(".gitignore").map do |line|
      line.chomp
    end
  rescue Errno::ENOENT
    already_ignored = []
  end
  
  new_ignored = files - already_ignored

  if new_ignored.count > 0
    File.open(".gitignore", "a") do |f|
      f.puts "# XcodeYamlizer"
      new_ignored.each do |line|
        f.puts line
      end
      f.puts "# end"
    end
    
    puts "added to .gitignore:"
    puts new_ignored
    repo_add_files [".gitignore"]

  end
  


end

#repo_remove_files(files) ⇒ Object



73
74
75
76
77
# File 'lib/xcode-yamlizer.rb', line 73

def repo_remove_files(files)
  files.each do |file|
      `git rm --cached '#{file}'`
  end
end