instructions_list 0.1.13.beta → 1.0.0.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/.byebug_history +9 -0
- data/.instructions/key +1 -0
- data/bin/console +1 -1
- data/exe/il +60 -19
- data/instructions/.keep +0 -0
- data/instructions_list.gemspec +2 -1
- data/lib/instructions_list/version.rb +1 -1
- data/lib/instructions_list.rb +53 -10
- metadata +19 -4
- data/instructions/git.rb +0 -8
- data/instructions/test.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: 85893549c4b07a547a2d75e029d926bbc78f05b0
|
4
|
+
data.tar.gz: 420aeed99c53df1d2b417dd311c78e5a27c50a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731c4bb40d6a1e7403875de14a611b6d5e21093919037529d0905d57574e5ad198d81a3ed36f9c395757b33ad91f764771cd22ab3247ff9c98d82e8d574d922d
|
7
|
+
data.tar.gz: b5a4ad4028491cf9cbafa9a17603968eca25244315a309a4fe93a4a80043ff0829eb32e7d8f4739c3613db5c3a48b33c2694e705146d4f4754f2e1ecb0867121
|
data/.byebug_history
ADDED
data/.instructions/key
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ILSCZUWANID
|
data/bin/console
CHANGED
data/exe/il
CHANGED
@@ -24,25 +24,38 @@ module InstructionsList
|
|
24
24
|
def self.source_root
|
25
25
|
File.dirname(__FILE__)
|
26
26
|
end
|
27
|
-
desc "init", "initialize a il directory"
|
28
|
-
def init
|
27
|
+
desc "init KEY", "initialize a il directory with list key"
|
28
|
+
def init key
|
29
29
|
`mkdir -p ./.instructions/`
|
30
30
|
`mkdir -p instructions`
|
31
|
+
`touch ./.instructions/key`
|
32
|
+
`echo #{key} > ./.instructions/key`
|
33
|
+
connect key
|
31
34
|
end
|
32
35
|
desc "reset", "reset state"
|
33
|
-
def reset
|
36
|
+
def reset name=:all
|
34
37
|
instructable do
|
35
|
-
`rm ./.instructions/state`
|
38
|
+
`rm ./.instructions/state` if name == :all
|
39
|
+
`ex +g/#{name}/d -cwq ./.instructions/state`
|
36
40
|
end
|
37
41
|
end
|
38
42
|
desc "sync", "synchronize the instructions"
|
43
|
+
option :reset
|
39
44
|
def sync
|
45
|
+
|
46
|
+
`mkdir -p /tmp/il/cache`
|
47
|
+
|
48
|
+
if options[:reset]
|
49
|
+
`rm -rf #{CACHE}` if Dir.exists? CACHE
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
40
53
|
instructable do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
begin
|
55
|
+
CacheBuilder.new.build
|
56
|
+
rescue SocketError
|
57
|
+
|
58
|
+
end
|
46
59
|
end
|
47
60
|
end
|
48
61
|
|
@@ -53,7 +66,11 @@ module InstructionsList
|
|
53
66
|
say show_command_for path
|
54
67
|
end
|
55
68
|
puts ""
|
56
|
-
list_from "
|
69
|
+
list_from "Cloud", CACHE << "/" do |path|
|
70
|
+
say show_command_for path
|
71
|
+
end
|
72
|
+
puts ""
|
73
|
+
list_from "Home Directory","#{ENV['HOME']}/instructions/" do |path|
|
57
74
|
say show_command_for path
|
58
75
|
end
|
59
76
|
puts ""
|
@@ -63,23 +80,53 @@ module InstructionsList
|
|
63
80
|
end
|
64
81
|
puts ""
|
65
82
|
end
|
83
|
+
|
84
|
+
desc "info" , "display information"
|
85
|
+
def info
|
86
|
+
say "connected to\ key: #{get_key}"
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "connect KEY" , "connect to a list"
|
90
|
+
def connect key
|
91
|
+
instructable do
|
92
|
+
`echo #{key} > ./.instructions/key`
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "disconnect" , "disconnect from a list"
|
98
|
+
def disconnect
|
99
|
+
instructable do
|
100
|
+
`rm ./.instructions/key`
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
66
104
|
desc "do", "do an instruction"
|
67
105
|
option :force
|
68
106
|
def do name=:all
|
69
107
|
instructable do
|
70
108
|
load_from "Defaults","#{File.join(File.dirname(__FILE__), "../instructions/")}"
|
71
|
-
load_from "User","
|
109
|
+
load_from "User","#{ENV['HOME']}/instructions/"
|
72
110
|
load_from "Project","./instructions/"
|
111
|
+
load_from "Cloud", CACHE << "/"
|
73
112
|
handle_instruction name,force: options[:force]
|
74
113
|
end
|
75
114
|
end
|
76
115
|
|
116
|
+
map list: :instructions
|
117
|
+
|
77
118
|
no_tasks do
|
119
|
+
def get_key
|
120
|
+
return "Not connected!" unless File.exists? KEY_PATH
|
121
|
+
File.read(KEY_PATH)
|
122
|
+
end
|
78
123
|
def instructable
|
79
124
|
if Dir.exists? "./instructions"
|
80
125
|
if Dir.exists? "./.instructions"
|
81
|
-
|
82
|
-
|
126
|
+
if File.exists? "./.instructions/key"
|
127
|
+
yield
|
128
|
+
return
|
129
|
+
end
|
83
130
|
end
|
84
131
|
end
|
85
132
|
|
@@ -95,7 +142,6 @@ module InstructionsList
|
|
95
142
|
|
96
143
|
def list_from location,path
|
97
144
|
puts "#{location}"
|
98
|
-
|
99
145
|
if Dir["#{path}*.rb"].any?
|
100
146
|
Dir["#{path}*.rb"].each {|file|
|
101
147
|
pn = Pathname.new(file)
|
@@ -107,16 +153,11 @@ module InstructionsList
|
|
107
153
|
end
|
108
154
|
|
109
155
|
def load_from name, path
|
110
|
-
#puts "search in #{name}"
|
111
|
-
|
112
156
|
if Dir["#{path}*.rb"].any?
|
113
157
|
Dir["#{path}*.rb"].each {|file|
|
114
158
|
pn = Pathname.new(file)
|
115
159
|
require file
|
116
|
-
#puts " #{File.basename(pn)}".gsub(".rb","")
|
117
160
|
}
|
118
|
-
else
|
119
|
-
#puts " none"
|
120
161
|
end
|
121
162
|
end
|
122
163
|
|
data/instructions/.keep
ADDED
File without changes
|
data/instructions_list.gemspec
CHANGED
@@ -28,7 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "riot"
|
30
30
|
spec.add_development_dependency "rr"
|
31
|
+
spec.add_development_dependency "byebug"
|
31
32
|
spec.add_dependency "thor"
|
32
33
|
spec.add_dependency "pry"
|
33
|
-
|
34
|
+
|
34
35
|
end
|
data/lib/instructions_list.rb
CHANGED
@@ -1,18 +1,28 @@
|
|
1
|
-
|
1
|
+
require "open-uri"
|
2
|
+
require "json"
|
2
3
|
require_relative "instructions_list/version"
|
3
4
|
|
5
|
+
|
4
6
|
module InstructionsList
|
5
7
|
INSTRUCTIONS=[]
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
!`ps aux | grep #{name} | grep -v grep`.empty?
|
8
|
+
CACHE = "/tmp/il/cache"
|
9
|
+
KEY_PATH="./.instructions/key"
|
10
|
+
HOST= ENV.fetch('INSTRUCTIONS_LIST_HOST',"instructionslist.com")
|
11
|
+
class It
|
12
|
+
def self.exists? path
|
13
|
+
File.exists? path
|
13
14
|
end
|
14
|
-
|
15
|
-
|
15
|
+
class Is
|
16
|
+
def self.done? name
|
17
|
+
return false unless File.exists? "./.instructions/state"
|
18
|
+
File.readlines("./.instructions/state").include? "#{name}\n"
|
19
|
+
end
|
20
|
+
def self.running? name
|
21
|
+
!`ps aux | grep #{name} | grep -v grep`.empty?
|
22
|
+
end
|
23
|
+
def self.installed? path
|
24
|
+
!`[ -d "#{path}"]`.empty?
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
|
@@ -69,6 +79,39 @@ module InstructionsList
|
|
69
79
|
system "echo #{name} ✔︎"
|
70
80
|
end
|
71
81
|
end
|
82
|
+
|
83
|
+
|
84
|
+
class CacheItem
|
85
|
+
def initialize(file_name)
|
86
|
+
@file_name = file_name
|
87
|
+
end
|
88
|
+
def write content
|
89
|
+
File.open("#{CACHE}/#{@file_name}","w") do |file|
|
90
|
+
file.puts content
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class CacheBuilder
|
96
|
+
def initialize(key="ILSCZUWANID",host=HOST)
|
97
|
+
@key = key
|
98
|
+
@host = host
|
99
|
+
end
|
100
|
+
def build
|
101
|
+
begin
|
102
|
+
content = JSON.parse open("http://#{@host}/lists/#{@key}.json").read
|
103
|
+
`mkdir -p #{CACHE}`
|
104
|
+
content["instructions"].each do |instruction|
|
105
|
+
CacheItem
|
106
|
+
.new(instruction["file_name"])
|
107
|
+
.write(instruction["file_contents"])
|
108
|
+
end
|
109
|
+
rescue SocketError,JSON::ParserError
|
110
|
+
puts "cant find #{@host}"
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
72
115
|
end
|
73
116
|
|
74
117
|
Object.send :include, InstructionsList
|
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: 0.
|
4
|
+
version: 1.0.0.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-10-
|
11
|
+
date: 2017-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: thor
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +117,9 @@ executables:
|
|
103
117
|
extensions: []
|
104
118
|
extra_rdoc_files: []
|
105
119
|
files:
|
120
|
+
- ".byebug_history"
|
106
121
|
- ".gitignore"
|
122
|
+
- ".instructions/key"
|
107
123
|
- CODE_OF_CONDUCT.md
|
108
124
|
- Gemfile
|
109
125
|
- LICENSE.txt
|
@@ -112,8 +128,7 @@ files:
|
|
112
128
|
- bin/console
|
113
129
|
- bin/setup
|
114
130
|
- exe/il
|
115
|
-
- instructions
|
116
|
-
- instructions/test.rb
|
131
|
+
- instructions/.keep
|
117
132
|
- instructions_list.gemspec
|
118
133
|
- lib/instructions_list.rb
|
119
134
|
- lib/instructions_list/version.rb
|
data/instructions/git.rb
DELETED