instructions_list 1.0.6.beta → 1.0.7.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a55844573f360de2b3cd37b8c0a5c31a97c67a66
4
- data.tar.gz: 441bc682eb4b42bde28865fe47174864fa135b19
3
+ metadata.gz: 20ffa50944492bc3074ef7f480f26844c8f1ebfe
4
+ data.tar.gz: 11caa36e95745d62e008a83f88d299eadd040648
5
5
  SHA512:
6
- metadata.gz: f38a513e2bc0cb04033680ceae91e811a9014c76663a38f354b3207a8e26eb58c0f77a35dd3445bde2f4c67c486498178cc009e6c170671ca42de3d753b23b46
7
- data.tar.gz: dbda2a8fb9ed60853235115c40f1cc72c8eb3f5e0b7e7e8427516a68871b7e90bd8319505292edf7ad2f5d9845d2959db4b7d157a8a5f0c4112a5ea0baff2ddf
6
+ metadata.gz: 0aa2e4d5bfe0296e0e7b740bf4cf1064462647d2f8ae8696624e8bd662e0fb34b75f9e17b066b1370040085da04f2c662cdd4e7bb6ee53dde440fb4e15a8a8c7
7
+ data.tar.gz: c9521aef1bf40101b234da1afb83bcccca381c641c251357c8bdb10254c1ad3405dc26dad550019ab7340574e5a15a130ddef521e775f628c8e25438a2342c59
data/exe/il CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "thor"
3
- require 'pry'
3
+ require 'byebug'
4
4
  require_relative "../lib/instructions_list/version"
5
5
  require_relative "../lib/instructions_list"
6
6
 
@@ -101,7 +101,7 @@ module InstructionsList
101
101
  instructable do
102
102
  load_from "Instructions", HOME_CACHE << "/" if home?
103
103
  load_from "Projects", PROJECT_CACHE << "/" if project?
104
- handle_instruction name,STACK,options[:force],p
104
+ do_instruction name, STACK, options[:force], p
105
105
 
106
106
  end
107
107
  rescue => e
@@ -114,6 +114,34 @@ module InstructionsList
114
114
 
115
115
  end
116
116
 
117
+ desc "undo", "undo an instruction"
118
+ option :force
119
+ def undo name
120
+ if name.nil?
121
+ say "oops ! you need a name"
122
+ return
123
+ end
124
+
125
+ begin
126
+ CHECKED.clear
127
+ STACK.clear
128
+ instructable do
129
+ load_from "Instructions", HOME_CACHE << "/" if home?
130
+ load_from "Projects", PROJECT_CACHE << "/" if project?
131
+ undo_instruction name, STACK, options[:force], p
132
+
133
+ end
134
+ rescue => e
135
+ puts ""
136
+ puts e.message
137
+ puts ""
138
+ puts `il list`
139
+ puts ""
140
+ end
141
+
142
+ end
143
+
144
+
117
145
  map list: :instructions
118
146
 
119
147
  no_tasks do
@@ -196,7 +224,7 @@ module InstructionsList
196
224
  end
197
225
  end
198
226
 
199
- def handle_instruction name,stack,force,progressbar
227
+ def do_instruction name, stack, force, progressbar
200
228
  instruction = InstructionsList::INSTRUCTIONS.find { |i|
201
229
  command_name(i.name.gsub(" ","_")) == command_name(name)
202
230
  }
@@ -204,14 +232,30 @@ module InstructionsList
204
232
  instruction.depends_on.each do |dependancy|
205
233
  unless stack.include? command_name(dependancy.gsub(" ","_"))
206
234
  stack << command_name(dependancy.gsub(" ","_"))
207
- handle_instruction(command_name(dependancy.gsub(" ","_")),stack,force,progressbar)
235
+ do_instruction(command_name(dependancy.gsub(" ", "_")), stack, force, progressbar)
208
236
  end
209
237
  end
210
- execute instruction,force: force
238
+ execute_instruction instruction, force: force
211
239
 
212
240
  end
213
241
 
214
- def execute instruction,force: false
242
+ def undo_instruction name, stack, force, progressbar
243
+ instruction = InstructionsList::INSTRUCTIONS.find { |i|
244
+ command_name(i.name.gsub(" ","_")) == command_name(name)
245
+ }
246
+ raise "Ooooops cant find #{command_name(name)}" if instruction.nil?
247
+ instruction.depends_on.each do |dependancy|
248
+ unless stack.include? command_name(dependancy.gsub(" ","_"))
249
+ stack << command_name(dependancy.gsub(" ","_"))
250
+ undo_instruction(command_name(dependancy.gsub(" ", "_")), stack, force, progressbar)
251
+ end
252
+ end
253
+
254
+ execute_uninstruction instruction, force: force
255
+
256
+ end
257
+
258
+ def execute_instruction instruction, force: false
215
259
  if force
216
260
  instruction.instruct.call()
217
261
  say "#{instruction.name} - forced!"
@@ -220,11 +264,25 @@ module InstructionsList
220
264
 
221
265
  unless instruction.instructed.call()
222
266
  instruction.instruct.call()
223
- mark_as_done instruction.name
224
- else
225
- check instruction.name
226
267
  end
268
+
269
+ mark_as_done instruction.name
270
+
271
+ end
272
+
273
+ def execute_uninstruction instruction, force: false
274
+
275
+ if instruction.respond_to? :uninstruct
276
+
277
+ instruction.uninstruct.call()
278
+
279
+ end
280
+
281
+ mark_as_undone instruction.name
282
+
227
283
  end
284
+
285
+
228
286
  end
229
287
  end
230
288
  end
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rr"
31
31
  spec.add_development_dependency "byebug"
32
32
  spec.add_dependency "thor"
33
- spec.add_dependency "pry"
34
33
  spec.add_dependency "tty"
35
34
 
36
35
 
@@ -1,3 +1,3 @@
1
1
  module InstructionsList
2
- VERSION = "1.0.6.beta"
2
+ VERSION = "1.0.7.beta"
3
3
  end
@@ -83,6 +83,9 @@ module InstructionsList
83
83
  `echo #{command_name(name.to_s.gsub(" ","_"))} >> #{STATE}`
84
84
  check command_name(name)
85
85
  end
86
+ def mark_as_undone(name)
87
+ `ex +g/#{name}/d -cwq #{STATE}`
88
+ end
86
89
 
87
90
  def command_name(name)
88
91
  name.to_s.gsub("_", ":")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instructions_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6.beta
4
+ version: 1.0.7.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coco Coder (aka Delaney Burke)
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: tty
113
99
  requirement: !ruby/object:Gem::Requirement