├── README ├── Rakefile └── lib └── simplegit.rb /README: -------------------------------------------------------------------------------- 1 | SimpleGit Ruby Library 2 | ====================== 3 | 4 | This library calls git commands and returns the output. 5 | 6 | Author : Scott Chacon -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | Gem::manage_gems 3 | require 'rake/gempackagetask' 4 | 5 | spec = Gem::Specification.new do |s| 6 | s.platform = Gem::Platform::RUBY 7 | s.name = "simplegit" 8 | s.version = "0.1.1" 9 | s.author = "Scott Chacon" 10 | s.email = "schacon@gmail.com" 11 | s.summary = "A simple gem for using Git in Ruby code." 12 | s.files = FileList['lib/**/*'].to_a 13 | s.require_path = "lib" 14 | end 15 | 16 | Rake::GemPackageTask.new(spec) do |pkg| 17 | pkg.need_tar = true 18 | end 19 | 20 | task :default => "pkg/#{spec.name}-#{spec.version}.gem" do 21 | puts "generated latest version" 22 | end 23 | 24 | -------------------------------------------------------------------------------- /lib/simplegit.rb: -------------------------------------------------------------------------------- 1 | # a super simple example class to use git in ruby 2 | class SimpleGit 3 | 4 | def initialize(git_dir = '.') 5 | @git_dir = File.expand_path(git_dir) 6 | end 7 | 8 | def show(treeish = 'master') 9 | command("git show #{treeish}") 10 | end 11 | 12 | private 13 | 14 | def command(git_cmd) 15 | Dir.chdir(@git_dir) do 16 | return `#{git_cmd} 2>&1`.chomp 17 | end 18 | end 19 | 20 | end 21 | --------------------------------------------------------------------------------