Class: GitPresenter::Controller
- Inherits:
-
Object
- Object
- GitPresenter::Controller
- Defined in:
- lib/git_presenter/controller.rb
Constant Summary collapse
- CONFIG_FILE =
".presentation"
Instance Method Summary collapse
- #initialise_presentation ⇒ Object
-
#initialize(file_path) ⇒ Controller
constructor
A new instance of Controller.
- #load_presentation ⇒ Object
- #start_presentation ⇒ Object
- #update_presentation ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Controller
Returns a new instance of Controller.
4 5 6 |
# File 'lib/git_presenter/controller.rb', line 4 def initialize(file_path) @presentation_dir = file_path end |
Instance Method Details
#initialise_presentation ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/git_presenter/controller.rb', line 8 def initialise_presentation yaml = {"slides" => , "branch" => current_branch}.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 |
#load_presentation ⇒ Object
17 18 19 20 |
# File 'lib/git_presenter/controller.rb', line 17 def load_presentation yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby GitPresenter::Presentation.new(yaml) end |
#start_presentation ⇒ Object
22 23 24 25 26 |
# File 'lib/git_presenter/controller.rb', line 22 def start_presentation presenter = load_presentation puts presenter.start presenter end |
#update_presentation ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/git_presenter/controller.rb', line 28 def update_presentation yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby = (yaml['slides'].last["slide"]["commit"]) yaml["slides"] = yaml["slides"] + yaml["slides"].uniq! write_file(yaml.to_yaml) puts "Your presentation has been updated" end |