instructions_list 1.0.3.beta → 1.0.4.beta
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.
- checksums.yaml +4 -4
- data/exe/il +60 -98
- data/lib/instructions_list/version.rb +1 -1
- data/lib/instructions_list.rb +22 -13
- data/lib/package_manager.rb +1 -1
- metadata +2 -3
- data/.instructions/cache/install:redis.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 178f2f01804312efebddae3724913bd8a82f2cf9
|
4
|
+
data.tar.gz: 1888e74f845861bd7264939012230cac5168840a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f530cc89303795277fcf94eed2ea0543b0d9731454efe8b0d268aedf0014280425b1bee333c8f4a765318f98ae4c43ddface76bc54792fc8df5a3140a9339f87
|
7
|
+
data.tar.gz: e567d639a4819b3f9e409f874cd5cd0575d7ab1b60bea8ef8494484634a5e43a2442c8dbaf197d145ab1bf32747dabda078bb04dec196c567197e10522a44f6e
|
data/exe/il
CHANGED
@@ -4,21 +4,8 @@ require 'pry'
|
|
4
4
|
require_relative "../lib/instructions_list/version"
|
5
5
|
require_relative "../lib/instructions_list"
|
6
6
|
|
7
|
-
|
8
7
|
module InstructionsList
|
9
8
|
|
10
|
-
class Instructions < Thor
|
11
|
-
include Thor::Actions
|
12
|
-
|
13
|
-
def self.source_root
|
14
|
-
File.dirname(__FILE__)
|
15
|
-
end
|
16
|
-
desc "add", "add instruction"
|
17
|
-
def add name
|
18
|
-
puts "add #{name} instruction"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
9
|
class CLI < Thor
|
23
10
|
include Thor::Actions
|
24
11
|
|
@@ -27,14 +14,19 @@ module InstructionsList
|
|
27
14
|
end
|
28
15
|
desc "init KEY", "initialize a il directory with list key"
|
29
16
|
def init key
|
17
|
+
`mkdir -p #{INSTRUCTIONS_DIR}`
|
30
18
|
`touch #{KEY_PATH}`
|
31
19
|
`echo #{key} > #{KEY_PATH}`
|
32
|
-
connect key
|
33
20
|
end
|
34
21
|
desc "reset", "reset state"
|
35
22
|
def reset name=:all
|
36
23
|
instructable do
|
37
|
-
|
24
|
+
if name == :all
|
25
|
+
`rm #{STATE}` if File.exists? STATE
|
26
|
+
`rm -rf .instructions`
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
38
30
|
`ex +g/#{name}/d -cwq #{STATE}`
|
39
31
|
end
|
40
32
|
end
|
@@ -42,23 +34,15 @@ module InstructionsList
|
|
42
34
|
option :reset
|
43
35
|
def sync
|
44
36
|
if instructable?
|
45
|
-
|
46
|
-
puts "is instructable!"
|
47
|
-
|
48
37
|
`mkdir -p #{PROJECT_CACHE}`
|
49
|
-
puts "created the project cache"
|
50
38
|
`mkdir -p #{PROJECT_CACHE_ARTIFACTS}`
|
51
|
-
puts "created the project cache artifacts"
|
52
|
-
|
53
39
|
if options[:reset]
|
54
40
|
`rm -rf #{PROJECT_CACHE}` if Dir.exists? PROJECT_CACHE
|
55
41
|
return
|
56
42
|
end
|
57
|
-
|
58
43
|
instructable do
|
59
44
|
begin
|
60
45
|
CacheBuilder.new(get_key,HOST,cache=PROJECT_CACHE,artifact_cache=PROJECT_CACHE_ARTIFACTS).build
|
61
|
-
puts "built cache"
|
62
46
|
rescue SocketError
|
63
47
|
end
|
64
48
|
end
|
@@ -72,38 +56,23 @@ module InstructionsList
|
|
72
56
|
desc "instructions", "list all instructions"
|
73
57
|
def instructions
|
74
58
|
|
75
|
-
if
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
if instructable?
|
85
|
-
unless home?
|
86
|
-
|
87
|
-
list_from "Project", PROJECT_CACHE << "/" do |path|
|
88
|
-
say show_command_for path
|
59
|
+
if project?
|
60
|
+
puts "project instructions!\n"
|
61
|
+
puts "list home instructions!"
|
62
|
+
elsif home?
|
63
|
+
Dir.chdir(ENV['HOME']) do
|
64
|
+
list_from "home", HOME_CACHE << '/' do |name|
|
65
|
+
say show_command_for name
|
89
66
|
end
|
90
|
-
puts ""
|
91
|
-
list_from "Home Directory", HOME_CACHE << "/" do |path|
|
92
|
-
say show_command_for path
|
93
|
-
end
|
94
|
-
|
95
67
|
end
|
96
68
|
else
|
97
|
-
Dir.chdir
|
98
|
-
list_from "
|
99
|
-
say show_command_for
|
69
|
+
Dir.chdir(ENV['HOME']) do
|
70
|
+
list_from "home", HOME_CACHE << '/' do |name|
|
71
|
+
say show_command_for name
|
100
72
|
end
|
101
73
|
end
|
102
74
|
end
|
103
75
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
76
|
end
|
108
77
|
|
109
78
|
desc "info" , "display information"
|
@@ -112,36 +81,27 @@ module InstructionsList
|
|
112
81
|
say "host: #{HOST}"
|
113
82
|
end
|
114
83
|
|
115
|
-
desc "connect KEY" , "connect to a list"
|
116
|
-
def connect key
|
117
|
-
instructable do
|
118
|
-
disconnect
|
119
|
-
`echo #{key} > #{KEY_PATH}`
|
120
|
-
`il sync`
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
desc "disconnect" , "disconnect from a list"
|
126
|
-
def disconnect
|
127
|
-
instructable do
|
128
|
-
`il sync --reset`
|
129
|
-
`rm #{KEY_PATH}`
|
130
|
-
end
|
131
|
-
end
|
132
84
|
|
133
85
|
desc "do", "do an instruction"
|
134
86
|
option :force
|
135
|
-
def do name
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
87
|
+
def do name
|
88
|
+
if name.nil?
|
89
|
+
say "oops ! you need a name"
|
90
|
+
return
|
91
|
+
end
|
92
|
+
|
93
|
+
begin
|
94
|
+
CHECKED.clear
|
95
|
+
STACK.clear
|
96
|
+
instructable do
|
97
|
+
load_from "Instructions", HOME_CACHE << "/" if home?
|
98
|
+
load_from "Projects", PROJECT_CACHE << "/" if project?
|
99
|
+
handle_instruction name,STACK,options[:force]
|
100
|
+
end
|
101
|
+
rescue => e
|
102
|
+
puts e.message
|
144
103
|
end
|
104
|
+
|
145
105
|
end
|
146
106
|
|
147
107
|
map list: :instructions
|
@@ -173,13 +133,13 @@ module InstructionsList
|
|
173
133
|
end
|
174
134
|
|
175
135
|
def instructable?
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
end
|
136
|
+
|
137
|
+
if Dir.exists? "./.instructions"
|
138
|
+
if File.exists? "./.instructions/key"
|
139
|
+
return true
|
181
140
|
end
|
182
141
|
end
|
142
|
+
|
183
143
|
false
|
184
144
|
end
|
185
145
|
|
@@ -197,22 +157,24 @@ module InstructionsList
|
|
197
157
|
`pwd`.chomp == ENV['HOME']
|
198
158
|
end
|
199
159
|
|
160
|
+
def project?
|
161
|
+
File.exists?("./instructions") && !home?
|
162
|
+
end
|
163
|
+
|
200
164
|
|
201
|
-
def show_command_for
|
202
|
-
|
203
|
-
" il do #{path}"
|
165
|
+
def show_command_for name
|
166
|
+
" il do #{command_name(name)}"
|
204
167
|
end
|
205
168
|
|
206
169
|
def list_from location,path
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
end
|
170
|
+
|
171
|
+
puts "#{location}\n"
|
172
|
+
|
173
|
+
Dir["#{path}*.rb"].each {|file|
|
174
|
+
pn = Pathname.new(file)
|
175
|
+
yield File.basename(pn).gsub(".rb","")
|
176
|
+
}
|
177
|
+
|
216
178
|
end
|
217
179
|
|
218
180
|
def load_from name, path
|
@@ -225,12 +187,14 @@ module InstructionsList
|
|
225
187
|
end
|
226
188
|
|
227
189
|
def handle_instruction name,stack,force
|
228
|
-
instruction = InstructionsList::INSTRUCTIONS.find{ |i|
|
229
|
-
|
190
|
+
instruction = InstructionsList::INSTRUCTIONS.find { |i|
|
191
|
+
command_name(i.name.gsub(" ","_")) == command_name(name)
|
192
|
+
}
|
193
|
+
raise "Ooooops cant find #{command_name(name)}" if instruction.nil?
|
230
194
|
instruction.depends_on.each do |dependancy|
|
231
|
-
unless stack.include? dependancy
|
232
|
-
stack << dependancy
|
233
|
-
handle_instruction(dependancy,stack,force)
|
195
|
+
unless stack.include? command_name(dependancy.gsub(" ","_"))
|
196
|
+
stack << command_name(dependancy.gsub(" ","_"))
|
197
|
+
handle_instruction(command_name(dependancy.gsub(" ","_")),stack,force)
|
234
198
|
end
|
235
199
|
end
|
236
200
|
execute instruction,force: force
|
@@ -251,8 +215,6 @@ module InstructionsList
|
|
251
215
|
end
|
252
216
|
end
|
253
217
|
end
|
254
|
-
#desc "instructions", "instructions"
|
255
|
-
#subcommand "instructions", Instructions
|
256
218
|
end
|
257
219
|
end
|
258
220
|
|
data/lib/instructions_list.rb
CHANGED
@@ -7,14 +7,13 @@ module InstructionsList
|
|
7
7
|
INSTRUCTIONS=[]
|
8
8
|
STACK=[]
|
9
9
|
CHECKED=[]
|
10
|
-
|
11
|
-
HOME_CACHE = "/
|
10
|
+
INSTRUCTIONS_DIR=".instructions"
|
11
|
+
HOME_CACHE = "#{ENV['HOME']}/#{INSTRUCTIONS_DIR}/cache"
|
12
12
|
HOME_CACHE_ARTIFACTS="#{HOME_CACHE}/artifacts"
|
13
|
-
|
14
13
|
PROJECT_CACHE = "./.instructions/cache"
|
15
14
|
PROJECT_CACHE_ARTIFACTS="#{PROJECT_CACHE}/artifacts"
|
16
|
-
|
17
|
-
|
15
|
+
KEY_PATH="./#{INSTRUCTIONS_DIR}/key"
|
16
|
+
STATE="./.instructions/state"
|
18
17
|
HOST= ENV.fetch('INSTRUCTIONS_LIST_HOST',"instructionslist.com")
|
19
18
|
class It
|
20
19
|
def self.exists? path
|
@@ -79,13 +78,25 @@ module InstructionsList
|
|
79
78
|
def done(name)
|
80
79
|
`mkdir -p './.instructions/'`
|
81
80
|
`touch #{STATE}`
|
82
|
-
`echo #{name} >> #{STATE}`
|
83
|
-
check name
|
81
|
+
`echo #{command_name(name.to_s.gsub(" ","_"))} >> #{STATE}`
|
82
|
+
check command_name(name)
|
83
|
+
end
|
84
|
+
|
85
|
+
def command_name(name)
|
86
|
+
name.to_s.gsub("_", ":")
|
87
|
+
end
|
88
|
+
def reverse_command_name(name)
|
89
|
+
name.to_s.gsub(":", "_")
|
84
90
|
end
|
85
91
|
|
86
92
|
def check name
|
87
|
-
|
88
|
-
CHECKED
|
93
|
+
|
94
|
+
unless CHECKED.include? command_name(name)
|
95
|
+
system "echo #{command_name(name)} ✔︎"
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
CHECKED << command_name(name)
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
@@ -96,7 +107,7 @@ module InstructionsList
|
|
96
107
|
@cache = cache
|
97
108
|
end
|
98
109
|
def write content
|
99
|
-
File.open("#{@cache}/#{@file_name}", "w") do |file|
|
110
|
+
File.open("#{@cache}/#{reverse_command_name(@file_name)}", "w") do |file|
|
100
111
|
file.puts content
|
101
112
|
end
|
102
113
|
end
|
@@ -109,7 +120,7 @@ module InstructionsList
|
|
109
120
|
end
|
110
121
|
def write content,directory
|
111
122
|
`mkdir -p #{@cache}/#{directory}`
|
112
|
-
File.open("#{@cache}/#{directory}/#{@file_name}", "w") do |file|
|
123
|
+
File.open("#{@cache}/#{directory}/#{reverse_command_name(@file_name)}", "w") do |file|
|
113
124
|
file.puts content
|
114
125
|
end
|
115
126
|
end
|
@@ -124,8 +135,6 @@ module InstructionsList
|
|
124
135
|
end
|
125
136
|
def build
|
126
137
|
begin
|
127
|
-
puts "http://#{@host}/lists/#{@key}.json"
|
128
|
-
|
129
138
|
content = JSON.parse open("http://#{@host}/lists/#{@key}.json").read
|
130
139
|
`mkdir -p #{@cache}`
|
131
140
|
content["instructions"].each do |instruction|
|
data/lib/package_manager.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instructions_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coco Coder (aka Delaney Burke)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,7 +119,6 @@ extra_rdoc_files: []
|
|
119
119
|
files:
|
120
120
|
- ".byebug_history"
|
121
121
|
- ".gitignore"
|
122
|
-
- ".instructions/cache/install:redis.rb"
|
123
122
|
- ".instructions/key"
|
124
123
|
- ".ruby-version"
|
125
124
|
- CODE_OF_CONDUCT.md
|