class ApiTommy::Github
Public Instance Methods
clone_wiki(dir)
click to toggle source
# File lib/api_tommy/github.rb, line 23 def clone_wiki(dir) git = Grit::Git.new("/tmp/filling-in") git.clone({}, wiki_url, dir) end
push(dir, file)
click to toggle source
# File lib/api_tommy/github.rb, line 32 def push(dir, file) repo = Grit::Repo.new(dir) Dir.chdir(dir) { repo.add(file) } repo.commit_index("Update #{file}") repo.git.push({}, "origin", "master") end
update_file(dir, file, content)
click to toggle source
# File lib/api_tommy/github.rb, line 28 def update_file(dir, file, content) File.open(File.join(dir, file), "w") { |f| f.write(content) } end
update_wiki(file, content)
click to toggle source
# File lib/api_tommy/github.rb, line 6 def update_wiki(file, content) Dir.mktmpdir("api_tommy") do |dir| clone_wiki(dir) update_file(dir, file, content) push(dir, file) end rescue => e raise Error, "Can't update wiki (#{e.message})" end
wiki_url()
click to toggle source
# File lib/api_tommy/github.rb, line 16 def wiki_url return @wiki_url if defined?(@wiki_url) origin = Grit::Repo.new(Dir.pwd).config["remote.origin.url"] @wiki_url = origin.gsub(".git", ".wiki.git") if origin @wiki_url end