marked-conductor 1.0.6 → 1.0.8
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/.irbrc +8 -2
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +34 -0
- data/Gemfile.lock +47 -3
- data/README.md +33 -1
- data/README.rdoc +6 -0
- data/Rakefile +38 -1
- data/bin/conductor +44 -15
- data/lib/conductor/array.rb +0 -1
- data/lib/conductor/command.rb +14 -15
- data/lib/conductor/condition.rb +171 -36
- data/lib/conductor/config.rb +4 -4
- data/lib/conductor/env.rb +35 -33
- data/lib/conductor/hash.rb +1 -1
- data/lib/conductor/script.rb +21 -21
- data/lib/conductor/string.rb +18 -10
- data/lib/conductor/version.rb +1 -1
- data/lib/conductor.rb +21 -19
- data/marked-conductor.gemspec +18 -10
- data/src/_README.md +33 -1
- metadata +121 -2
data/lib/conductor/condition.rb
CHANGED
@@ -11,6 +11,13 @@ module Conductor
|
|
11
11
|
parse_condition
|
12
12
|
end
|
13
13
|
|
14
|
+
##
|
15
|
+
## @brief Splits booleans and tests components.
|
16
|
+
##
|
17
|
+
## @param condition The condition to test
|
18
|
+
##
|
19
|
+
## @return [Boolean] test result
|
20
|
+
##
|
14
21
|
def split_booleans(condition)
|
15
22
|
split = condition.split(/ ((?:AND )?NOT|AND|OR) /)
|
16
23
|
|
@@ -21,7 +28,7 @@ module Conductor
|
|
21
28
|
bool = nil
|
22
29
|
prev = false
|
23
30
|
split.each do |cond|
|
24
|
-
if
|
31
|
+
if /((?:AND )?NOT|AND|OR|&&|\|\||!!)/.match?(cond)
|
25
32
|
bool = cond.bool_to_symbol
|
26
33
|
next
|
27
34
|
end
|
@@ -44,6 +51,15 @@ module Conductor
|
|
44
51
|
end
|
45
52
|
end
|
46
53
|
|
54
|
+
##
|
55
|
+
## @brief Test operators
|
56
|
+
##
|
57
|
+
## @param value1 Value
|
58
|
+
## @param value2 Value to test
|
59
|
+
## @param operator The operator
|
60
|
+
##
|
61
|
+
## @return [Boolean] test result
|
62
|
+
##
|
47
63
|
def test_operator(value1, value2, operator)
|
48
64
|
case operator
|
49
65
|
when :gt
|
@@ -63,13 +79,38 @@ module Conductor
|
|
63
79
|
end
|
64
80
|
end
|
65
81
|
|
82
|
+
##
|
83
|
+
## @brief Splits a natural language condition.
|
84
|
+
##
|
85
|
+
## @param condition The condition
|
86
|
+
## @return [Array] Value, value to compare, operator
|
87
|
+
##
|
66
88
|
def split_condition(condition)
|
89
|
+
if condition.match(/(?:((?:does )?not)?(?:ha(?:s|ve)|contains?|includes?) +)?(yaml|headers|frontmatter|mmd|meta(?:data)?)(:\S+)?/i)
|
90
|
+
m = Regexp.last_match
|
91
|
+
op = m[1].nil? ? :contains : :not_contains
|
92
|
+
type = m[2] =~ /^m/i ? "mmd" : "yaml"
|
93
|
+
return ["#{type}#{m[3]}", nil, op]
|
94
|
+
end
|
67
95
|
res = condition.match(/^(?<val1>.*?)(?:(?: +(?<op>(?:is|does)(?: not)?(?: an?|type(?: of)?|equals?(?: to))?|!?==?|[gl]t|(?:greater|less)(?: than)?|<|>|(?:starts|ends) with|(?:ha(?:s|ve) )?(?:prefix|suffix)|has|contains?|includes?) +)(?<val2>.*?))?$/i)
|
68
|
-
[res[
|
96
|
+
[res["val1"], res["val2"], operator_to_symbol(res["op"])]
|
69
97
|
end
|
70
98
|
|
99
|
+
##
|
100
|
+
## @brief Test for type of value
|
101
|
+
##
|
102
|
+
## @param val1 value
|
103
|
+
## @param val2 value to test against
|
104
|
+
## @param operator The operator
|
105
|
+
##
|
71
106
|
def test_type(val1, val2, operator)
|
72
107
|
res = case val2
|
108
|
+
when /number/
|
109
|
+
val1.is_a?(Numeric)
|
110
|
+
when /int(eger)?/
|
111
|
+
val1.is_a?(Integer)
|
112
|
+
when /(float|decimal)/
|
113
|
+
val1.is_a?(Float)
|
73
114
|
when /array/i
|
74
115
|
val1.is_a?(Array)
|
75
116
|
when /(string|text)/i
|
@@ -80,12 +121,21 @@ module Conductor
|
|
80
121
|
operator == :type_of ? res : !res
|
81
122
|
end
|
82
123
|
|
124
|
+
##
|
125
|
+
## @brief Compare a string based on operator
|
126
|
+
##
|
127
|
+
## @param val1 The string to test against
|
128
|
+
## @param val2 The value to test
|
129
|
+
## @param operator The operator
|
130
|
+
##
|
131
|
+
## @return [Boolean] test result
|
132
|
+
##
|
83
133
|
def test_string(val1, val2, operator)
|
84
134
|
return operator == :not_equal ? val1.nil? : !val1.nil? if val2.nil?
|
85
135
|
|
86
136
|
return operator == :not_equal if val1.nil?
|
87
137
|
|
88
|
-
val2 = val2.force_encoding(
|
138
|
+
val2 = val2.force_encoding("utf-8")
|
89
139
|
|
90
140
|
if val1.date?
|
91
141
|
if val2.time?
|
@@ -109,12 +159,12 @@ module Conductor
|
|
109
159
|
return res unless res.nil?
|
110
160
|
end
|
111
161
|
|
112
|
-
val2 = if
|
113
|
-
val2.gsub(%r{(^/|/$)},
|
162
|
+
val2 = if %r{^/.*?/$}.match?(val2.strip)
|
163
|
+
val2.gsub(%r{(^/|/$)}, "")
|
114
164
|
else
|
115
165
|
Regexp.escape(val2)
|
116
166
|
end
|
117
|
-
val1 = val1.dup.to_s.force_encoding(
|
167
|
+
val1 = val1.dup.to_s.force_encoding("utf-8")
|
118
168
|
case operator
|
119
169
|
when :contains
|
120
170
|
val1 =~ /#{val2}/i
|
@@ -135,6 +185,17 @@ module Conductor
|
|
135
185
|
end
|
136
186
|
end
|
137
187
|
|
188
|
+
##
|
189
|
+
## @brief Test for the existince of a
|
190
|
+
## file/directory in the parent tree
|
191
|
+
##
|
192
|
+
## @param origin Starting directory
|
193
|
+
## @param value The file/directory to search
|
194
|
+
## for
|
195
|
+
## @param operator The operator
|
196
|
+
##
|
197
|
+
## @return [Boolean] test result
|
198
|
+
##
|
138
199
|
def test_tree(origin, value, operator)
|
139
200
|
return true if File.exist?(File.join(origin, value))
|
140
201
|
|
@@ -142,13 +203,22 @@ module Conductor
|
|
142
203
|
|
143
204
|
if Dir.exist?(File.join(dir, value))
|
144
205
|
true
|
145
|
-
elsif [Dir.home,
|
206
|
+
elsif [Dir.home, "/"].include?(dir)
|
146
207
|
false
|
147
208
|
else
|
148
209
|
test_tree(dir, value, operator)
|
149
210
|
end
|
150
211
|
end
|
151
212
|
|
213
|
+
##
|
214
|
+
## @brief Test "truthiness"
|
215
|
+
##
|
216
|
+
## @param value1 Value to test against
|
217
|
+
## @param value2 Value to test
|
218
|
+
## @param operator The operator
|
219
|
+
##
|
220
|
+
## @return [Boolean] test result
|
221
|
+
##
|
152
222
|
def test_truthy(value1, value2, operator)
|
153
223
|
return false unless value2&.bool?
|
154
224
|
|
@@ -159,6 +229,89 @@ module Conductor
|
|
159
229
|
operator == :not_equal ? !res : res
|
160
230
|
end
|
161
231
|
|
232
|
+
##
|
233
|
+
## @brief Test for presence of yaml, optionall for
|
234
|
+
## a key, optionally for a key's value
|
235
|
+
##
|
236
|
+
## @param content Text content containing YAML
|
237
|
+
## @param value The value to test for
|
238
|
+
## @param key The key to test for
|
239
|
+
## @param operator The operator
|
240
|
+
##
|
241
|
+
## @return [Boolean] test result
|
242
|
+
##
|
243
|
+
def test_yaml(content, value, key, operator)
|
244
|
+
yaml = YAML.safe_load(content.split(/^(?:---|\.\.\.)/)[1])
|
245
|
+
|
246
|
+
return operator == :not_equal unless yaml
|
247
|
+
|
248
|
+
if key
|
249
|
+
value1 = yaml[key]
|
250
|
+
return operator == :not_equal if value1.nil?
|
251
|
+
|
252
|
+
if value.nil?
|
253
|
+
has_key = !value1.nil?
|
254
|
+
return operator == :not_equal ? !has_key : has_key
|
255
|
+
end
|
256
|
+
|
257
|
+
if %i[type_of not_type_of].include?(operator)
|
258
|
+
return test_type(value1, value, operator)
|
259
|
+
end
|
260
|
+
|
261
|
+
value1 = value1.join(",") if value1.is_a?(Array)
|
262
|
+
|
263
|
+
if value1.bool?
|
264
|
+
test_truthy(value1, value, operator)
|
265
|
+
elsif value1.number? && value.number? && %i[gt lt equal not_equal].include?(operator)
|
266
|
+
test_operator(value1, value, operator)
|
267
|
+
else
|
268
|
+
test_string(value1, value, operator)
|
269
|
+
end
|
270
|
+
else
|
271
|
+
res = value ? yaml.key?(value) : true
|
272
|
+
(operator == :not_equal) ? !res : res
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
## @brief Test for MultiMarkdown metadata,
|
278
|
+
## optionally key and value
|
279
|
+
##
|
280
|
+
## @param content [String] The text content
|
281
|
+
## @param value [String] The value to test for
|
282
|
+
## @param key [String] The key to test for
|
283
|
+
## @param operator [Symbol] The operator
|
284
|
+
##
|
285
|
+
## @return [Boolean] test result
|
286
|
+
##
|
287
|
+
def test_meta(content, value, key, operator)
|
288
|
+
headers = []
|
289
|
+
content.split("\n").each do |line|
|
290
|
+
break if line == /^ *\n$/ || line !~ /\w+: *\S/
|
291
|
+
|
292
|
+
headers << line
|
293
|
+
end
|
294
|
+
|
295
|
+
return operator == :not_equal if headers.empty?
|
296
|
+
|
297
|
+
return operator != :not_equal if value.nil?
|
298
|
+
|
299
|
+
meta = {}
|
300
|
+
headers.each do |h|
|
301
|
+
parts = h.split(/ *: */)
|
302
|
+
k = parts[0].strip.downcase.gsub(/ +/, "")
|
303
|
+
v = parts[1..].join(":").strip
|
304
|
+
meta[k] = v
|
305
|
+
end
|
306
|
+
|
307
|
+
if key
|
308
|
+
test_string(meta[key], value, operator)
|
309
|
+
else
|
310
|
+
res = value ? meta.key?(value) : true
|
311
|
+
operator == :not_equal ? !res : res
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
162
315
|
def test_condition(condition)
|
163
316
|
type, value, operator = split_condition(condition)
|
164
317
|
|
@@ -178,38 +331,18 @@ module Conductor
|
|
178
331
|
test_tree(@env[:origin], value, operator)
|
179
332
|
when /^(path|dir)/i
|
180
333
|
test_string(@env[:filepath], value, operator) ? true : false
|
334
|
+
when /^(file)?name/i
|
335
|
+
test_string(@env[:filename], value, operator) ? true : false
|
181
336
|
when /^phase/i
|
182
337
|
test_string(@env[:phase], value, :starts_with) ? true : false
|
183
338
|
when /^text/i
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
yaml = YAML.safe_load(content.split(/^(?:---|\.\.\.)/)[1])
|
192
|
-
|
193
|
-
return false unless yaml
|
194
|
-
|
195
|
-
if m[2]
|
196
|
-
value1 = yaml[m[2]]
|
197
|
-
return false if value1.nil?
|
198
|
-
|
199
|
-
value1 = value1.join(',') if value1.is_a?(Array)
|
200
|
-
if %i[type_of not_type_of].include?(operator)
|
201
|
-
test_type(value1, value, operator)
|
202
|
-
elsif value1.bool?
|
203
|
-
test_truthy(value1, value, operator)
|
204
|
-
elsif value1.number? && value2.number? && %i[gt lt equal not_equal].include?(operator)
|
205
|
-
test_operator(value1, value, operator)
|
206
|
-
else
|
207
|
-
test_string(value1, value, operator)
|
208
|
-
end
|
209
|
-
else
|
210
|
-
res = value? ? yaml.key?(value) : true
|
211
|
-
operator == :not_equal ? !res : res
|
212
|
-
end
|
339
|
+
test_string(Conductor.stdin, value, operator) ? true : false
|
340
|
+
when /^(?:yaml|headers|frontmatter)(?::(.*?))?$/i
|
341
|
+
key = Regexp.last_match(1) || nil
|
342
|
+
Conductor.stdin.yaml? ? test_yaml(Conductor.stdin, value, key, operator) : false
|
343
|
+
when /^(?:mmd|meta(?:data)?)(?::(.*?))?$/i
|
344
|
+
key = Regexp.last_match(1) || nil
|
345
|
+
Conductor.stdin.meta? ? test_meta(Conductor.stdin, value, key, operator) : false
|
213
346
|
else
|
214
347
|
false
|
215
348
|
end
|
@@ -223,6 +356,8 @@ module Conductor
|
|
223
356
|
:gt
|
224
357
|
when /(lt|less( than)?|<|(?:is )?before)/i
|
225
358
|
:lt
|
359
|
+
when /not (ha(?:s|ve)|contains|includes|match(es)?|\*=)/i
|
360
|
+
:not_contains
|
226
361
|
when /(ha(?:s|ve)|contains|includes|match(es)?|\*=)/i
|
227
362
|
:contains
|
228
363
|
when /not (suffix|ends? with)/i
|
data/lib/conductor/config.rb
CHANGED
@@ -6,22 +6,22 @@ module Conductor
|
|
6
6
|
attr_reader :config, :tracks
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
config_file = File.expand_path(
|
9
|
+
config_file = File.expand_path("~/.config/conductor/tracks.yaml")
|
10
10
|
|
11
11
|
create_config(config_file) unless File.exist?(config_file)
|
12
12
|
|
13
13
|
@config ||= YAML.safe_load(IO.read(config_file))
|
14
14
|
|
15
|
-
@tracks = @config[
|
15
|
+
@tracks = @config["tracks"].symbolize_keys
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_config(config_file)
|
20
20
|
config_dir = File.dirname(config_file)
|
21
|
-
scripts_dir = File.dirname(File.join(config_dir,
|
21
|
+
scripts_dir = File.dirname(File.join(config_dir, "scripts"))
|
22
22
|
FileUtils.mkdir_p(config_dir) unless File.directory?(config_dir)
|
23
23
|
FileUtils.mkdir_p(scripts_dir) unless File.directory?(scripts_dir)
|
24
|
-
File.open(config_file,
|
24
|
+
File.open(config_file, "w") { |f| f.puts sample_config }
|
25
25
|
puts "Sample config created at #{config_file}"
|
26
26
|
|
27
27
|
Process.exit 0
|
data/lib/conductor/env.rb
CHANGED
@@ -3,52 +3,54 @@
|
|
3
3
|
module Conductor
|
4
4
|
module Env
|
5
5
|
def self.env
|
6
|
-
@env ||= if ENV[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
@env ||= if ENV["CONDUCTOR_TEST"] == "true"
|
7
|
+
load_test_env
|
8
|
+
else
|
9
|
+
@env ||= {
|
10
|
+
home: ENV["HOME"],
|
11
|
+
css_path: ENV["MARKED_CSS_PATH"],
|
12
|
+
ext: ENV["MARKED_EXT"],
|
13
|
+
includes: ENV["MARKED_INCLUDES"],
|
14
|
+
origin: ENV["MARKED_ORIGIN"],
|
15
|
+
filepath: ENV["MARKED_PATH"],
|
16
|
+
filename: File.basename(filepath),
|
17
|
+
phase: ENV["MARKED_PHASE"],
|
18
|
+
outline: ENV["OUTLINE"],
|
19
|
+
path: ENV["PATH"]
|
20
|
+
}
|
21
|
+
end
|
21
22
|
|
22
23
|
@env
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.load_test_env
|
26
27
|
@env = {
|
27
|
-
home:
|
28
|
-
css_path:
|
29
|
-
ext:
|
28
|
+
home: "/Users/ttscoff",
|
29
|
+
css_path: "/Applications/Marked 2.app/Contents/Resources/swiss.css",
|
30
|
+
ext: "md",
|
30
31
|
includes: [],
|
31
|
-
origin:
|
32
|
-
filepath:
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
origin: "/Users/ttscoff/Desktop/Code/marked-conductor/",
|
33
|
+
filepath: "/Users/ttscoff/Desktop/Code/marked-conductor/README.md",
|
34
|
+
filename: "README.md",
|
35
|
+
phase: "PREPROCESS",
|
36
|
+
outline: "NONE",
|
37
|
+
path: "/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/ttscoff/Dropbox/Writing/brettterpstra.com/_drafts/"
|
36
38
|
}
|
37
39
|
end
|
38
40
|
|
39
41
|
def self.to_s
|
40
42
|
out_h = {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
"HOME" => @env[:home],
|
44
|
+
"MARKED_CSS_PATH" => @env[:css_path],
|
45
|
+
"MARKED_EXT" => @env[:ext],
|
46
|
+
"MARKED_ORIGIN" => @env[:origin],
|
47
|
+
"MARKED_INCLUDES" => @env[:includes],
|
48
|
+
"MARKED_PATH" => @env[:filepath],
|
49
|
+
"MARKED_PHASE" => @env[:phase],
|
50
|
+
"OUTLINE" => @env[:outline],
|
51
|
+
"PATH" => @env[:path]
|
50
52
|
}
|
51
|
-
out_h.map { |k, v| %(#{k}="#{v}") }.join(
|
53
|
+
out_h.map { |k, v| %(#{k}="#{v}") }.join(" ")
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/lib/conductor/hash.rb
CHANGED
data/lib/conductor/script.rb
CHANGED
@@ -8,44 +8,44 @@ module Conductor
|
|
8
8
|
def initialize(script)
|
9
9
|
parts = Shellwords.split(script)
|
10
10
|
self.path = parts[0]
|
11
|
-
self.args = parts[1..].join(
|
11
|
+
self.args = parts[1..].join(" ")
|
12
12
|
end
|
13
13
|
|
14
14
|
def path=(path)
|
15
|
-
@path = if
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
@path = if %r{^[%/]}.match?(path)
|
16
|
+
File.expand_path(path)
|
17
|
+
else
|
18
|
+
script_dir = File.expand_path("~/.config/conductor/scripts")
|
19
|
+
if File.exist?(File.join(script_dir, path))
|
20
|
+
File.join(script_dir, path)
|
21
|
+
elsif TTY::Which.exist?(path)
|
22
|
+
TTY::Which.which(path)
|
23
|
+
else
|
24
|
+
raise "Path to #{path} not found"
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def args=(array)
|
31
31
|
@args = if array.is_a?(Array)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
array.join(" ")
|
33
|
+
else
|
34
|
+
array
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def run
|
39
39
|
stdin = Conductor.stdin
|
40
40
|
|
41
|
-
raise
|
41
|
+
raise "Script path not defined" unless @path
|
42
42
|
|
43
43
|
use_stdin = true
|
44
|
-
if
|
44
|
+
if /\$\{?file\}?/.match?(args)
|
45
45
|
use_stdin = false
|
46
46
|
args.sub!(/\$\{?file\}?/, Env.env[:filepath])
|
47
47
|
else
|
48
|
-
raise
|
48
|
+
raise "No input" unless stdin
|
49
49
|
|
50
50
|
end
|
51
51
|
|
data/lib/conductor/string.rb
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
class ::String
|
5
5
|
def bool_to_symbol
|
6
6
|
case self
|
7
|
-
when /NOT/
|
7
|
+
when /(NOT|!!)/
|
8
8
|
:not
|
9
|
-
when /AND/
|
9
|
+
when /(AND|&&)/
|
10
10
|
:and
|
11
11
|
else
|
12
12
|
:or
|
@@ -14,32 +14,40 @@ class ::String
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def date?
|
17
|
-
dup.force_encoding(
|
17
|
+
dup.force_encoding("utf-8").match?(/^\d{4}-\d{2}-\d{2}/)
|
18
18
|
end
|
19
19
|
|
20
20
|
def time?
|
21
|
-
dup.force_encoding(
|
21
|
+
dup.force_encoding("utf-8").match(/ \d{1,2}(:\d\d)? *([ap]m)?/i)
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_date
|
25
|
-
Chronic.parse(
|
25
|
+
Chronic.parse(dup.force_encoding("utf-8"))
|
26
26
|
end
|
27
27
|
|
28
28
|
def strip_time
|
29
|
-
dup.force_encoding(
|
29
|
+
dup.force_encoding("utf-8").sub(/ \d{1,2}(:\d\d)? *([ap]m)?/i, "")
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_day(time = :end)
|
33
|
-
t = time == :end ?
|
34
|
-
Chronic.parse("#{
|
33
|
+
t = time == :end ? "23:59" : "00:00"
|
34
|
+
Chronic.parse("#{strip_time} #{t}")
|
35
35
|
end
|
36
36
|
|
37
37
|
def number?
|
38
|
-
to_f
|
38
|
+
to_f.positive?
|
39
39
|
end
|
40
40
|
|
41
41
|
def bool?
|
42
|
-
dup.force_encoding(
|
42
|
+
dup.force_encoding("utf-8").match?(/^(?:y(?:es)?|no?|t(?:rue)?|f(?:alse)?)$/)
|
43
|
+
end
|
44
|
+
|
45
|
+
def meta?
|
46
|
+
self =~ /^---/m
|
47
|
+
end
|
48
|
+
|
49
|
+
def yaml?
|
50
|
+
self =~ /^\w+: +\S+/m
|
43
51
|
end
|
44
52
|
|
45
53
|
def to_bool!
|
data/lib/conductor/version.rb
CHANGED
data/lib/conductor.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative
|
15
|
-
require_relative
|
16
|
-
require_relative
|
17
|
-
require_relative
|
18
|
-
require_relative
|
19
|
-
require_relative
|
3
|
+
require "tty-which"
|
4
|
+
require "yaml"
|
5
|
+
require "shellwords"
|
6
|
+
require "fcntl"
|
7
|
+
require "time"
|
8
|
+
require "chronic"
|
9
|
+
require "fileutils"
|
10
|
+
require_relative "conductor/version"
|
11
|
+
require_relative "conductor/env"
|
12
|
+
require_relative "conductor/config"
|
13
|
+
require_relative "conductor/hash"
|
14
|
+
require_relative "conductor/array"
|
15
|
+
require_relative "conductor/boolean"
|
16
|
+
require_relative "conductor/string"
|
17
|
+
require_relative "conductor/script"
|
18
|
+
require_relative "conductor/command"
|
19
|
+
require_relative "conductor/condition"
|
20
20
|
|
21
21
|
module Conductor
|
22
22
|
class << self
|
23
|
+
attr_writer :stdin
|
24
|
+
|
23
25
|
def stdin
|
24
|
-
warn
|
25
|
-
@stdin ||= $stdin.read.strip.force_encoding(
|
26
|
+
warn "input on STDIN required" unless $stdin.stat.size.positive? || $stdin.fcntl(Fcntl::F_GETFL, 0).zero?
|
27
|
+
@stdin ||= $stdin.read.strip.force_encoding("utf-8")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
data/marked-conductor.gemspec
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
require_relative "lib/conductor/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "marked-conductor"
|
7
|
+
spec.version = Conductor::VERSION
|
8
|
+
spec.authors = ["Brett Terpstra"]
|
9
|
+
spec.email = ["me@brettterpstra.com"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
11
|
+
spec.summary = "A custom processor manager for Marked 2 (Mac)"
|
12
|
+
spec.description = "Conductor allows easy configuration of multiple scripts that are run as custom pre/processors for Marked based on conditional statements."
|
13
|
+
spec.homepage = "https://github.com/ttscoff/marked-conductor"
|
14
|
+
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -25,12 +25,20 @@ Gem::Specification.new do |spec|
|
|
25
25
|
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
26
|
end
|
27
27
|
end
|
28
|
-
spec.bindir
|
29
|
-
spec.executables
|
28
|
+
spec.bindir = "bin"
|
29
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
spec.add_development_dependency "pry", "~> 0.14.2"
|
33
33
|
spec.add_development_dependency "awesome_print", "~> 1.9.2"
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
+
spec.add_development_dependency "gem-release", "~> 2.2"
|
36
|
+
spec.add_development_dependency "parse_gemspec-cli", "~> 1.0"
|
37
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
38
|
+
spec.add_development_dependency "yard", "~> 0.9", ">= 0.9.26"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
spec.add_development_dependency "simplecov", "~> 0.21"
|
41
|
+
spec.add_development_dependency "simplecov-console", "~> 0.9"
|
34
42
|
|
35
43
|
# Uncomment to register a new dependency of your gem
|
36
44
|
spec.add_dependency "tty-which", "~> 0.5.0"
|