marked-conductor 1.0.29 → 1.0.30

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
  SHA256:
3
- metadata.gz: 25fca33d78a755b6ab7b9dc4003d842723ca9b1a5eabb4357f665f91480e08cc
4
- data.tar.gz: b75c35f4db0f8d96a8a62e7636ff3f268918f85aa98fd133d30621c16dc58ce1
3
+ metadata.gz: 4960753920594bf8bc9a5abf999c6a40b9d0d2b88c2aadcb6b3c05db659af3bd
4
+ data.tar.gz: efb3cb83e50415a108d68e58468469b8b78132ad231825fff7f6fb3c2918d364
5
5
  SHA512:
6
- metadata.gz: 4bdd6b152729410fbd5f6752672169a41cdeab264f9b21ae8796eced90dcff3334817dd51038f8732ff6e9d5856776872b3d9cdcaf87898a74c405e8ce99a3a7
7
- data.tar.gz: f26b8b7c39db572313b95b83fce5ac49cbd950171034a1bc99a092c62cc0104b1d28eb78e3dbdfa4c44bd1f54f90a4c0d79e0ea9173020fcc4e7e1ab1131eb0f
6
+ metadata.gz: ff89946ef72b83902d598685e1c455384fba1e453674672d94c116a4598a29c19d65a2d0e51b1fc6f898d2c14799417f8bb3171b2a6d00d2d13e32b80e76cf3d
7
+ data.tar.gz: 8dd2b41b6750edd993e05c19c95b1fd98b9c4b969a6bedef6c8e56a43b98d06a6cce06eacf6cabd37887c3791562b9bdd1a440b9d138f72f48a2521dc55411a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.0.30
2
+
3
+ 2024-07-29 11:47
4
+
1
5
  ### 1.0.29
2
6
 
3
7
  2024-07-28 09:57
data/README.md CHANGED
@@ -107,6 +107,8 @@ Available conditions are:
107
107
  - `includes` are files included in the document with special syntax (Marked, IA Writer, etc.)
108
108
  - `includes contain file` or `includes not contains file` will test all included files for filename matches
109
109
  - `includes contain path` or `includes not contains path` will test all included files for fragment matches anywhere in the path
110
+ - `env:KEY matches VALUE` will test for matching values in a environment key. All string matching operators are available, and `env[KEY]` syntax will also work.
111
+ - `env contains KEY` tests just for the existence of an environment variable key (can include variables set by Marked).
110
112
  - The following keywords act as a catchall and can be used as the last track in the config to act on any documents that aren't matched by preceding rules:
111
113
  - `any`
112
114
  - `else`
data/bin/conductor CHANGED
@@ -4,9 +4,20 @@
4
4
  require_relative "../lib/conductor"
5
5
  require "optparse"
6
6
 
7
+ options = {
8
+ config_file: nil
9
+ }
10
+
7
11
  optparse = OptionParser.new do |opts|
8
12
  opts.banner = "Called from Marked 2 as a Custom Pre/Processor"
9
13
 
14
+ opts.on("-c", "--config", "Specify alternate config file") do |file|
15
+ config = File.expand_path(file)
16
+ raise "Config file not found" unless File.exist?(config)
17
+
18
+ options[:config_file] = file
19
+ end
20
+
10
21
  opts.on("-v", "--version", "Show version number") do
11
22
  puts "conductor v#{Conductor::VERSION}"
12
23
  Process.exit 0
@@ -21,6 +32,7 @@ end
21
32
  optparse.parse!
22
33
 
23
34
  config = Conductor::Config.new
35
+ config.config_file = options[:config_file] if options[:config_file]
24
36
  res = config.configure
25
37
 
26
38
  Process.exit 0 unless res
@@ -184,6 +184,11 @@ module Conductor
184
184
 
185
185
  val2 = val2.to_s.dup.force_encoding("utf-8")
186
186
 
187
+ if val2.bool?
188
+ res = val2.to_bool == val1.to_bool
189
+ return operator === :not_equal ? !res : res
190
+ end
191
+
187
192
  if val1.date?
188
193
  if val2.time?
189
194
  date1 = val1.to_date
@@ -276,6 +281,26 @@ module Conductor
276
281
  operator == :not_equal ? !res : res
