marked-conductor 1.0.1 → 1.0.3

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: 57fd34f9a06a34ea2a2f4d226143a850d0e1f38dca0528a8df454a3477c2c08a
4
- data.tar.gz: d7b1ce254b548ccf2d8da5839ff855409d9313c99764e37371cf8642c761e7d3
3
+ metadata.gz: b8baea5f97cf53a0a8ff79a8ccb0f6fc06ce84192f708291f2e07ebd85e3c393
4
+ data.tar.gz: 43c20bc158834e03ca7a8d2e5e52bde33ff27b7397183b2eece3adeb77162991
5
5
  SHA512:
6
- metadata.gz: 549e27e12fe646d0367a72181a0217b5176b5b78286f4657d9ae76e4715b52a43f59e800961f48054f8d9dcf307c65d7f4c188011f507883fce41c7ae5544339
7
- data.tar.gz: 0c5af7759efef1f1748b5e8b56b6b70b11d416019f01dcd201571346ed4b9207046e1e1d26ba0bd6d2542bdcf0ffbf838d1abe6cf2ce00384414d6dfa7f59448
6
+ metadata.gz: 4672bd627a2d34dfc578ff80f9a3360d8a5319428c8b4746442a77adae4e7555f68c91797a0be91b4ddc2e384fb8dd84164682643d64342b580db4dd79921b76
7
+ data.tar.gz: 1ba57715e5ad4d0844f654a3792551d9d7bd333385a4018b0a0a00f1a90e67f3105798a89be2fb2be0f453ee5c88f170e5e6d183196213e4f258de7b8d59007e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ### 1.0.3
2
+
3
+ 2024-04-25 14:32
4
+
5
+ #### FIXED
6
+
7
+ - YAML true/false testing
8
+
9
+ ### 1.0.2
10
+
11
+ 2024-04-25 14:15
12
+
13
+ #### CHANGED
14
+
15
+ - Prepped for gem release
16
+
17
+ #### FIXED
18
+
19
+ - Encoding issue affecting Shellwords.escape
20
+
1
21
  ### 1.0.0
2
22
 
