git_presenter 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/VERSION +1 -1
- data/git_presenter.gemspec +5 -2
- data/lib/git_presenter.rb +10 -9
- data/lib/git_presenter/presentation.rb +1 -0
- data/lib/git_presenter/slide.rb +2 -0
- data/spec/integration/moving_through_presentation_spec.rb +13 -2
- data/spec/integration/start_presentation_spec.rb +1 -1
- data/spec/lib/git_presenter/slide_spec.rb +17 -0
- data/spec/support/git_helpers.rb +27 -2
- metadata +28 -17
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.2.8)
|
4
5
|
coderay (1.0.6)
|
5
6
|
diff-lcs (1.1.3)
|
6
7
|
git (1.2.5)
|
@@ -14,6 +15,8 @@ GEM
|
|
14
15
|
rake
|
15
16
|
rdoc
|
16
17
|
json (1.7.3)
|
18
|
+
launchy (2.1.0)
|
19
|
+
addressable (~> 2.2.6)
|
17
20
|
method_source (0.7.1)
|
18
21
|
mime-types (1.18)
|
19
22
|
posix-spawn (0.3.6)
|
@@ -42,6 +45,7 @@ DEPENDENCIES
|
|
42
45
|
bundler
|
43
46
|
grit (~> 2.4)
|
44
47
|
jeweler (~> 1.6)
|
48
|
+
launchy (~> 2.1)
|
45
49
|
pry
|
46
50
|
rcov (~> 0.9)
|
47
51
|
rspec (~> 2.7)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/git_presenter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "git_presenter"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Colin Gemmell"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-07-10"
|
13
13
|
s.description = "Code presentation tool using git"
|
14
14
|
s.email = "pythonandchips@gmail.com"
|
15
15
|
s.executables = ["git-presenter"]
|
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
|
56
56
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
57
|
s.add_runtime_dependency(%q<grit>, ["~> 2.4"])
|
58
|
+
s.add_runtime_dependency(%q<launchy>, ["~> 2.1"])
|
58
59
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
59
60
|
s.add_development_dependency(%q<rspec>, ["~> 2.7"])
|
60
61
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
@@ -63,6 +64,7 @@ Gem::Specification.new do |s|
|
|
63
64
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
64
65
|
else
|
65
66
|
s.add_dependency(%q<grit>, ["~> 2.4"])
|
67
|
+
s.add_dependency(%q<launchy>, ["~> 2.1"])
|
66
68
|
s.add_dependency(%q<pry>, [">= 0"])
|
67
69
|
s.add_dependency(%q<rspec>, ["~> 2.7"])
|
68
70
|
s.add_dependency(%q<bundler>, [">= 0"])
|
@@ -72,6 +74,7 @@ Gem::Specification.new do |s|
|
|
72
74
|
end
|
73
75
|
else
|
74
76
|
s.add_dependency(%q<grit>, ["~> 2.4"])
|
77
|
+
s.add_dependency(%q<launchy>, ["~> 2.1"])
|
75
78
|
s.add_dependency(%q<pry>, [">= 0"])
|
76
79
|
s.add_dependency(%q<rspec>, ["~> 2.7"])
|
77
80
|
s.add_dependency(%q<bundler>, [">= 0"])
|
data/lib/git_presenter.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'grit'
|
2
|
+
require 'yaml'
|
3
|
+
require 'readline'
|
4
|
+
require 'launchy'
|
4
5
|
|
5
6
|
class GitPresenter
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require 'git_presenter/presentation'
|
8
|
+
require 'git_presenter/controller'
|
9
|
+
require 'git_presenter/slide'
|
9
10
|
|
10
11
|
def initialize(current_dir, interactive=true)
|
11
12
|
@controller = Controller.new(current_dir)
|
@@ -13,14 +14,14 @@ class GitPresenter
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def execute(command)
|
16
|
-
if command ==
|
17
|
+
if command == 'init'
|
17
18
|
@controller.initialise_presentation
|
18
|
-
elsif command ==
|
19
|
+
elsif command == 'start'
|
19
20
|
@presentation = @controller.start_presentation
|
20
21
|
if @interactive
|
21
22
|
enter_run_loop
|
22
23
|
end
|
23
|
-
elsif command ==
|
24
|
+
elsif command == 'update'
|
24
25
|
@controller.update_presentation
|
25
26
|
else
|
26
27
|
puts @presentation.execute(command)
|
data/lib/git_presenter/slide.rb
CHANGED
@@ -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
|
|
@@ -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"
|
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,6 +163,17 @@ 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|
|
@@ -31,7 +31,7 @@ describe "starting a presentation" do
|
|
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
|
@@ -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
|
data/spec/support/git_helpers.rb
CHANGED
@@ -71,10 +71,10 @@ class GitHelper
|
|
71
71
|
commits
|
72
72
|
end
|
73
73
|
|
74
|
-
def start_presentation(
|
74
|
+
def start_presentation(commands=[])
|
75
75
|
commits = initialise_presentation({:delay => true})
|
76
76
|
Dir.chdir(@presentation_dir) do
|
77
|
-
|
77
|
+
add_commands(commands) unless commands.empty?
|
78
78
|
presenter = GitPresenter.new('.', false)
|
79
79
|
presenter = presenter.execute('start')
|
80
80
|
yield(commits, presenter) if block_given?
|
@@ -102,6 +102,31 @@ class GitHelper
|
|
102
102
|
removed_commit
|
103
103
|
end
|
104
104
|
|
105
|
+
def add_commands(commands)
|
106
|
+
commands.each do |command|
|
107
|
+
if command.include?(:run)
|
108
|
+
add_command(command[:run], command[:on_slide])
|
109
|
+
end
|
110
|
+
if command.include?(:launch)
|
111
|
+
add_launch(command[:launch], command[:on_slide])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_launch(command, add_command_to_commit=nil)
|
117
|
+
Dir.chdir(PRESENTATION_DIR) do
|
118
|
+
presentation = YAML.parse(File.open(".presentation")).to_ruby
|
119
|
+
if !add_command_to_commit.nil?
|
120
|
+
presentation["slides"][add_command_to_commit]["slide"]["launch"] = command
|
121
|
+
else
|
122
|
+
presentation["slides"] << {"slide" => {"launch" => command}}
|
123
|
+
end
|
124
|
+
File.open(".presentation", "w") do |file|
|
125
|
+
file.write(presentation.to_yaml)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
105
130
|
def add_command(command, add_command_to_commit=nil)
|
106
131
|
Dir.chdir(PRESENTATION_DIR) do
|
107
132
|
presentation = YAML.parse(File.open(".presentation")).to_ruby
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
16
|
-
requirement: &
|
16
|
+
requirement: &70174479333640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '2.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70174479333640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: launchy
|
27
|
+
requirement: &70174478378360 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70174478378360
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: pry
|
27
|
-
requirement: &
|
38
|
+
requirement: &70174478379800 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70174478379800
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rspec
|
38
|
-
requirement: &
|
49
|
+
requirement: &70174478381240 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '2.7'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70174478381240
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: bundler
|
49
|
-
requirement: &
|
60
|
+
requirement: &70174478382680 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70174478382680
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: jeweler
|
60
|
-
requirement: &
|
71
|
+
requirement: &70174478385540 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ~>
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '1.6'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70174478385540
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: rcov
|
71
|
-
requirement: &
|
82
|
+
requirement: &70174478954780 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ~>
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: '0.9'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70174478954780
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: pry
|
82
|
-
requirement: &
|
93
|
+
requirement: &70174478102720 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,7 +98,7 @@ dependencies:
|
|
87
98
|
version: '0'
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70174478102720
|
91
102
|
description: Code presentation tool using git
|
92
103
|
email: pythonandchips@gmail.com
|
93
104
|
executables:
|
@@ -137,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
148
|
version: '0'
|
138
149
|
segments:
|
139
150
|
- 0
|
140
|
-
hash:
|
151
|
+
hash: -3910658736089827662
|
141
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
153
|
none: false
|
143
154
|
requirements:
|