pgit 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.travis.yml +1 -0
- data/README.markdown +32 -9
- data/Rakefile +12 -0
- data/bin/pgit +167 -25
- data/lib/pgit.rb +40 -10
- data/lib/pgit/bilateral/handle_back.rb +22 -0
- data/lib/pgit/bilateral/handle_choose_story.rb +31 -0
- data/lib/pgit/bilateral/story.rb +44 -0
- data/lib/pgit/command.rb +83 -0
- data/lib/pgit/command/add.rb +36 -0
- data/lib/pgit/command/application.rb +21 -0
- data/lib/pgit/command/edit.rb +36 -0
- data/lib/pgit/command/remove.rb +36 -0
- data/lib/pgit/command/run.rb +32 -0
- data/lib/pgit/command/show.rb +53 -0
- data/lib/pgit/configuration.rb +27 -3
- data/lib/pgit/current_project.rb +9 -45
- data/lib/pgit/current_project/validator.rb +2 -1
- data/lib/pgit/error/external.rb +11 -0
- data/lib/pgit/error/user.rb +12 -0
- data/lib/pgit/helpers/heredoc.rb +17 -0
- data/lib/pgit/helpers/query_methods.rb +63 -0
- data/lib/pgit/helpers/string_extensions.rb +29 -0
- data/lib/pgit/installer/bash_auto_completion.rb +57 -0
- data/lib/pgit/pivotal/collection_request.rb +21 -0
- data/lib/pgit/pivotal/individual_request.rb +47 -0
- data/lib/pgit/pivotal/iteration.rb +6 -0
- data/lib/pgit/pivotal/iterations.rb +15 -0
- data/lib/pgit/pivotal/project.rb +6 -0
- data/lib/pgit/pivotal/projects.rb +20 -0
- data/lib/pgit/pivotal/query.rb +8 -0
- data/lib/pgit/pivotal/request.rb +33 -0
- data/lib/pgit/pivotal/request/query.rb +25 -0
- data/lib/pgit/pivotal/story.rb +38 -0
- data/lib/pgit/pivotal_request_validator.rb +1 -1
- data/lib/pgit/project.rb +78 -0
- data/lib/pgit/project/add.rb +28 -0
- data/lib/pgit/project/application.rb +21 -0
- data/lib/pgit/project/interactive_adder.rb +41 -0
- data/lib/pgit/project/remove.rb +41 -0
- data/lib/pgit/project/reuse_api_token_adder.rb +48 -0
- data/lib/pgit/response_handler.rb +16 -0
- data/lib/pgit/root.rb +5 -0
- data/lib/pgit/status.rb +16 -0
- data/lib/pgit/story_branch/application.rb +3 -3
- data/lib/pgit/{name_parser.rb → story_branch/name_parser.rb} +0 -0
- data/lib/pgit/story_branch/story_id_parser.rb +11 -0
- data/lib/pgit/validators/project_validator.rb +20 -0
- data/lib/pgit/version.rb +1 -1
- data/lib/pivotal +0 -0
- data/pgit.gemspec +5 -0
- data/spec/fixtures/iterations +1 -0
- data/spec/pgit/bilateral/handle_back_spec.rb +29 -0
- data/spec/pgit/bilateral/handle_choose_story_spec.rb +17 -0
- data/spec/pgit/bilateral/story_spec.rb +178 -0
- data/spec/pgit/command/add_spec.rb +68 -0
- data/spec/pgit/command/application_spec.rb +110 -0
- data/spec/pgit/command/edit_spec.rb +61 -0
- data/spec/pgit/command/remove_spec.rb +76 -0
- data/spec/pgit/command/run_spec.rb +49 -0
- data/spec/pgit/command/show_spec.rb +95 -0
- data/spec/pgit/command_spec.rb +299 -0
- data/spec/pgit/configuration_spec.rb +121 -18
- data/spec/pgit/current_project/validator_spec.rb +2 -1
- data/spec/pgit/current_project_spec.rb +20 -71
- data/spec/pgit/{external_error_spec.rb → error/external_spec.rb} +3 -3
- data/spec/pgit/error/user_spec.rb +17 -0
- data/spec/pgit/helpers/heredoc_spec.rb +33 -0
- data/spec/pgit/helpers/query_methods_spec.rb +24 -0
- data/spec/pgit/helpers/string_extensions_spec.rb +49 -0
- data/spec/pgit/installer/bash_auto_completion_spec.rb +134 -0
- data/spec/pgit/pivotal/individual_request_spec.rb +32 -0
- data/spec/pgit/pivotal/iteration_spec.rb +19 -0
- data/spec/pgit/pivotal/iterations_spec.rb +37 -0
- data/spec/pgit/pivotal/project_spec.rb +9 -0
- data/spec/pgit/pivotal/projects_spec.rb +48 -0
- data/spec/pgit/pivotal/request/query_spec.rb +24 -0
- data/spec/pgit/pivotal/story_spec.rb +113 -0
- data/spec/pgit/pivotal_request_validator_spec.rb +3 -3
- data/spec/pgit/project/add_spec.rb +52 -0
- data/spec/pgit/project/application_spec.rb +69 -0
- data/spec/pgit/project/interactive_adder_spec.rb +45 -0
- data/spec/pgit/project/remove_spec.rb +86 -0
- data/spec/pgit/project/reuse_api_token_adder_spec.rb +41 -0
- data/spec/pgit/project_spec.rb +513 -0
- data/spec/pgit/status_spec.rb +40 -0
- data/spec/pgit/story_branch/application_spec.rb +5 -8
- data/spec/pgit/story_branch/name_parser_spec.rb +3 -3
- data/spec/pgit/story_branch/story_id_parser_spec.rb +17 -0
- data/spec/pgit/validators/project_validator_spec.rb +39 -0
- metadata +146 -21
- data/lib/pgit/configuration/layout_error.rb +0 -9
- data/lib/pgit/configuration/missing_attributes_error.rb +0 -10
- data/lib/pgit/configuration/not_found_error.rb +0 -10
- data/lib/pgit/configuration/project_missing_error.rb +0 -10
- data/lib/pgit/configuration/validator.rb +0 -41
- data/lib/pgit/current_project/no_paths_match_working_dir_error.rb +0 -10
- data/lib/pgit/external_error.rb +0 -9
- data/lib/pgit/installer/configuration.rb +0 -34
- data/lib/pgit/story.rb +0 -44
- data/spec/pgit/configuration/missing_attributes_error_spec.rb +0 -30
- data/spec/pgit/configuration/not_found_error_spec.rb +0 -17
- data/spec/pgit/configuration/project_missing_error_spec.rb +0 -30
- data/spec/pgit/configuration/validator_spec.rb +0 -79
- data/spec/pgit/current_project/no_paths_match_working_dir_error_spec.rb +0 -17
- data/spec/pgit/installer/configuration_spec.rb +0 -162
- data/spec/pgit/story_spec.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c992ab6fde90207008812368d16901885da908e4
|
4
|
+
data.tar.gz: edb7562be4874a0c82f28e17cdd70734bce7d195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e467a864a8d3f2afbb1918b17c2c7715bfa3a800ea892520c9464782bb894706bd012454d09e3b8bd77a4739c370312cbc06250015ee35b29919a7c001fb615e
|
7
|
+
data.tar.gz: 672584afd6286457f95837d4544180d94fa291a9e743420cd34b6bee1ef2cfa8a2c43ea62d8ca2b0e49a756fced144adbeae97a278abda4117a21602bcdab930
|
data/.agignore
ADDED
data/.travis.yml
CHANGED
data/README.markdown
CHANGED
@@ -21,27 +21,50 @@ will create a branch for you named `implement-really-cool-feature-10102004`
|
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
24
|
-
|
24
|
+
### Install via RubyGems:
|
25
25
|
|
26
26
|
```
|
27
27
|
$ gem install pgit
|
28
28
|
```
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
### Create autocompletion script and configuration file
|
32
31
|
```
|
33
32
|
$ pgit install
|
34
33
|
```
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
### Add a project
|
36
|
+
|
37
|
+
The following will ask you questions as to which Pivotal Tracker project to associate to your working directory:
|
38
|
+
|
39
|
+
```
|
40
|
+
$ pgit proj add
|
41
|
+
```
|
42
|
+
|
43
|
+
### Create a branch
|
44
|
+
|
45
|
+
Once your working directory is associated to a Pivotal Tracker project,
|
46
|
+
this will ask you which branch to create:
|
47
|
+
|
48
|
+
```
|
49
|
+
$ pgit branch
|
50
|
+
```
|
51
|
+
|
52
|
+
### Add a command for deployment
|
39
53
|
|
40
|
-
|
54
|
+
Do you want to automate the merging/rebasing process?
|
55
|
+
`STORY_BRANCH` is the memoized current branch.
|
41
56
|
|
42
|
-
|
43
|
-
|
57
|
+
```
|
58
|
+
pgit cmd add --name="finish" --steps="git fetch origin master, git rebase origin/master, git checkout master, git merge STORY_BRANCH, git branch -d STORY_BRANCH, git push origin :STORY_BRANCH, git push origin master"
|
59
|
+
```
|
60
|
+
|
61
|
+
You can run the steps of the command as follows:
|
62
|
+
|
63
|
+
```
|
64
|
+
$ pgit cmd run finish
|
65
|
+
```
|
44
66
|
|
45
67
|
|
46
68
|
## Development
|
69
|
+
|
47
70
|
See https://www.pivotaltracker.com/n/projects/1228944 for information.
|
data/Rakefile
CHANGED
@@ -18,3 +18,15 @@ desc 'Run specs'
|
|
18
18
|
require 'rspec/core/rake_task'
|
19
19
|
RSpec::Core::RakeTask.new
|
20
20
|
task :default => [:spec]
|
21
|
+
|
22
|
+
namespace :spec do
|
23
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
24
|
+
puts 'Running unit specs'
|
25
|
+
t.pattern = Dir['spec/pgit/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
29
|
+
puts 'Running integration specs'
|
30
|
+
t.pattern = Dir['spec/integration/**/*_spec.rb']
|
31
|
+
end
|
32
|
+
end
|
data/bin/pgit
CHANGED
@@ -10,6 +10,13 @@ version Pgit::VERSION
|
|
10
10
|
subcommand_option_handling :normal
|
11
11
|
arguments :strict
|
12
12
|
|
13
|
+
desc "Color output"
|
14
|
+
default_value :true
|
15
|
+
switch :color
|
16
|
+
|
17
|
+
desc "Print backtrace if there is an exception"
|
18
|
+
switch :trace
|
19
|
+
|
13
20
|
# desc 'Path to the config file'
|
14
21
|
# default_value "#{ENV['HOME']}/.pgit.rc.yml"
|
15
22
|
# arg_name '/path/to/.pivotal.yml'
|
@@ -21,11 +28,154 @@ arguments :strict
|
|
21
28
|
# desc 'PivotalTracker API Token'
|
22
29
|
# arg_name 'secr3tT0ken123'
|
23
30
|
# flag [:'api-token']
|
31
|
+
desc "Work with projects"
|
32
|
+
command :proj do |p|
|
33
|
+
|
34
|
+
p.desc "add a project"
|
35
|
+
p.command :add do |a|
|
36
|
+
|
37
|
+
a.desc "the id associated to the Pivotal Tracker project"
|
38
|
+
a.arg_name '12030405'
|
39
|
+
a.flag :d, :id
|
40
|
+
|
41
|
+
a.desc "the filepath that is going to be associated to the Pivotal Tracker and Git project"
|
42
|
+
a.arg_name '"/some/file/path"'
|
43
|
+
a.default_value Dir.pwd
|
44
|
+
a.flag :p, :path
|
45
|
+
|
46
|
+
a.desc "your Pivotal Tracker API token"
|
47
|
+
a.arg_name "token"
|
48
|
+
a.flag :t, :api_token
|
49
|
+
|
50
|
+
a.action do |global_options,options,args|
|
51
|
+
app = PGit::Project::Application.new(global_options, options, args)
|
52
|
+
add = PGit::Project::Add.new(app)
|
53
|
+
add.execute!
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
p.desc "remove a project"
|
58
|
+
p.command :rm do |a|
|
59
|
+
|
60
|
+
a.desc "the path whose pgit project will be removed"
|
61
|
+
a.arg_name '"/some/file/path"'
|
62
|
+
a.default_value Dir.pwd
|
63
|
+
a.flag :p, :path
|
64
|
+
|
65
|
+
a.action do |global_options,options,args|
|
66
|
+
app = PGit::Project::Application.new(global_options, options, args)
|
67
|
+
rm = PGit::Project::Remove.new(app)
|
68
|
+
rm.execute!
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Work with custom commands defined in the current project"
|
74
|
+
command :cmd do |c|
|
75
|
+
c.desc "show the custom command(s)"
|
76
|
+
c.arg_name 'command_name'
|
77
|
+
c.command :show do |s|
|
78
|
+
s.action do |global_options,options,args|
|
79
|
+
app = PGit::Command::Application.new(global_options,
|
80
|
+
options,
|
81
|
+
args)
|
82
|
+
|
83
|
+
show = PGit::Command::Show.new(app)
|
84
|
+
show.execute!
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
c.desc "run a command"
|
89
|
+
c.arg_name 'command_name'
|
90
|
+
c.command :run do |r|
|
91
|
+
r.action do |global_options,options,args|
|
92
|
+
app = PGit::Command::Application.new(global_options,
|
93
|
+
options,
|
94
|
+
args)
|
95
|
+
run = PGit::Command::Run.new(app)
|
96
|
+
run.execute!
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
c.desc "add a command"
|
101
|
+
c.command :add do |a|
|
102
|
+
accept(Array) do |value|
|
103
|
+
value.split(',').map {|item| item.strip }
|
104
|
+
end
|
105
|
+
a.desc "name of the command"
|
106
|
+
a.arg_name "new_command_name"
|
107
|
+
a.flag :n, :name, required: true
|
108
|
+
|
109
|
+
a.desc "steps of the command, delimited by commas"
|
110
|
+
a.arg_name "steps"
|
111
|
+
a.flag :s, :steps, required: true, type: Array
|
112
|
+
|
113
|
+
a.action do |global_options,options,args|
|
114
|
+
app = PGit::Command::Application.new(global_options,
|
115
|
+
options,
|
116
|
+
args)
|
117
|
+
add = PGit::Command::Add.new(app)
|
118
|
+
add.execute!
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
c.desc "edit a command"
|
123
|
+
c.command :edit do |a|
|
124
|
+
accept(Array) do |value|
|
125
|
+
value.split(',').map {|item| item.strip }
|
126
|
+
end
|
127
|
+
a.desc "name of the command"
|
128
|
+
a.arg_name "new_command_name"
|
129
|
+
a.flag :n, :name, required: true
|
130
|
+
|
131
|
+
a.desc "steps of the command, delimited by commas"
|
132
|
+
a.arg_name "steps"
|
133
|
+
a.flag :s, :steps, required: true, type: Array
|
134
|
+
|
135
|
+
a.action do |global_options,options,args|
|
136
|
+
app = PGit::Command::Application.new(global_options,
|
137
|
+
options,
|
138
|
+
args)
|
139
|
+
edit = PGit::Command::Edit.new(app)
|
140
|
+
edit.execute!
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
c.desc "remove a command"
|
145
|
+
c.command :rm do |a|
|
146
|
+
accept(Array) do |value|
|
147
|
+
value.split(',').map {|item| item.strip }
|
148
|
+
end
|
149
|
+
a.desc "name of the command"
|
150
|
+
a.arg_name "new_command_name"
|
151
|
+
a.flag :n, :name, required: true
|
152
|
+
|
153
|
+
a.action do |global_options,options,args|
|
154
|
+
app = PGit::Command::Application.new(global_options,
|
155
|
+
options,
|
156
|
+
args)
|
157
|
+
remove = PGit::Command::Remove.new(app)
|
158
|
+
remove.execute!
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Show the status of the story being worked on"
|
164
|
+
command :status do |c|
|
165
|
+
c.action do |global_options,options,args|
|
166
|
+
status = PGit::Status.new(global_options,options,args)
|
167
|
+
status.execute!
|
168
|
+
end
|
169
|
+
end
|
24
170
|
|
25
171
|
desc "Installs the pgit configuration file"
|
26
172
|
command :install do |c|
|
27
173
|
c.action do |global_options,options,args|
|
28
|
-
PGit::Installer::
|
174
|
+
completer = PGit::Installer::BashAutoCompletion.new(global_options,
|
175
|
+
options,
|
176
|
+
args)
|
177
|
+
completer.write_completer_file
|
178
|
+
completer.source_completer_from_bashrc
|
29
179
|
end
|
30
180
|
end
|
31
181
|
|
@@ -41,44 +191,34 @@ command :story_branch do |c|
|
|
41
191
|
c.arg_name 'STORY_ID'
|
42
192
|
c.flag :s, :start
|
43
193
|
|
44
|
-
# c.desc "Merge back to staging, remove local and remote (origin?) branches"
|
45
|
-
# c.switch :f, :finish
|
46
|
-
|
47
|
-
# c.desc "Attempts to join the story-branch that, presumably, already exists"
|
48
|
-
# c.arg_name 'STORY_ID'
|
49
|
-
# c.flag :j, :join
|
50
|
-
|
51
194
|
c.action do |global_options,options,args|
|
52
195
|
PGit::StoryBranch::Application.new(global_options, options, args)
|
53
196
|
end
|
54
197
|
end
|
55
198
|
|
56
|
-
|
57
|
-
|
58
|
-
# command :commit do |c|
|
59
|
-
# arg_name 'Describe arguments to commit here'
|
60
|
-
# c.action do |global_options,options,args|
|
61
|
-
# puts "commit command ran"
|
62
|
-
# end
|
63
|
-
# end
|
64
|
-
|
199
|
+
desc 'Deal with iterations'
|
65
200
|
|
201
|
+
command :branch do |c|
|
202
|
+
c.desc "The scope of the iteration. Valid scopes are 'current', 'current_backlog', 'backlog', and 'done'"
|
203
|
+
c.default_value :current_backlog
|
204
|
+
c.flag :s, :scope
|
205
|
+
c.action do |global_options,options,args|
|
206
|
+
bilateral_story = PGit::Bilateral::Story.new(options)
|
207
|
+
bilateral_story.execute!
|
208
|
+
end
|
209
|
+
end
|
66
210
|
desc 'Initializes configuration file'
|
67
|
-
|
68
211
|
arg_name 'path/to/config_file'
|
69
212
|
|
70
|
-
# command :init_config do |c|
|
71
|
-
# c.action do |global_options,options,args|
|
72
|
-
# puts "init_config command ran"
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
|
76
213
|
pre do |global,command,options,args|
|
77
214
|
# Pre logic here
|
78
215
|
# Return true to proceed; false to abort and not call the
|
79
216
|
# chosen command
|
80
217
|
# Use skips_pre before a command to skip this block
|
81
218
|
# on that command only
|
219
|
+
# $trace = true if global.fetch(:trace)
|
220
|
+
$trace = true if global.fetch(:trace)
|
221
|
+
Rainbow.enabled = global.fetch(:color)
|
82
222
|
true
|
83
223
|
end
|
84
224
|
|
@@ -91,7 +231,9 @@ end
|
|
91
231
|
on_error do |exception|
|
92
232
|
# Error logic here
|
93
233
|
# return false to skip default error handling
|
94
|
-
|
234
|
+
warn Rainbow("error: #{exception}").color(:red)
|
235
|
+
exception.backtrace.each { |e| warn Rainbow(e).color(:red) } if $trace
|
236
|
+
exit 1
|
95
237
|
end
|
96
238
|
|
97
239
|
exit run(ARGV)
|
data/lib/pgit.rb
CHANGED
@@ -1,22 +1,52 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'rainbow'
|
3
|
+
require 'interactive'
|
4
|
+
require 'active_model'
|
5
|
+
require 'pgit/root.rb'
|
6
|
+
require 'pgit/validators/project_validator'
|
7
|
+
require 'pgit/pivotal/request'
|
8
|
+
require 'pgit/pivotal/request/query'
|
9
|
+
require 'pgit/pivotal/collection_request'
|
10
|
+
require 'pgit/pivotal/individual_request'
|
11
|
+
require 'pgit/helpers/string_extensions'
|
12
|
+
require 'pgit/helpers/heredoc'
|
13
|
+
require 'pgit/helpers/query_methods'
|
14
|
+
require 'pgit/response_handler'
|
15
|
+
require 'pgit/bilateral/handle_back'
|
16
|
+
require 'pgit/bilateral/handle_choose_story'
|
17
|
+
require 'pgit/bilateral/story'
|
2
18
|
require 'pgit/error'
|
3
|
-
require 'pgit/
|
4
|
-
require 'pgit/
|
5
|
-
require 'pgit/configuration/project_missing_error'
|
6
|
-
require 'pgit/configuration/missing_attributes_error'
|
7
|
-
require 'pgit/configuration/validator'
|
19
|
+
require 'pgit/error/user'
|
20
|
+
require 'pgit/error/external'
|
8
21
|
require 'pgit/configuration'
|
22
|
+
require 'pgit/command'
|
23
|
+
require 'pgit/command/application'
|
24
|
+
require 'pgit/command/add'
|
25
|
+
require 'pgit/command/edit'
|
26
|
+
require 'pgit/command/remove'
|
27
|
+
require 'pgit/command/run'
|
28
|
+
require 'pgit/command/show'
|
9
29
|
require 'pgit/current_branch'
|
10
|
-
require 'pgit/
|
30
|
+
require 'pgit/project'
|
31
|
+
require 'pgit/project/application'
|
32
|
+
require 'pgit/project/reuse_api_token_adder'
|
33
|
+
require 'pgit/project/interactive_adder'
|
34
|
+
require 'pgit/project/add'
|
35
|
+
require 'pgit/project/remove'
|
36
|
+
require 'pgit/pivotal/story'
|
37
|
+
require 'pgit/pivotal/iteration'
|
38
|
+
require 'pgit/pivotal/iterations'
|
39
|
+
require 'pgit/pivotal/project'
|
40
|
+
require 'pgit/pivotal/projects'
|
11
41
|
require 'pgit/current_project/validator'
|
12
42
|
require 'pgit/current_project'
|
13
|
-
require 'pgit/installer/
|
14
|
-
require 'pgit/name_parser'
|
43
|
+
require 'pgit/installer/bash_auto_completion'
|
15
44
|
require 'pgit/pivotal_request_validator'
|
16
|
-
require 'pgit/external_error'
|
17
|
-
require 'pgit/story'
|
18
45
|
require 'pgit/story_branch'
|
46
|
+
require 'pgit/story_branch/name_parser'
|
47
|
+
require 'pgit/story_branch/story_id_parser'
|
19
48
|
require 'pgit/story_branch/application'
|
49
|
+
require 'pgit/status'
|
20
50
|
require 'pgit/version.rb'
|
21
51
|
require 'yaml'
|
22
52
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PGit
|
2
|
+
module Bilateral
|
3
|
+
class HandleBack
|
4
|
+
def initialize(options)
|
5
|
+
@parent_question = options.fetch(:parent_question)
|
6
|
+
@response = options.fetch(:response)
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute!
|
10
|
+
if response_can_be_handled?
|
11
|
+
@parent_question.reask!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def response_can_be_handled?
|
18
|
+
@response.back?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pgit'
|
2
|
+
|
3
|
+
module PGit
|
4
|
+
module Bilateral
|
5
|
+
class HandleChooseStory < ResponseHandler
|
6
|
+
def initialize(options)
|
7
|
+
@response = options.fetch(:response)
|
8
|
+
@stories = options.fetch(:stories)
|
9
|
+
@response_handlers = [PGit::Bilateral::HandleBack]
|
10
|
+
name_parser = PGit::StoryBranch::NameParser.new(chosen_story)
|
11
|
+
story_branch = PGit::StoryBranch.new(name_parser)
|
12
|
+
|
13
|
+
story_branch.start
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def chosen_story
|
19
|
+
@stories[@response.to_i]
|
20
|
+
end
|
21
|
+
|
22
|
+
def options(new_response)
|
23
|
+
{ response: new_response, stories: @stories, parent_question: @parent_question }
|
24
|
+
end
|
25
|
+
|
26
|
+
def response_can_be_handled?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|