3
23
  2024-04-25 10:51
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ [![RubyGems.org](https://img.shields.io/gem/v/marked-conductor)](https://rubygems.org/gems/marked-conductor)
2
3
 
3
4
  # Marked Conductor
4
5
 
@@ -72,7 +73,7 @@ Available conditions are:
72
73
  - `path`: This tests just the path itself, allowing conditions like `path contains _drafts` or `path does not contain _posts`.
73
74
  - `phase`: Tests whether Marked is in Preprocessor or Processor phase, allowing conditions like `phase is preprocess` or `phase is process` (which can be shortened to `pre` and `pro`).
74
75
  - `text`: This tests for any string match within the text of the document being processed. This can be used with operators `starts with`, `ends with`, or `contains`, e.g. `text contains @taskpaper` or `text does not contain <!--more-->`.
75
- - If the test value is surrounded by forward slashes, it will be treated as a regular expression. Regexes are always flagged as case insensitive. Use it like `text matches @\w+`.
76
+ - If the test value is surrounded by forward slashes, it will be treated as a regular expression. Regexes are always flagged as case insensitive. Use it like `text contains /@\w+/`.
76
77
  - `yaml`, `headers`, or `frontmatter` will test for YAML headers. If a `yaml:KEY` is defined, a specific YAML key will be tested for. If a value is defined with an operator, it will be tested against the value key.
77
78
  - `yaml` tests for the presence of YAML frontmatter.
78
79
  - `yaml:comments` tests for the presence of a `comments` key.
@@ -107,6 +108,12 @@ Commands are interpreted as shell commands. If a command exists in the `$PATH`,
107
108
 
108
109
  Using `$file` as an argument to a script or command will bypass processing of STDIN input, and instead use the value of $MARKED_PATH to read the contents of the specified file.
109
110
 
111
+ ## Custom Processors
112
+
113
+ All of the [capabilities and requirements](https://marked2app.com/help/Custom_Processor) of a Custom Processor script or command still apply, and all of the [environment variables that Marked sets](https://marked2app.com/help/Custom_Processor#environmentvariables) are still available. You just no longer have to have one huge script that forks on the various environment variables and you don't have to write your own tests for handling different scenarios.
114
+
115
+ A script run by Conductor already knows it has the right type of file with the expected data and path, so your script can focus on just processing one file type. It's recommended to separate all of that logic you may already have written out into separate scripts and let Conductor handle the forking based on various criteria.
116
+
110
117
  ## Testing
111
118
 
112
119
  In order to test from the command line, you'll need certain environment variables set. This can be done by exporting the following variables with your own definitions, or by running conductor with all of the variables preceding the command, e.g. `$ MARKED_ORIGIN=/path/to/markdown_file.md [...] conductor`.
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # True class
4
+ class ::TrueClass
5
+ def bool?
6
+ true
7
+ end
8
+ end
9
+
10
+ # False class
11
+ class ::FalseClass
12
+ def bool?
13
+ true
14
+ end
15
+ end
@@ -150,7 +150,7 @@ module Conductor
150
150
  def test_truthy(value1, value2, operator)
151
151
  return false unless value2.bool?
152
152
 
153
- value2.to_bool!
153
+ value2 = value2.to_bool if value2.is_a?(String)
154
154
 
155
155
  res = value1 == value2
156
156
 
@@ -182,16 +182,18 @@ module Conductor
182
182
  test_string(IO.read(@env[:filepath]), value, operator) ? true : false
183
183
  when /^(yaml|headers|frontmatter)(?::(.*?))?$/i
184
184
  m = Regexp.last_match
185
- content = IO.read(@env[:filepath])
185
+ content = IO.read(@env[:filepath]).force_encoding('utf-8')
186
186
  return false unless content =~ /^---/
187
187
 
188
- yaml = YAML.safe_load(content.split(/(---|\.\.\.)/)[1])
188
+ yaml = YAML.safe_load(content.split(/^(?:---|\.\.\.)/)[1])
189
+
190
+ return false unless yaml
189
191
  if m[2]
190
192
  value1 = yaml[m[2]]
191
193
  value1 = value1.join(',') if value1.is_a?(Array)
192
194
  if %i[type_of not_type_of].include?(operator)
193
195
  test_type(value1, value, operator)
194
- elsif value1.is_a?(Boolean)
196
+ elsif value1.bool?
195
197
  test_truthy(value1, value, operator)
196
198
  elsif value1.number? && value2.number? && %i[gt lt equal not_equal].include?(operator)
197
199
  test_operator(value1, value, operator)
data/lib/conductor/env.rb CHANGED
@@ -28,11 +28,11 @@ module Conductor
28
28
  css_path: '/Applications/Marked 2.app/Contents/Resources/swiss.css',
29
29
  ext: 'md',
30
30
  includes: [],
31
- origin: '/Users/ttscoff/Library/Mobile Documents/9CR7T2DMDG~com~ngocluu~onewriter/Documents/nvALT2.2/',
32
- filepath: '/Users/ttscoff/Library/Mobile Documents/9CR7T2DMDG~com~ngocluu~onewriter/Documents/nvALT2.2/bt.com App Review- AeroPress timer for iPhone.md',
31
+ origin: '/Users/ttscoff/Dropbox/Writing/brettterpstra.com/_drafts/',
32
+ filepath: '/Users/ttscoff/Dropbox/Writing/brettterpstra.com/_drafts/marked-2-and-obsidian.md',
33
33
  phase: 'PREPROCESS',
34
34
  outline: 'NONE',
35
- path: '/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/ttscoff/Library/Mobile Documents/9CR7T2DMDG~com~ngocluu~onewriter/Documents/nvALT2.2'
35
+ path: '/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/ttscoff/Dropbox/Writing/brettterpstra.com/_drafts/'
36
36
  }
37
37
  end
38
38
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conductor
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.3'
5
5
  end
data/lib/conductor.rb CHANGED
@@ -11,6 +11,7 @@ require_relative 'conductor/env'
11
11
  require_relative 'conductor/config'
12
12
  require_relative 'conductor/hash'
13
13
  require_relative 'conductor/array'
14
+ require_relative 'conductor/boolean'
14
15
  require_relative 'conductor/string'
15
16
  require_relative 'conductor/script'
16
17
  require_relative 'conductor/command'
@@ -19,7 +20,7 @@ require_relative 'conductor/condition'
19
20
  module Conductor
20
21
  class << self
21
22
  def stdin
22
- @stdin ||= $stdin.read.strip if $stdin.stat.size.positive? || $stdin.fcntl(Fcntl::F_GETFL, 0).zero?
23
+ @stdin ||= $stdin.read.strip.force_encoding('utf-8') if $stdin.stat.size.positive? || $stdin.fcntl(Fcntl::F_GETFL, 0).zero?
23
24
  end
24
25
  end
25
26
  end
data/src/_README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!--README-->
2
- [![RubyGems.org](https://img.shields.io/gem/v/journal-cli)](https://rubygems.org/gems/journal-cli)
2
+ [![RubyGems.org](https://img.shields.io/gem/v/marked-conductor)](https://rubygems.org/gems/marked-conductor)
3
3
 
4
4
  # Marked Conductor
5
5
 
@@ -73,7 +73,7 @@ Available conditions are:
73
73
  - `path`: This tests just the path itself, allowing conditions like `path contains _drafts` or `path does not contain _posts`.
74
74
  - `phase`: Tests whether Marked is in Preprocessor or Processor phase, allowing conditions like `phase is preprocess` or `phase is process` (which can be shortened to `pre` and `pro`).
75
75
  - `text`: This tests for any string match within the text of the document being processed. This can be used with operators `starts with`, `ends with`, or `contains`, e.g. `text contains @taskpaper` or `text does not contain <!--more-->`.
76
- - If the test value is surrounded by forward slashes, it will be treated as a regular expression. Regexes are always flagged as case insensitive. Use it like `text matches @\w+`.
76
+ - If the test value is surrounded by forward slashes, it will be treated as a regular expression. Regexes are always flagged as case insensitive. Use it like `text contains /@\w+/`.
77
77
  - `yaml`, `headers`, or `frontmatter` will test for YAML headers. If a `yaml:KEY` is defined, a specific YAML key will be tested for. If a value is defined with an operator, it will be tested against the value key.
78
78
  - `yaml` tests for the presence of YAML frontmatter.
79
79
  - `yaml:comments` tests for the presence of a `comments` key.
@@ -108,6 +108,12 @@ Commands are interpreted as shell commands. If a command exists in the `$PATH`,
108
108
 
109
109
  Using `$file` as an argument to a script or command will bypass processing of STDIN input, and instead use the value of $MARKED_PATH to read the contents of the specified file.
110
110
 
111
+ ## Custom Processors
112
+
113
+ All of the [capabilities and requirements](https://marked2app.com/help/Custom_Processor) of a Custom Processor script or command still apply, and all of the [environment variables that Marked sets](https://marked2app.com/help/Custom_Processor#environmentvariables) are still available. You just no longer have to have one huge script that forks on the various environment variables and you don't have to write your own tests for handling different scenarios.
114
+
115
+ A script run by Conductor already knows it has the right type of file with the expected data and path, so your script can focus on just processing one file type. It's recommended to separate all of that logic you may already have written out into separate scripts and let Conductor handle the forking based on various criteria.
116
+
111
117
  ## Testing
112
118
 
113
119
  In order to test from the command line, you'll need certain environment variables set. This can be done by exporting the following variables with your own definitions, or by running conductor with all of the variables preceding the command, e.g. `$ MARKED_ORIGIN=/path/to/markdown_file.md [...] conductor`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marked-conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -88,6 +88,7 @@ files:
88
88
  - images/preferences.jpg
89
89
  - lib/conductor.rb
90
90
  - lib/conductor/array.rb
91
+ - lib/conductor/boolean.rb
91
92
  - lib/conductor/command.rb
92
93
  - lib/conductor/condition.rb
93
94
  - lib/conductor/config.rb