spec/support/git_helpers.rb in git_presenter-0.3.0 vs spec/support/git_helpers.rb in git_presenter-0.4.0

- old
+ new

@@ -69,14 +69,14 @@ yield(commits, yaml) if block_given? end commits end - def start_presentation(command="", add_command_to_commit=nil) + def start_presentation(commands=[]) commits = initialise_presentation({:delay => true}) Dir.chdir(@presentation_dir) do - add_command(command, add_command_to_commit) unless command.empty? + add_commands(commands) unless commands.empty? presenter = GitPresenter.new('.', false) presenter = presenter.execute('start') yield(commits, presenter) if block_given? end end @@ -98,9 +98,34 @@ File.open(File.open(File.join(@presentation_dir, ".presentation")), "w") do |file| file.write(yaml.to_yaml) end end removed_commit + end + + def add_commands(commands) + commands.each do |command| + if command.include?(:run) + add_command(command[:run], command[:on_slide]) + end + if command.include?(:launch) + add_launch(command[:launch], command[:on_slide]) + end + end + end + + def add_launch(command, add_command_to_commit=nil) + Dir.chdir(PRESENTATION_DIR) do + presentation = YAML.parse(File.open(".presentation")).to_ruby + if !add_command_to_commit.nil? + presentation["slides"][add_command_to_commit]["slide"]["launch"] = command + else + presentation["slides"] << {"slide" => {"launch" => command}} + end + File.open(".presentation", "w") do |file| + file.write(presentation.to_yaml) + end + end end def add_command(command, add_command_to_commit=nil) Dir.chdir(PRESENTATION_DIR) do presentation = YAML.parse(File.open(".presentation")).to_ruby