git_presenter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ #
6
+ gem "grit"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec"
12
+ gem "cucumber"
13
+ gem "bundler"
14
+ gem "jeweler"
15
+ gem "rcov", ">= 0"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ builder (3.0.0)
5
+ cucumber (1.1.2)
6
+ builder (>= 2.1.2)
7
+ diff-lcs (>= 1.1.2)
8
+ gherkin (~> 2.6.2)
9
+ json (>= 1.4.6)
10
+ term-ansicolor (>= 1.0.6)
11
+ diff-lcs (1.1.3)
12
+ gherkin (2.6.6)
13
+ json (>= 1.4.6)
14
+ git (1.2.5)
15
+ grit (2.4.1)
16
+ diff-lcs (~> 1.1)
17
+ mime-types (~> 1.15)
18
+ jeweler (1.6.4)
19
+ bundler (~> 1.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ json (1.6.1)
23
+ mime-types (1.17.2)
24
+ rake (0.9.2.2)
25
+ rcov (0.9.11)
26
+ rspec (2.7.0)
27
+ rspec-core (~> 2.7.0)
28
+ rspec-expectations (~> 2.7.0)
29
+ rspec-mocks (~> 2.7.0)
30
+ rspec-core (2.7.1)
31
+ rspec-expectations (2.7.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.7.0)
34
+ term-ansicolor (1.0.7)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ bundler
41
+ cucumber
42
+ grit
43
+ jeweler
44
+ rcov
45
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Colin Gemmell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,69 @@
1
+ # git-presenter
2
+
3
+ When presenting code live on stage you have a few choices:
4
+ * Change code live on stage and risk making a mistake and the code not working.
5
+ * Place code in a slide and not be able to run the code live.
6
+
7
+ Git-presenter hope to solve this problem by giving a presentation style interface for your code.
8
+
9
+ ## Current status
10
+
11
+ Early version but the basics are there to be used.
12
+ Any and all feedback is welcome
13
+
14
+ ## Pre-requisites
15
+
16
+ * Git
17
+ * Ruby
18
+
19
+ ## Installation
20
+
21
+ gem install git-presenter
22
+
23
+ ## Usage
24
+
25
+ Commit to git as you develop you code.
26
+ When the code is ready use the "git-presenter init" command to initialise
27
+ Once it is initialised you can start the presentation with "git-presenter start"
28
+ Then use the following command to navigate the presentation
29
+
30
+ next/n: move to next slide
31
+ back/b: move back a slide
32
+ end/e: move to end of presentation
33
+ start/s: move to start of presentation
34
+ list/l : list slides in presentation
35
+ help/h: display this message
36
+
37
+ ## Contributing to git-presenter
38
+
39
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
40
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
41
+ * Fork the project
42
+ * Start a feature/bugfix branch
43
+ * Commit and push until you are happy with your contribution
44
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
+
47
+ ## Copyright
48
+
49
+ Copyright (c) 2012 Colin Gemmell
50
+
51
+ Permission is hereby granted, free of charge, to any person obtaining
52
+ a copy of this software and associated documentation files (the
53
+ "Software"), to deal in the Software without restriction, including
54
+ without limitation the rights to use, copy, modify, merge, publish,
55
+ distribute, sublicense, and/or sell copies of the Software, and to
56
+ permit persons to whom the Software is furnished to do so, subject to
57
+ the following conditions:
58
+
59
+ The above copyright notice and this permission notice shall be
60
+ included in all copies or substantial portions of the Software.
61
+
62
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
63
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
65
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
66
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
67
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
68
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69
+
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "git_presenter"
18
+ gem.homepage = "http://github.com/pythonandchips/git-presenter"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Code presentation tool using git}
21
+ gem.description = %Q{Code presentation tool using git}
22
+ gem.email = "pythonandchips@gmail.com"
23
+ gem.authors = ["Colin Gemmell"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ require 'cucumber/rake/task'
40
+ Cucumber::Rake::Task.new(:features)
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "git_presenter #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/git-presenter ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require "rubygems"
4
+ require "readline"
5
+ require_relative "../lib/git_presenter"
6
+
7
+ if ARGV[0] == "init"
8
+ GitPresenter.initialise_presentation(Dir.pwd)
9
+ puts "Presentation has been initalised"
10
+ puts "run 'git-presenter start' to begin the presentation"
11
+ elsif ARGV[0] == "start"
12
+ presenter = GitPresenter.start_presentation(Dir.pwd)
13
+
14
+ while command = Readline.readline(presenter.status_line, true)
15
+ p presenter.execute(command)
16
+ end
17
+ else
18
+ puts "what you talkin bout willis"
19
+ end
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "git_presenter"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Colin Gemmell"]
12
+ s.date = "2012-03-20"
13
+ s.description = "Code presentation tool using git"
14
+ s.email = "pythonandchips@gmail.com"
15
+ s.executables = ["git-presenter"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.markdown"
19
+ ]
20
+ s.files = [
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.markdown",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/git-presenter",
29
+ "git_presenter.gemspec",
30
+ "lib/git_presenter.rb",
31
+ "spec/integration/initialize_presentation_spec.rb",
32
+ "spec/integration/moving_through_presentation_spec.rb",
33
+ "spec/integration/processing_user_command_spec.rb",
34
+ "spec/integration/start_presentation_spec.rb",
35
+ "spec/integration/status_line_spec.rb",
36
+ "spec/spec_helper.rb",
37
+ "spec/support/repo_helpers.rb"
38
+ ]
39
+ s.homepage = "http://github.com/pythonandchips/git-presenter"
40
+ s.licenses = ["MIT"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = "1.8.15"
43
+ s.summary = "Code presentation tool using git"
44
+
45
+ if s.respond_to? :specification_version then
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<grit>, [">= 0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
51
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, [">= 0"])
53
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<grit>, [">= 0"])
57
+ s.add_dependency(%q<rspec>, [">= 0"])
58
+ s.add_dependency(%q<cucumber>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, [">= 0"])
60
+ s.add_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<grit>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, [">= 0"])
66
+ s.add_dependency(%q<cucumber>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, [">= 0"])
68
+ s.add_dependency(%q<jeweler>, [">= 0"])
69
+ s.add_dependency(%q<rcov>, [">= 0"])
70
+ end
71
+ end
72
+
@@ -0,0 +1,116 @@
1
+ require "grit"
2
+
3
+ class GitPresenter
4
+ def initialize(commits)
5
+ @commits = commits
6
+ @current_commit = commits.first
7
+ end
8
+
9
+ def self.initialise_presentation dir
10
+ File.open(dir + "/.presentation", "w") do |file|
11
+ repo = Grit::Repo.new(".", "master")
12
+ repo.commits.reverse.each do |commit|
13
+ file.write("#{commit.id}\n")
14
+ end
15
+ end
16
+ end
17
+
18
+ def commits
19
+ @commits
20
+ end
21
+
22
+ def self.start_presentation dir
23
+ presenter = nil
24
+ File.open(dir + "/.presentation", "r") do |file|
25
+ commits = file.lines.map{|line| line.strip}
26
+ presenter = GitPresenter.new(commits)
27
+ presenter.start
28
+ end
29
+ presenter
30
+ end
31
+
32
+ def command_for(command)
33
+ return :commit if command =~ /^[0-9]+$/
34
+ {"n" => :next, "next" => :next,
35
+ "back" => :previous, "b" => :previous,
36
+ "start" => :start, "s" => :start,
37
+ "end" => :end, "e" => :end,
38
+ "list" => :list, "l" => :list,
39
+ "help" => :help, "h" => :help
40
+ }[command]
41
+ end
42
+
43
+ def execute(user_command)
44
+ command = command_for(user_command)
45
+ if command.nil?
46
+ puts "I canny understand ye, gonna try again"
47
+ return
48
+ end
49
+ return commit(user_command.to_i) if command == :commit
50
+ self.send(command)
51
+ end
52
+
53
+ def status_line
54
+ "#{position+1}/#{total_slides} >"
55
+ end
56
+
57
+ def position
58
+ commits.index(@current_commit)
59
+ end
60
+
61
+ def total_slides
62
+ @commits.length
63
+ end
64
+
65
+
66
+ def start
67
+ @current_commit = commits.first
68
+ checkout_current
69
+ end
70
+
71
+ def help
72
+ <<-EOH
73
+ Git Presenter Reference
74
+
75
+ next/n: move to next slide
76
+ back/b: move back a slide
77
+ end/e: move to end of presentation
78
+ start/s: move to start of presentation
79
+ list/l : list slides in presentation
80
+ help/h: display this message
81
+ EOH
82
+ end
83
+
84
+ def end
85
+ @current_commit = commits.last
86
+ checkout_current
87
+ end
88
+
89
+ def commit(slide_number)
90
+ @current_commit = commits[slide_number - 1]
91
+ checkout_current
92
+ end
93
+
94
+ def next
95
+ return if position.nil?
96
+ @current_commit = commits[position + 1]
97
+ checkout_current
98
+ end
99
+
100
+ def previous
101
+ position = commits.index(@current_commit)
102
+ @current_commit = commits[position - 1]
103
+ checkout_current
104
+ end
105
+
106
+ def list
107
+ commits = @commits.dup
108
+ position = commits.index(@current_commit)
109
+ commits[position] = "*#{commits[position]}"
110
+ commits.join("\n")
111
+ end
112
+
113
+ def checkout_current
114
+ `git checkout #{@current_commit}`
115
+ end
116
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe "initializing a presentation" do
4
+ let(:presentation_dir){File.dirname(__FILE__) + "/../../presentation"}
5
+
6
+ context ".presentation file" do
7
+ it "should be written to root directory" do
8
+ initialise_presentation do
9
+ File.exists?(".presentation").should be_true
10
+ end
11
+ end
12
+
13
+ it "should contain a line for each commit to the repository" do
14
+ initialise_presentation do |commits, file|
15
+ file.lines.to_a.length.should eql commits.length
16
+ end
17
+ end
18
+
19
+ it "first line should contain the first commit number" do
20
+ initialise_presentation(true) do |commits, file|
21
+ file.lines.first.should include commits.first.id
22
+ end
23
+ end
24
+
25
+ it "second line should contain the second commit number" do
26
+ initialise_presentation(true) do |commits, file|
27
+ file.lines.to_a[1].should include commits[1].id
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,104 @@
1
+ require "spec_helper"
2
+
3
+ describe "while giving presentation" do
4
+ let(:presentation_dir){File.dirname(__FILE__) + "/../../presentation"}
5
+
6
+ context "when moving to the next slide" do
7
+ it "should move to the next commit" do
8
+ start_presentation do |commits, presenter|
9
+ presenter.execute("next")
10
+ head_position.should eql commits[1].id
11
+ end
12
+ end
13
+
14
+ it "should continue till the last commit" do
15
+ start_presentation do |commits, presenter|
16
+ presenter.execute("next")
17
+ presenter.execute("next")
18
+ head_position.should eql commits[2].id
19
+ end
20
+ end
21
+ end
22
+
23
+ context "when the presentation reaches the end" do
24
+ it "should stay on the last commit" do
25
+ start_presentation do |commits, presenter|
26
+ presenter.execute("next")
27
+ presenter.execute("next")
28
+ presenter.execute("next")
29
+ presenter.execute("next")
30
+ head_position.should eql commits[2].id
31
+ end
32
+ end
33
+ end
34
+
35
+ context "when going back through the presentation" do
36
+ it "should o go back to a previous commit" do
37
+ start_presentation do |commits, presenter|
38
+ presenter.execute("next")
39
+ presenter.execute("next")
40
+ presenter.execute("back")
41
+ head_position.should eql commits[1].id
42
+ end
43
+ end
44
+ end
45
+
46
+ context "when going back to the start of the presention" do
47
+ it "should move to the first commit" do
48
+ start_presentation do |commits, presenter|
49
+ presenter.execute("next")
50
+ presenter.execute("next")
51
+ presenter.execute("start")
52
+ head_position.should eql commits[0].id
53
+ end
54
+ end
55
+ end
56
+
57
+ context "when going to the end of the presentation" do
58
+ it "should move the last commit" do
59
+ start_presentation do |commits, presenter|
60
+ presenter.execute("end")
61
+ head_position.should eql commits.last.id
62
+ end
63
+ end
64
+ end
65
+
66
+ context "when going to a specific slide" do
67
+ it "should checkout the specific commit" do
68
+ start_presentation do |commits, presenter|
69
+ presenter.execute("2")
70
+ head_position.should eql commits[1].id
71
+ end
72
+ end
73
+ end
74
+
75
+ context "list presentation" do
76
+ it "should print a list of commits" do
77
+ start_presentation do |commits, presenter|
78
+ commits[0] = "*#{commits[0]}"
79
+ expected_output = commits.join("\n")
80
+ presentation = presenter.execute("list")
81
+ presentation.should eql expected_output
82
+ end
83
+ end
84
+ end
85
+
86
+ context "when asking for help" do
87
+ it "should print a list of command and there usage" do
88
+ start_presentation do |commits, presenter|
89
+ help_text = <<-EOH
90
+ Git Presenter Reference
91
+
92
+ next/n: move to next slide
93
+ back/b: move back a slide
94
+ end/e: move to end of presentation
95
+ start/s: move to start of presentation
96
+ list/l : list slides in presentation
97
+ help/h: display this message
98
+ EOH
99
+ message = presenter.execute("help")
100
+ message.should eql help_text
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ describe "when receiving a user command" do
4
+
5
+ def given_command(command)
6
+ presenter = GitPresenter.new([])
7
+ presenter.command_for(command)
8
+ end
9
+
10
+ context "with next" do
11
+ it { given_command("next").should eql :next }
12
+ end
13
+
14
+ context "with next" do
15
+ it { given_command("n").should eql :next }
16
+ end
17
+
18
+ context "with back" do
19
+ it { given_command("back").should eql :previous }
20
+ end
21
+
22
+ context "with b" do
23
+ it { given_command("b").should eql :previous }
24
+ end
25
+
26
+ context "with start" do
27
+ it { given_command("start").should eql :start }
28
+ end
29
+
30
+ context "with s" do
31
+ it { given_command("s").should eql :start }
32
+ end
33
+
34
+ context "with end" do
35
+ it { given_command("end").should eql :end }
36
+ end
37
+
38
+ context "with e" do
39
+ it { given_command("e").should eql :end }
40
+ end
41
+
42
+ context "with list" do
43
+ it { given_command("list").should eql :list }
44
+ end
45
+
46
+ context "with l" do
47
+ it { given_command("l").should eql :list }
48
+ end
49
+
50
+ context "with any number" do
51
+ it { given_command("6").should eql :commit}
52
+ end
53
+
54
+ context "with h" do
55
+ it { given_command("h").should eql :help}
56
+ end
57
+
58
+ context "with help" do
59
+ it { given_command("help").should eql :help}
60
+ end
61
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe "starting a presentation" do
4
+ let(:presentation_dir){File.dirname(__FILE__) + "/../../presentation"}
5
+
6
+ it "should contian the commits for presentations" do
7
+ initialise_presentation
8
+ Dir.chdir(presentation_dir) do
9
+ presenter = GitPresenter.start_presentation(".")
10
+ presenter.commits.length.should eql 3
11
+ end
12
+ end
13
+
14
+ it "first commit should be first commit in file" do
15
+ start_presentation do |commits, presenter|
16
+ presenter.commits[0].should eql commits[0].id
17
+ end
18
+ end
19
+
20
+ it "second commit should be second commit in file" do
21
+ start_presentation do |commits, presenter|
22
+ presenter.commits[1].should eql commits[1].id
23
+ end
24
+ end
25
+
26
+ it "should have the presentation at first commit" do
27
+ start_presentation do |commits, presenter|
28
+ head_position.should eql commits.first.id
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe "when displaying the command line" do
4
+ it "should display the current position" do
5
+ presenter = GitPresenter.new(["0", "1","2"])
6
+ presenter.status_line.should eql "1/3 >"
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require 'rspec'
2
+ require "support/repo_helpers"
3
+ require_relative "../lib/git_presenter"
4
+
5
+ RSpec.configure do |config|
6
+
7
+ end
@@ -0,0 +1,65 @@
1
+ def initialise_test_repo(presentation_dir, delay)
2
+ clean_up_repo(presentation_dir)
3
+ code_file = "a_file.rb"
4
+ commits = []
5
+ Dir.mkdir(presentation_dir)
6
+ Dir.chdir(presentation_dir) do
7
+ git_repo = Grit::Repo.init(".")
8
+ File.open(code_file, "w") do |file|
9
+ file.write("a")
10
+ end
11
+ git_repo.add(".")
12
+ git_repo.commit_all("initial commit")
13
+ commits << git_repo.commits[0]
14
+ #need to make it sleep for a second.
15
+ #git is not accurate enough with the speed of the test
16
+ #to sort correctly
17
+ sleep 1 if delay
18
+ File.open(code_file, "a") do |file|
19
+ file.write("b")
20
+ end
21
+ git_repo.commit_all("second commit")
22
+ commits << git_repo.commits[0]
23
+ sleep 1 if delay
24
+ File.open(code_file, "a") do |file|
25
+ file.write("c")
26
+ end
27
+ git_repo.commit_all("third commit")
28
+ commits << git_repo.commits[0]
29
+ end
30
+ commits
31
+ end
32
+
33
+ def setup_presentation_file(commits)
34
+ File.open(".presentation", "w") do |file|
35
+ @commits.each do |commit|
36
+ file.write(commit.id + "\n")
37
+ end
38
+ end
39
+ end
40
+
41
+ def clean_up_repo(dir)
42
+ `rm -fr #{dir}`
43
+ end
44
+
45
+ def head_position
46
+ File.open(presentation_dir + '/.git/HEAD').lines.first.strip
47
+ end
48
+
49
+ def initialise_presentation(delay=false)
50
+ commits = initialise_test_repo(presentation_dir, delay)
51
+ Dir.chdir(presentation_dir) do
52
+ git_presentation = GitPresenter.initialise_presentation(".")
53
+ file = File.open(File.join(presentation_dir, ".presentation"))
54
+ yield(commits, file) if block_given?
55
+ end
56
+ commits
57
+ end
58
+
59
+ def start_presentation
60
+ commits = initialise_presentation(true)
61
+ Dir.chdir(presentation_dir) do
62
+ presenter = GitPresenter.start_presentation(".")
63
+ yield(commits, presenter) if block_given?
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_presenter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Colin Gemmell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: grit
16
+ requirement: &70125030832880 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70125030832880
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70125030832100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70125030832100
36
+ - !ruby/object:Gem::Dependency
37
+ name: cucumber
38
+ requirement: &70125030830240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70125030830240
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70125030828920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70125030828920
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &70125030844160 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70125030844160
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &70125030838440 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70125030838440
80
+ description: Code presentation tool using git
81
+ email: pythonandchips@gmail.com
82
+ executables:
83
+ - git-presenter
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.markdown
88
+ files:
89
+ - .rspec
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.markdown
94
+ - Rakefile
95
+ - VERSION
96
+ - bin/git-presenter
97
+ - git_presenter.gemspec
98
+ - lib/git_presenter.rb
99
+ - spec/integration/initialize_presentation_spec.rb
100
+ - spec/integration/moving_through_presentation_spec.rb
101
+ - spec/integration/processing_user_command_spec.rb
102
+ - spec/integration/start_presentation_spec.rb
103
+ - spec/integration/status_line_spec.rb
104
+ - spec/spec_helper.rb
105
+ - spec/support/repo_helpers.rb
106
+ homepage: http://github.com/pythonandchips/git-presenter
107
+ licenses:
108
+ - MIT
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ segments:
120
+ - 0
121
+ hash: -3273275985704648144
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.15
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Code presentation tool using git
134
+ test_files: []