git_presenter 0.3.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ec6e73263bc7b7fe3385a30fefd9473631fd9a2015182f73c437f832296df9ea
4
+ data.tar.gz: 01c7a2b97c61f48a440b7489019742cbaf1c5da68e1bc084ff9e5a30741e51f1
5
+ SHA512:
6
+ metadata.gz: fc2b81fa4219096831ec3b6e79d4a5829d9385de50e4883aea10e3af971965402231e0a13ec90f485377bd9860b94cf4bfe7378a0962bc10121765d6868479fe
7
+ data.tar.gz: 353bca888c8f73082cf757068d582f8148122b87838c3ef7986b979b2573dbece0e42bd95de3b5c5c332bf0401a27a2c554459b358cc2fc285a3bb0ec97c02f8
@@ -2,4 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 3.0.0
5
8
  # - jruby-19mode # JRuby in 1.9 mode
9
+ script: "bundle exec rspec spec"
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  #
6
- gem "grit", "~> 2.4"
6
+ gem "git"
7
+ gem 'launchy', '~> 2.5'
7
8
 
8
9
  # Add dependencies to develop your gem here.
9
10
  # Include everything needed to run rake, tests, features, etc.
@@ -11,7 +12,5 @@ group :development do
11
12
  gem "pry"
12
13
  gem "rspec", "~> 2.7"
13
14
  gem "bundler"
14
- gem "jeweler", "~> 1.6"
15
- gem "rcov", "~> 0.9"
16
- gem 'pry'
15
+ gem 'jeweler', '~> 2.3'
17
16
  end
@@ -1,47 +1,97 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- coderay (1.0.6)
5
- diff-lcs (1.1.3)
6
- git (1.2.5)
7
- grit (2.5.0)
8
- diff-lcs (~> 1.1)
9
- mime-types (~> 1.15)
10
- posix-spawn (~> 0.3.6)
11
- jeweler (1.8.3)
12
- bundler (~> 1.0)
4
+ addressable (2.7.0)
5
+ public_suffix (>= 2.0.2, < 5.0)
6
+ builder (3.2.4)
7
+ coderay (1.1.3)
8
+ descendants_tracker (0.0.4)
9
+ thread_safe (~> 0.3, >= 0.3.1)
10
+ diff-lcs (1.4.4)
11
+ faraday (0.9.2)
12
+ multipart-post (>= 1.2, < 3)
13
+ ffi (1.14.2-java)
14
+ git (1.8.1)
15
+ rchardet (~> 1.8)
16
+ github_api (0.11.3)
17
+ addressable (~> 2.3)
18
+ descendants_tracker (~> 0.0.1)
19
+ faraday (~> 0.8, < 0.10)
20
+ hashie (>= 1.2)
21
+ multi_json (>= 1.7.5, < 2.0)
22
+ nokogiri (~> 1.6.0)
23
+ oauth2
24
+ hashie (4.1.0)
25
+ highline (2.0.3)
26
+ jar-dependencies (0.4.1)
27
+ jeweler (2.3.5)
28
+ builder
29
+ bundler (>= 1.0)
13
30
  git (>= 1.2.5)
31
+ github_api (~> 0.11.0)
32
+ highline (>= 1.6.15)
33
+ nokogiri (>= 1.5.10)
34
+ psych (~> 2.2)
14
35
  rake
15
36
  rdoc
16
- json (1.7.3)
17
- method_source (0.7.1)
18
- mime-types (1.18)
19
- posix-spawn (0.3.6)
20
- pry (0.9.9.6)
21
- coderay (~> 1.0.5)
22
- method_source (~> 0.7.1)
23
- slop (>= 2.4.4, < 3)
24
- rake (0.9.2.2)
25
- rcov (0.9.11)
26
- rdoc (3.12)
27
- json (~> 1.4)
28
- rspec (2.10.0)
29
- rspec-core (~> 2.10.0)
30
- rspec-expectations (~> 2.10.0)
31
- rspec-mocks (~> 2.10.0)
32
- rspec-core (2.10.1)
33
- rspec-expectations (2.10.0)
34
- diff-lcs (~> 1.1.3)
35
- rspec-mocks (2.10.1)
36
- slop (2.4.4)
37
+ semver2
38
+ jwt (2.2.2)
39
+ launchy (2.5.0)
40
+ addressable (~> 2.7)
41
+ method_source (1.0.0)
42
+ mini_portile2 (2.1.0)
43
+ multi_json (1.15.0)
44
+ multi_xml (0.6.0)
45
+ multipart-post (2.1.1)
46
+ nokogiri (1.6.8.1)
47
+ mini_portile2 (~> 2.1.0)
48
+ nokogiri (1.6.8.1-java)
49
+ oauth2 (1.4.4)
50
+ faraday (>= 0.8, < 2.0)
51
+ jwt (>= 1.0, < 3.0)
52
+ multi_json (~> 1.3)
53
+ multi_xml (~> 0.5)
54
+ rack (>= 1.2, < 3)
55
+ pry (0.13.1)
56
+ coderay (~> 1.1)
57
+ method_source (~> 1.0)
58
+ pry (0.13.1-java)
59
+ coderay (~> 1.1)
60
+ method_source (~> 1.0)
61
+ spoon (~> 0.0)
62
+ psych (2.2.4)
63
+ psych (2.2.4-java)
64
+ jar-dependencies (>= 0.1.7)
65
+ public_suffix (4.0.6)
66
+ rack (2.2.3)
67
+ rake (13.0.3)
68
+ rchardet (1.8.0)
69
+ rdoc (6.3.0)
70
+ rspec (2.99.0)
71
+ rspec-core (~> 2.99.0)
72
+ rspec-expectations (~> 2.99.0)
73
+ rspec-mocks (~> 2.99.0)
74
+ rspec-core (2.99.2)
75
+ rspec-expectations (2.99.2)
76
+ diff-lcs (>= 1.1.3, < 2.0)
77
+ rspec-mocks (2.99.4)
78
+ semver2 (3.4.2)
79
+ spoon (0.0.6)
80
+ ffi
81
+ thread_safe (0.3.6)
82
+ thread_safe (0.3.6-java)
37
83
 
