Sha256: cf485a7aa5d4210fd27c75b1f105b3a66dc2b7c70ff747b42e3e06d691e9cddb
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
class GitPresenter::Controller CONFIG_FILE = ".presentation" def initialize(file_path) @presentation_dir = file_path end def initialise_presentation yaml = {"slides" => create_slides}.to_yaml File.open(presentation_file_location, "w") do |file| file.write(yaml) end puts "Presentation has been initalised" puts "run 'git-presenter start' to begin the presentation" end def start_presentation yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby presenter = GitPresenter::Presentation.new(yaml) puts presenter.start presenter end def update_presentation yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby slides = create_slides(yaml['slides'].last["slide"]["commit"]) last_commit = yaml["slides"].last yaml["slides"] = yaml["slides"] + slides yaml["slides"].uniq! write_file(yaml.to_yaml) puts "Your presentation has been updated" end private def write_file(yaml) File.open(presentation_file_location, "w") do |file| file.write(yaml) end end def presentation_file_location File.join(@presentation_dir, CONFIG_FILE) end def create_slides(last_commit=nil) repo = Grit::Repo.new(".", "master") commits = repo.commits("master", false).reverse commits = commits.drop_while{|commit| commit.id != last_commit}[1..-1] unless last_commit.nil? commits.map do |commit| {"slide" => {"commit" => commit.id, "message" => commit.message} } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
git_presenter-0.4.0 | lib/git_presenter/controller.rb |
git_presenter-0.3.0 | lib/git_presenter/controller.rb |