277
282
  end
278
283
 
284
+ ##
285
+ ## Test for environment variable
286
+ ##
287
+ ## @param value [String] The value (test for existence of key if
288
+ ## nil)
289
+ ## @param key [String] The key
290
+ ## @param operator [Symbol] The operator
291
+ ##
292
+ ## @return [Boolean] test result
293
+ ##
294
+ def test_env(value, key, operator)
295
+ env = Env.env.merge(ENV)
296
+ if key.nil?
297
+ res = !env[value].nil?
298
+ return operator == :not_contains ? !res : res
299
+ end
300
+
301
+ return test_string(env[key], value, operator)
302
+ end
303
+
279
304
  ##
280
305
  ## Test for presence of yaml, optionall for
281
306
  ## a key, optionally for a key's value
@@ -391,6 +416,9 @@ module Conductor
391
416
  end
392
417
 
393
418
  case type
419
+ when /^env(?:ironment)?(?:[:\[\()](.*?)[\]\)]?)?$/i
420
+ key = Regexp.last_match(1) || nil
421
+ test_env(value, key, operator)
394
422
  when /^include/i
395
423
  test_includes(@env[:includes], value, operator) ? true : false
396
424
  when /^ext/i
@@ -41,8 +41,12 @@ module Conductor
41
41
  config_file ||= @config_file
42
42
  config_dir = File.dirname(config_file)
43
43
  scripts_dir = File.dirname(File.join(config_dir, "scripts"))
44
+ styles_dir = File.dirname(File.join(config_dir, "css"))
45
+ js_dir = File.dirname(File.join(config_dir, "js"))
44
46
  FileUtils.mkdir_p(config_dir) unless File.directory?(config_dir)
45
47
  FileUtils.mkdir_p(scripts_dir) unless File.directory?(scripts_dir)
48
+ FileUtils.mkdir_p(styles_dir) unless File.directory?(styles_dir)
49
+ FileUtils.mkdir_p(js_dir) unless File.directory?(js_dir)
46
50
  unless File.exist?(config_file)
47
51
  File.open(config_file, "w") { |f| f.puts sample_config }
48
52
  puts "Sample config created at #{config_file}"
data/lib/conductor/env.rb CHANGED
@@ -7,7 +7,7 @@ module Conductor
7
7
  ## Define @env using Marked environment variables
8
8
  ##
9
9
  def self.env
10
- if ENV["CONDUCTOR_TEST"] == "true"
10
+ if ENV["CONDUCTOR_TEST"].to_bool
11
11
  load_test_env
12
12
  else
13
13
  @env ||= {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conductor
4
- VERSION = '1.0.29'
4
+ VERSION = '1.0.30'
5
5
  end
data/src/_README.md CHANGED
@@ -107,6 +107,8 @@ Available conditions are:
107
107
  - `includes` are files included in the document with special syntax (Marked, IA Writer, etc.)
108
108
  - `includes contain file` or `includes not contains file` will test all included files for filename matches
109
109
  - `includes contain path` or `includes not contains path` will test all included files for fragment matches anywhere in the path
110
+ - `env:KEY matches VALUE` will test for matching values in a environment key. All string matching operators are available, and `env[KEY]` syntax will also work.
111
+ - `env contains KEY` tests just for the existence of an environment variable key (can include variables set by Marked).
110
112
  - The following keywords act as a catchall and can be used as the last track in the config to act on any documents that aren't matched by preceding rules:
111
113
  - `any`
112
114
  - `else`
data/test.sh CHANGED
@@ -23,6 +23,7 @@ fi
23
23
 
24
24
  PHASE="PREPROCESS"
25
25
  STD="BOTH"
26
+ CONFIG=""
26
27
 
27
28
  while getopts "h?p:o:d" opt; do
28
29
  case "$opt" in
@@ -32,6 +33,8 @@ while getopts "h?p:o:d" opt; do
32
33
  ;;
33
34
  p) PHASE=$OPTARG
34
35
  ;;
36
+ c) CMD="$CMD -c \"$OPTARG\""
37
+ ;;
35
38
  o) STD=$OPTARG
36
39
  ;;
37
40
  d)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marked-conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.29
4
+ version: 1.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-28 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print