38
84
  PLATFORMS
85
+ java
39
86
  ruby
40
87
 
41
88
  DEPENDENCIES
42
89
  bundler
43
- grit (~> 2.4)
44
- jeweler (~> 1.6)
90
+ git
91
+ jeweler (~> 2.3)
92
+ launchy (~> 2.5)
45
93
  pry
46
- rcov (~> 0.9)
47
94
  rspec (~> 2.7)
95
+
96
+ BUNDLED WITH
97
+ 2.2.3
@@ -1,6 +1,6 @@
1
1
  # git-presenter
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/pythonandchips/git-presenter.png?branch=master)](http://travis-ci.org/pythonandchips/git-presenter)
3
+ [![Build Status](https://drone.io/github.com/pythonandchips/git-presenter/status.png)](https://drone.io/github.com/pythonandchips/git-presenter/latest)
4
4
 
5
5
  When presenting code live on stage you have a few choices:
6
6
 
@@ -11,15 +11,12 @@ Git-presenter hope to solve this problem by giving a presentation style interfac
11
11
 
12
12
  ## Current status
13
13
 
14
- Early version but the basics are there to be used.
15
- Any and all feedback is welcome
14
+ Complete.
16
15
 
17
16
  ## Pre-requisites
18
17
 
19
18
  * Git
20
- * Ruby version 1.9.2 or 1.9.3
21
-
22
- Note jruby is currently unsupported as there is a problem with posix-spawn and jruby
19
+ * Ruby version 1.9.2, 1.9.3, 2.0.0, 2.1.0 and jruby
23
20
 
24
21
  ## Installation
25
22
 
@@ -39,7 +36,20 @@ gem install git_presenter
39
36
  * list/l : list slides in presentation
40
37
  * help/h: display this message
41
38
 
42
- ## Bugs/Features/Prase
39
+ ### Command mode
40
+
41
+ The default for git presenter is interactive mode however if you want to use git presenter from a text editor you can use command mode.
42
+
43
+ To start a presentation in command mode use "git-presenter start -c"
44
+
45
+ Once started you run "git-presenter {{command}}" e.g. to move to the next slide run "git-presenter next"
46
+
47
+ ## Other resources
48
+ There are couple of videos showing git presenter and how to us it
49
+ * (video 1)[https://vimeo.com/38949496]
50
+ * (video 2)[https://vimeo.com/39225144]
51
+
52
+ ## Bugs/Features/Praise
43
53
 
44
54
  It you find any bugs or have some feature requests please add an issue on the repository. Or if you just want to get in touch and tell me how awesome git presenter is you can get me on twitter @colin_gemmell or drop me an email at pythonandchips{at}gmail.com
45
55
 
@@ -54,6 +64,10 @@ It you find any bugs or have some feature requests please add an issue on the re
54
64
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
55
65
  * 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.
56
66
 
67
+ ## Contributors
68
+
69
+ * (Luís Ferreira - Zamith)[https://github.com/zamith]
70
+
57
71
  ## Copyright
58
72
 
59
73
  Copyright (c) 2012 Colin Gemmell
@@ -76,4 +90,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
76
90
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
77
91
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
78
92
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
79
-
data/Rakefile CHANGED
@@ -24,26 +24,3 @@ Jeweler::Tasks.new do |gem|
24
24
  # dependencies defined in Gemfile
25
25
  end
26
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
- task :default => :spec
40
-
41
- require 'rake/rdoctask'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "git_presenter #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 1.3.0
@@ -4,5 +4,11 @@ require_relative "../lib/git_presenter"
4
4
 
5
5
  YAML::ENGINE.yamler = 'psych'
6
6
 
7
- presenter = GitPresenter.new(Dir.pwd)
7
+ if ARGV[1] == "-c"
8
+ interactive = false
9
+ else
10
+ interactive = true
11
+ end
12
+
13
+ presenter = GitPresenter.new(Dir.pwd, interactive)
8
14
  presenter.execute(ARGV[0])
@@ -2,17 +2,19 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: git_presenter 1.3.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = "git_presenter"
8
- s.version = "0.3.0"
8
+ s.name = "git_presenter".freeze
9
+ s.version = "1.3.0"
9
10
 
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-06-29"
13
- s.description = "Code presentation tool using git"
14
- s.email = "pythonandchips@gmail.com"
15
- s.executables = ["git-presenter"]
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Colin Gemmell".freeze]
14
+ s.date = "2021-01-11"
15
+ s.description = "Code presentation tool using git".freeze
16
+ s.email = "pythonandchips@gmail.com".freeze
17
+ s.executables = ["git-presenter".freeze]
16
18
  s.extra_rdoc_files = [
17
19
  "LICENSE.txt",
18
20
  "README.markdown"
@@ -31,6 +33,7 @@ Gem::Specification.new do |s|
31
33
  "lib/git_presenter.rb",
32
34
  "lib/git_presenter/controller.rb",
33
35
  "lib/git_presenter/presentation.rb",
36
+ "lib/git_presenter/shell.rb",
34
37
  "lib/git_presenter/slide.rb",
35
38
  "spec/bugs/max_10_commits_being_parsed_spec.rb",
36
39
  "spec/integration/initialize_presentation_spec.rb",
@@ -44,40 +47,29 @@ Gem::Specification.new do |s|
44
47
  "spec/support/command_line_helper.rb",
45
48
  "spec/support/git_helpers.rb"
46
49
  ]
47
- s.homepage = "http://github.com/pythonandchips/git-presenter"
48
- s.licenses = ["MIT"]
49
- s.require_paths = ["lib"]
50
- s.rubygems_version = "1.8.15"
51
- s.summary = "Code presentation tool using git"
50
+ s.homepage = "http://github.com/pythonandchips/git-presenter".freeze
51
+ s.licenses = ["MIT".freeze]
52
+ s.rubygems_version = "3.2.3".freeze
53
+ s.summary = "Code presentation tool using git".freeze
52
54
 
53
55
  if s.respond_to? :specification_version then
54
- s.specification_version = 3
56
+ s.specification_version = 4
57
+ end
55
58
 
56
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<grit>, ["~> 2.4"])
58
- s.add_development_dependency(%q<pry>, [">= 0"])
59
- s.add_development_dependency(%q<rspec>, ["~> 2.7"])
60
- s.add_development_dependency(%q<bundler>, [">= 0"])
61
- s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
62
- s.add_development_dependency(%q<rcov>, ["~> 0.9"])
63
- s.add_development_dependency(%q<pry>, [">= 0"])
64
- else
65
- s.add_dependency(%q<grit>, ["~> 2.4"])
66
- s.add_dependency(%q<pry>, [">= 0"])
67
- s.add_dependency(%q<rspec>, ["~> 2.7"])
68
- s.add_dependency(%q<bundler>, [">= 0"])
69
- s.add_dependency(%q<jeweler>, ["~> 1.6"])
70
- s.add_dependency(%q<rcov>, ["~> 0.9"])
71
- s.add_dependency(%q<pry>, [">= 0"])
72
- end
59
+ if s.respond_to? :add_runtime_dependency then
60
+ s.add_runtime_dependency(%q<git>.freeze, [">= 0"])
61
+ s.add_runtime_dependency(%q<launchy>.freeze, ["~> 2.5"])
62
+ s.add_development_dependency(%q<pry>.freeze, [">= 0"])
63
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 2.7"])
64
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
65
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3"])
73
66
  else
74
- s.add_dependency(%q<grit>, ["~> 2.4"])
75
- s.add_dependency(%q<pry>, [">= 0"])
76
- s.add_dependency(%q<rspec>, ["~> 2.7"])
77
- s.add_dependency(%q<bundler>, [">= 0"])
78
- s.add_dependency(%q<jeweler>, ["~> 1.6"])
79
- s.add_dependency(%q<rcov>, ["~> 0.9"])
80
- s.add_dependency(%q<pry>, [">= 0"])
67
+ s.add_dependency(%q<git>.freeze, [">= 0"])
68
+ s.add_dependency(%q<launchy>.freeze, ["~> 2.5"])
69
+ s.add_dependency(%q<pry>.freeze, [">= 0"])
70
+ s.add_dependency(%q<rspec>.freeze, ["~> 2.7"])
71
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
72
+ s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
81
73
  end
82
74
  end
83
75
 
@@ -1,11 +1,13 @@
1
- require "grit"
2
- require "yaml"
3
- require "readline"
1
+ require 'git'
2
+ require 'yaml'
3
+ require 'readline'
4
+ require 'launchy'
4
5
 
5
6
  class GitPresenter
6
- require "git_presenter/presentation"
7
- require "git_presenter/controller"
8
- require "git_presenter/slide"
7
+ require_relative 'git_presenter/presentation'
8
+ require_relative 'git_presenter/controller'
9
+ require_relative 'git_presenter/slide'
10
+ require_relative 'git_presenter/shell'
9
11
 
10
12
  def initialize(current_dir, interactive=true)
11
13
  @controller = Controller.new(current_dir)
@@ -13,21 +15,28 @@ class GitPresenter
13
15
  end
14
16
 
15
17
  def execute(command)
16
- if command == "init"
18
+ if command == 'init'
17
19
  @controller.initialise_presentation
18
- elsif command == "start"
20
+ elsif command == 'start'
19
21
  @presentation = @controller.start_presentation
20
22
  if @interactive
21
23
  enter_run_loop
22
24
  end
23
- elsif command == "update"
25
+ elsif command == 'update'
24
26
  @controller.update_presentation
25
27
  else
28
+ if @presentation.nil?
29
+ @presentation = @controller.load_presentation
30
+ end
26
31
  puts @presentation.execute(command)
27
32
  end
28
33
  @presentation
29
34
  end
30
35
 
36
+ def current_slide
37
+ @presentation.current_slide
38
+ end
39
+
31
40
  private
32
41
 
33
42
  def enter_run_loop
@@ -6,7 +6,7 @@ class GitPresenter::Controller
6
6
  end
7
7
 
8
8
  def initialise_presentation
9
- yaml = {"slides" => create_slides}.to_yaml
9
+ yaml = {"slides" => create_slides, "branch" => current_branch}.to_yaml
10
10
  File.open(presentation_file_location, "w") do |file|
11
11
  file.write(yaml)
12
12
  end
@@ -14,9 +14,13 @@ class GitPresenter::Controller
14
14
  puts "run 'git-presenter start' to begin the presentation"
15
15
  end
16
16
 
17
- def start_presentation
17
+ def load_presentation
18
18
  yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby
19
- presenter = GitPresenter::Presentation.new(yaml)
19
+ GitPresenter::Presentation.new(yaml)
20
+ end
21
+
22
+ def start_presentation
23
+ presenter = load_presentation
20
24
  puts presenter.start
21
25
  presenter
22
26
  end
@@ -24,7 +28,6 @@ class GitPresenter::Controller
24
28
  def update_presentation
25
29
  yaml = YAML.parse(File.open(@presentation_dir + "/.presentation", "r")).to_ruby
26
30
  slides = create_slides(yaml['slides'].last["slide"]["commit"])
27
- last_commit = yaml["slides"].last
28
31
  yaml["slides"] = yaml["slides"] + slides
29
32
  yaml["slides"].uniq!
30
33
  write_file(yaml.to_yaml)
@@ -44,14 +47,18 @@ class GitPresenter::Controller
44
47
  end
45
48
 
46
49
  def create_slides(last_commit=nil)
47
- repo = Grit::Repo.new(".", "master")
48
- commits = repo.commits("master", false).reverse
49
- commits = commits.drop_while{|commit| commit.id != last_commit}[1..-1] unless last_commit.nil?
50
+ repo = Git.open(".")
51
+ commits = repo.log.to_a.reverse
52
+ commits = commits.drop_while{|commit| commit.sha != last_commit}[1..-1] unless last_commit.nil?
50
53
  commits.map do |commit|
51
54
  {"slide" =>
52
- {"commit" => commit.id,
55
+ {"commit" => commit.sha,
53
56
  "message" => commit.message}
54
57
  }
55
58
  end
56
59
  end
60
+
61
+ def current_branch
62
+ `git rev-parse --abbrev-ref HEAD`.strip
63
+ end
57
64
  end
@@ -1,9 +1,16 @@
1
1
  class GitPresenter::Presentation
2
2
  attr_reader :slides, :current_slide
3
3
 
4
- def initialize(presentation)
4
+ def initialize(presentation, shell=GitPresenter::Shell.new)
5
+ @branch = presentation["branch"]
5
6
  @slides = presentation["slides"].map{|slide| GitPresenter::Slide.new(slide["slide"])}
6
- @current_slide = slides.first
7
+ @shell = shell
8
+ @current_slide = find_current_slide
9
+ end
10
+
11
+ def find_current_slide
12
+ sha = @shell.run("git rev-parse HEAD").strip
13
+ @slides.detect{|s| s.commit == sha}
7
14
  end
8
15
 
9
16
  def command_for(command)
@@ -39,11 +46,12 @@ class GitPresenter::Presentation
39
46
  end
40
47
 
41
48
  def exit
42
- `git checkout -q master`
49
+ `git checkout -q #{@branch}`
50
+ :exit
43
51
  end
44
52
 
45
53
  def position
46
- slides.index(@current_slide)
54
+ @slides.index(@current_slide)
47
55
  end
48
56
 
49
57
  def total_slides
@@ -0,0 +1,5 @@
1
+ class GitPresenter::Shell
2
+ def run(command)
3
+ `#{command}`.strip
4
+ end
5
+ end
@@ -5,12 +5,14 @@ class GitPresenter::Slide
5
5
  @commit = slide["commit"]
6
6
  @message = slide["message"]
7
7
  @run = slide["run"]
8
+ @launch = slide["launch"]
8
9
  end
9
10
 
10
11
  def execute
11
12
  output = ""
12
13
  output << checkout unless @commit.nil?
13
14
  output << `#{run}` unless @run.nil?
15
+ Launchy.open(@launch) unless @launch.nil?
14
16
  output
15
17
  end
16
18
 
@@ -10,7 +10,7 @@ describe "initializing a presentation" do
10
10
  context ".presentation file" do
11
11
  it "should be written to root directory" do
12
12
  @helper.initialise_presentation do
13
- File.exists?(".presentation").should be_true
13
+ File.exists?(".presentation").should be_truthy
14
14
  end
15
15
  end
16
16
 
@@ -20,6 +20,12 @@ describe "initializing a presentation" do
20
20
  end
21
21
  end
22
22
 
23
+ it 'should have a branch note' do
24
+ @helper.initialise_presentation do |commits, yaml|
25
+ yaml["branch"].should_not be_nil
26
+ end
27
+ end
28
+
23
29
  it "should contain a line for each commit to the repository" do
24
30
  @helper.initialise_presentation do |commits, yaml|
25
31
  yaml["slides"].length.should eql commits.length
@@ -28,13 +34,13 @@ describe "initializing a presentation" do
28
34
 
29
35
  it "first line should contain the first commit number" do
30
36
  @helper.initialise_presentation({:delay => true}) do |commits, yaml|
31
- yaml["slides"][0]["slide"]["commit"].should eql commits.first.id
37
+ yaml["slides"][0]["slide"]["commit"].should eql commits.first.sha
32
38
  end
33
39
  end
34
40
 
35
41
  it "second line should contain the second commit number" do
36
42
  @helper.initialise_presentation({:delay => true}) do |commits, yaml|
37
- yaml["slides"][1]["slide"]["commit"].should eql commits[1].id
43
+ yaml["slides"][1]["slide"]["commit"].should eql commits[1].sha
38
44
  end
39
45
  end
40
46
  end
@@ -11,7 +11,7 @@ describe "while giving presentation" do
11
11
  it "should move to the next commit" do
12
12
  @helper.start_presentation do |commits, presenter|
13
13
  presenter.execute("next")
14
- @helper.head_position.should eql commits[1].id
14
+ @helper.head_position.should eql commits[1].sha
15
15
  end
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ describe "while giving presentation" do
19
19
  @helper.start_presentation do |commits, presenter|
20
20
  presenter.execute("next")
21
21
  presenter.execute("next")
22
- @helper.head_position.should eql commits[2].id
22
+ @helper.head_position.should eql commits[2].sha
23
23
  end
24
24
  end
25
25
  end
@@ -30,7 +30,7 @@ describe "while giving presentation" do
30
30
  presenter.execute("next")
31
31
  @helper.edit_file("inner commit")
32
32
  presenter.execute("next")
33
- @helper.head_position.should eql commits[2].id
33
+ @helper.head_position.should eql commits[2].sha
34
34
  end
35
35
  end
36
36
  end
@@ -42,7 +42,7 @@ describe "while giving presentation" do
42
42
  presenter.execute("next")
43
43
  presenter.execute("next")
44
44
  presenter.execute("next")
45
- @helper.head_position.should eql commits[2].id
45
+ @helper.head_position.should eql commits[2].sha
46
46
  end
47
47
  end
48
48
  end
@@ -53,7 +53,7 @@ describe "while giving presentation" do
53
53
  presenter.execute("next")
54
54
  presenter.execute("next")
55
55
  presenter.execute("back")
56
- @helper.head_position.should eql commits[1].id
56
+ @helper.head_position.should eql commits[1].sha
57
57
  end
58
58
  end
59
59
  end
@@ -67,7 +67,7 @@ describe "while giving presentation" do
67
67
  presenter.execute("back")
68
68
  presenter.execute("back")
69
69
  presenter.execute("back")
70
- @helper.head_position.should eql commits[0].id
70
+ @helper.head_position.should eql commits[0].sha
71
71
  end
72
72
  end
73
73
  end
@@ -78,7 +78,7 @@ describe "while giving presentation" do
78
78
  presenter.execute("next")
79
79
  presenter.execute("next")
80
80
  presenter.execute("start")
81
- @helper.head_position.should eql commits[0].id
81
+ @helper.head_position.should eql commits[0].sha
82
82
  end
83
83
  end
84
84
  end
@@ -87,7 +87,7 @@ describe "while giving presentation" do
87
87
  it "should move the last commit" do
88
88
  @helper.start_presentation do |commits, presenter|
89
89
  presenter.execute("end")
90
- @helper.head_position.should eql commits.last.id
90
+ @helper.head_position.should eql commits.last.sha
91
91
  end
92
92
  end
93
93
  end
@@ -96,7 +96,7 @@ describe "while giving presentation" do
96
96
  it "should checkout the specific commit" do
97
97
  @helper.start_presentation do |commits, presenter|
98
98
  presenter.execute("2")
99
- @helper.head_position.should eql commits[1].id
99
+ @helper.head_position.should eql commits[1].sha
100
100
  end
101
101
  end
102
102
  end
@@ -104,7 +104,7 @@ describe "while giving presentation" do
104
104
  context "list presentation" do
105
105
  it "should print a list of commits" do
106
106
  @helper.start_presentation do |commits, presenter|
107
- expected_output = (["*#{commits.first.id[0..9]}, #{commits.first.message}"] + commits[1..-1].map{|commit| "#{commit.id[0..9]}, #{commit.message}"}).join("\n")
107
+ expected_output = (["*#{commits.first.sha[0..9]}, #{commits.first.message}"] + commits[1..-1].map{|commit| "#{commit.sha[0..9]}, #{commit.message}"}).join("\n")
108
108
  presentation = presenter.execute("list")
109
109
  presentation.should eql expected_output
110
110
  end
@@ -135,7 +135,7 @@ EOH
135
135
  context "when the slide contains a run command only" do
136
136
  it "should execute the command" do
137
137
  command_line_helper = CommandLineHelper.capture_output
138
- @helper.start_presentation("echo hello world") do |commits, presenter|
138
+ @helper.start_presentation([:run => "echo hello world"]) do |commits, presenter|
139
139
  presenter.execute("next")
140
140
  presenter.execute("next")
141
141
  presenter.execute("next").strip.should eql "hello world"
@@ -146,7 +146,7 @@ EOH
146
146
  context "when the slide has a commit and a run command" do
147
147
  it "should checkout the commit and then execute the command" do
148
148
  command_line_helper = CommandLineHelper.capture_output
149
- @helper.start_presentation("echo hello world", 2) do |commits, presenter|
149
+ @helper.start_presentation([:run => "echo hello world",:on_slide => 2]) do |commits, presenter|
150
150
  presenter.execute("next")
151
151
  presenter.execute("next").should eql "#{commits[2].message}\nhello world\n"
152
152
  end
@@ -163,13 +163,33 @@ EOH
163
163
  end
164
164
  end
165
165
 
166
+ context "when opening an application" do
167
+ it "should open the with launchy" do
168
+ command_line_helper = CommandLineHelper.capture_output
169
+ @helper.start_presentation([:launch => 'readme', :on_slide => 2]) do |commits, presenter|
170
+ Launchy.should_receive(:open).with('readme').once
171
+ presenter.execute("next")
172
+ presenter.execute("next")
173
+ end
174
+ end
175
+ end
176
+
166
177
  context "when exiting a presentation" do
167
178
  it "should set the repo back to the master branch" do
168
179
  @helper.start_presentation do |commits, presenter|
169
180
  presenter.execute("next")
170
181
  presenter.execute("exit")
171
182
  @helper.current_branch.should_not be_nil
172
- @helper.current_branch.name.should eql "master"
183
+ @helper.current_branch.should eql "master"
184
+ end
185
+ end
186
+ end
187
+
188
+ context "when running in command mode" do
189
+ it "should set the current slide to commit" do
190
+ @helper.start_presentation([], 1) do |commits, presenter|
191
+ presenter.execute("list")
192
+ presenter.current_slide.commit.should eql commits[1].sha
173
193
  end
174
194
  end
175
195
  end
@@ -19,26 +19,26 @@ describe "starting a presentation" do
19
19
 
20
20
  it "first commit should be first commit in file" do
21
21
  @helper.start_presentation do |commits, presenter|
22
- presenter.slides[0].commit.should eql commits[0].id
22
+ presenter.slides[0].commit.should eql commits[0].sha
23
23
  end
24
24
  end
25
25
 
26
26
  it "second commit should be second commit in file" do
27
27
  @helper.start_presentation do |commits, presenter|
28
- presenter.slides[1].commit.should eql commits[1].id
28
+ presenter.slides[1].commit.should eql commits[1].sha
29
29
  end
30
30
  end
31
31
 
32
32
  it "the last commit should be a command" do
33
33
  command = "echo hello world"
34
- @helper.start_presentation(command) do |commits, presenter|
34
+ @helper.start_presentation([:run => command]) do |commits, presenter|
35
35
  presenter.slides[3].run.should eql command
36
36
  end
37
37
  end
38
38
 
39
39
  it "should have the presentation at first commit" do
40
40
  @helper.start_presentation do |commits, presenter|
41
- @helper.head_position.should eql commits.first.id
41
+ @helper.head_position.should eql commits.first.sha
42
42
  end
43
43
  end
44
44
  end
@@ -18,7 +18,7 @@ describe "update presentation with any new commits" do
18
18
  commits = @helper.initialise_presentation({:delay => true})
19
19
  new_commit = @helper.edit_file_and_commit("forth commit", "d")
20
20
  @helper.update_presentation do |yaml|
21
- yaml["slides"].last["slide"]["commit"].should eql new_commit.id
21
+ yaml["slides"].last["slide"]["commit"].should eql new_commit.sha
22
22
  end
23
23
  end
24
24
 
@@ -1,15 +1,27 @@
1
1
  require "spec_helper"
2
2
 
3
+ class FakeShell
4
+ attr_reader :ran_commands
5
+ def initialize()
6
+ @ran_commands = []
7
+ end
8
+ def run(command)
9
+ @ran_commands << command
10
+ end
11
+ end
3
12
  describe GitPresenter::Presentation do
4
13
  let(:presentation){ {"slides" => [
5
14
  {"slide" => {"commit" => "0"}},
6
15
  {"slide" => {"commit" => "1"}},
7
- {"slide" => {"commit" => "2"}}]
16
+ {"slide" => {"commit" => "2"}}],
17
+ "branch" => "test"
8
18
  }
9
19
  }
20
+ let(:fake_shell){ FakeShell.new }
10
21
  context "when displaying the command line" do
11
22
  it "should display the current position" do
12
- presenter = GitPresenter::Presentation.new(presentation)
23
+ fake_shell.should_receive(:run).with("git rev-parse HEAD").and_return("0")
24
+ presenter = GitPresenter::Presentation.new(presentation, fake_shell)
13
25
  presenter.status_line.should eql "1/3 >"
14
26
  end
15
27
  end
@@ -17,7 +29,8 @@ describe GitPresenter::Presentation do
17
29
 
18
30
  context "when calculating the position" do
19
31
  it "should return the index of the current commit" do
20
- presenter = GitPresenter::Presentation.new(presentation)
32
+ fake_shell.should_receive(:run).with("git rev-parse HEAD").and_return("0")
33
+ presenter = GitPresenter::Presentation.new(presentation, fake_shell)
21
34
  presenter.position.should eql 0
22
35
  end
23
36
  end
@@ -83,5 +96,16 @@ describe GitPresenter::Presentation do
83
96
  context "with help" do
84
97
  it { given_command("help").should eql :help}
85
98
  end
99
+
100
+ context "with exit" do
101
+ it { given_command("exit").should eql :exit}
102
+ it 'checks out to the correct branch' do
103
+ presenter = GitPresenter::Presentation.new(presentation)
104
+
105
+ expect(presenter).to receive(:'`').with("git checkout -q #{presentation['branch']}")
106
+
107
+ presenter.exit
108
+ end
109
+ end
86
110
  end
87
111
  end
@@ -31,6 +31,23 @@ describe GitPresenter::Slide do
31
31
  end
32
32
  end
33
33
 
34
+ context "when slide contains a launch command" do
35
+ it "should launch the application for the file type" do
36
+ command_line_helper = CommandLineHelper.capture_output
37
+ Launchy.should_receive(:open).with("readme").once
38
+ slide = GitPresenter::Slide.new({"launch" => "readme"})
39
+ slide.execute
40
+ end
41
+
42
+ it "should not try and launch if no launch supplied" do
43
+ command_line_helper = CommandLineHelper.capture_output
44
+ Launchy.should_receive(:open).with("readme").never
45
+ slide = GitPresenter::Slide.new({"commit" => "number", "message" => "checkout", "run" => "echo hello world"})
46
+ slide.stub(:checkout).and_return("checkout\n")
47
+ slide.execute.should eql "checkout\nhello world\n"
48
+ end
49
+ end
50
+
34
51
  context "when slide contains only a commit" do
35
52
  it "should checkout the code then run the command" do
36
53
  command_line_helper = CommandLineHelper.capture_output
@@ -16,10 +16,10 @@ class GitHelper
16
16
  content = ('a'..'z').to_a
17
17
  Dir.mkdir(presentation_dir)
18
18
  Dir.chdir(presentation_dir) do
19
- @git_repo = Grit::Repo.init(".")
19
+ @git_repo = Git.init(".")
20
20
  (1..no_of_commits).each do |n|
21
- edit_file_and_commit("commit number #{n}", content[n])
22
- commits << @git_repo.commits[0]
21
+ commit = edit_file_and_commit("commit number #{n}", content[n])
22
+ commits << commit
23
23
  #need to make it sleep for a second.
24
24
  #git is not accurate enough with the speed of the test
25
25
  #to sort correctly only when required
@@ -40,7 +40,7 @@ class GitHelper
40
40
  edit_file(content)
41
41
  @git_repo.add(".")
42
42
  @git_repo.commit_all(commit_message)
43
- @git_repo.commits[0]
43
+ @git_repo.log.to_a[0]
44
44
  end
45
45
 
46
46
  def setup_presentation_file(commits)
@@ -56,7 +56,7 @@ class GitHelper
56
56
  end
57
57
 
58
58
  def head_position
59
- File.open(@presentation_dir + '/.git/HEAD').lines.first.strip
59
+ File.open(@presentation_dir + '/.git/HEAD').each_line.first.strip
60
60
  end
61
61
 
62
62
  def initialise_presentation(params={})
@@ -71,12 +71,17 @@ class GitHelper
71
71
  commits
72
72
  end
73
73
 
74
- def start_presentation(command="", add_command_to_commit=nil)
74
+ def start_presentation(commands=[], start_slide=0)
75
75
  commits = initialise_presentation({:delay => true})
76
76
  Dir.chdir(@presentation_dir) do
77
- add_command(command, add_command_to_commit) unless command.empty?
77
+ add_commands(commands) unless commands.empty?
78
+ if start_slide != 0
79
+ `git checkout -q #{commits[start_slide]}`
80
+ end
78
81
  presenter = GitPresenter.new('.', false)
79
- presenter = presenter.execute('start')
82
+ if start_slide == 0
83
+ presenter = presenter.execute('start')
84
+ end
80
85
  yield(commits, presenter) if block_given?
81
86
  end
82
87
  end
@@ -102,6 +107,31 @@ class GitHelper
102
107
  removed_commit
103
108
  end
104
109
 
110
+ def add_commands(commands)
111
+ commands.each do |command|
112
+ if command.include?(:run)
113
+ add_command(command[:run], command[:on_slide])
114
+ end
115
+ if command.include?(:launch)
116
+ add_launch(command[:launch], command[:on_slide])
117
+ end
118
+ end
119
+ end
120
+
121
+ def add_launch(command, add_command_to_commit=nil)
122
+ Dir.chdir(PRESENTATION_DIR) do
123
+ presentation = YAML.parse(File.open(".presentation")).to_ruby
124
+ if !add_command_to_commit.nil?
125
+ presentation["slides"][add_command_to_commit]["slide"]["launch"] = command
126
+ else
127
+ presentation["slides"] << {"slide" => {"launch" => command}}
128
+ end
129
+ File.open(".presentation", "w") do |file|
130
+ file.write(presentation.to_yaml)
131
+ end
132
+ end
133
+ end
134
+
105
135
  def add_command(command, add_command_to_commit=nil)
106
136
  Dir.chdir(PRESENTATION_DIR) do
107
137
  presentation = YAML.parse(File.open(".presentation")).to_ruby
@@ -118,8 +148,8 @@ class GitHelper
118
148
 
119
149
  def current_branch
120
150
  Dir.chdir(PRESENTATION_DIR) do
121
- repo = Grit::Repo.init('.')
122
- repo.head
151
+ repo = Git.open('.')
152
+ repo.current_branch
123
153
  end
124
154
  end
125
155
 
metadata CHANGED
@@ -1,93 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 1.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Colin Gemmell
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-29 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: grit
16
- requirement: &70193289098420 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '2.4'
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: launchy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
22
34
  type: :runtime
23
35
  prerelease: false
24
- version_requirements: *70193289098420
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
25
41
  - !ruby/object:Gem::Dependency
26
42
  name: pry
27
- requirement: &70193289097940 !ruby/object:Gem::Requirement
28
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
29
44
  requirements:
30
- - - ! '>='
45
+ - - ">="
31
46
  - !ruby/object:Gem::Version
32
47
  version: '0'
33
48
  type: :development
34
49
  prerelease: false
35
- version_requirements: *70193289097940
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
36
55
  - !ruby/object:Gem::Dependency
37
56
  name: rspec
38
- requirement: &70193289097460 !ruby/object:Gem::Requirement
39
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
40
58
  requirements:
41
- - - ~>
59
+ - - "~>"
42
60
  - !ruby/object:Gem::Version
43
61
  version: '2.7'
44
62
  type: :development
45
63
  prerelease: false
46
- version_requirements: *70193289097460
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: bundler
49
- requirement: &70193289096980 !ruby/object:Gem::Requirement
50
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
51
72
  requirements:
52
- - - ! '>='
73
+ - - ">="
53
74
  - !ruby/object:Gem::Version
54
75
  version: '0'
55
76
  type: :development
56
77
  prerelease: false
57
- version_requirements: *70193289096980
58
- - !ruby/object:Gem::Dependency
59
- name: jeweler
60
- requirement: &70193289096500 !ruby/object:Gem::Requirement
61
- none: false
78
+ version_requirements: !ruby/object:Gem::Requirement
62
79
  requirements:
63
- - - ~>
80
+ - - ">="
64
81
  - !ruby/object:Gem::Version
65
- version: '1.6'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70193289096500
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rcov
71
- requirement: &70193289096020 !ruby/object:Gem::Requirement
72
- none: false
84
+ name: jeweler
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
- - - ~>
87
+ - - "~>"
75
88
  - !ruby/object:Gem::Version
76
- version: '0.9'
89
+ version: '2.3'
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *70193289096020
80
- - !ruby/object:Gem::Dependency
81
- name: pry
82
- requirement: &70193289095540 !ruby/object:Gem::Requirement
83
- none: false
92
+ version_requirements: !ruby/object:Gem::Requirement
84
93
  requirements:
85
- - - ! '>='
94
+ - - "~>"
86
95
  - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70193289095540
96
+ version: '2.3'
91
97
  description: Code presentation tool using git
92
98
  email: pythonandchips@gmail.com
93
99
  executables:
@@ -97,8 +103,8 @@ extra_rdoc_files:
97
103
  - LICENSE.txt
98
104
  - README.markdown
99
105
  files:
100
- - .rspec
101
- - .travis.yml
106
+ - ".rspec"
107
+ - ".travis.yml"
102
108
  - Gemfile
103
109
  - Gemfile.lock
104
110
  - LICENSE.txt
@@ -110,6 +116,7 @@ files:
110
116
  - lib/git_presenter.rb
111
117
  - lib/git_presenter/controller.rb
112
118
  - lib/git_presenter/presentation.rb
119
+ - lib/git_presenter/shell.rb
113
120
  - lib/git_presenter/slide.rb
114
121
  - spec/bugs/max_10_commits_being_parsed_spec.rb
115
122
  - spec/integration/initialize_presentation_spec.rb
@@ -125,29 +132,24 @@ files:
125
132
  homepage: http://github.com/pythonandchips/git-presenter
126
133
  licenses:
127
134
  - MIT
135
+ metadata: {}
128
136
  post_install_message:
129
137
  rdoc_options: []
130
138
  require_paths:
131
139
  - lib
132
140
  required_ruby_version: !ruby/object:Gem::Requirement
133
- none: false
134
141
  requirements:
135
- - - ! '>='
142
+ - - ">="
136
143
  - !ruby/object:Gem::Version
137
144
  version: '0'
138
- segments:
139
- - 0
140
- hash: 2611368202741633093
141
145
  required_rubygems_version: !ruby/object:Gem::Requirement
142
- none: false
143
146
  requirements:
144
- - - ! '>='
147
+ - - ">="
145
148
  - !ruby/object:Gem::Version
146
149
  version: '0'
147
150
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 1.8.15
151
+ rubygems_version: 3.2.3
150
152
  signing_key:
151
- specification_version: 3
153
+ specification_version: 4
152
154
  summary: Code presentation tool using git
153
155
  test_files: []