Module: LiquidDiagrams::Utils
- Defined in:
- lib/liquid_diagrams/utils.rb
Constant Summary collapse
- INLINE_OPTIONS_SYNTAX =
/^\s*(?:(\w+)=(\w+|"[^"]+")\s+)*\s*$/.freeze
- INLINE_OPTIONS_REGEXP =
/(?:(\w+)=(\w+|"[^"]+"))/.freeze
Class Method Summary collapse
- .build_flags(config, keys, prefix: '--') ⇒ Object
- .build_options(config, keys, prefix: '--', sep: ' ') ⇒ Object
-
.join(args, with:) { ... } ⇒ String
Join the args with prefix.
- .parse_inline_options(input) ⇒ Object
- .run_jar(jar) ⇒ Object
- .vendor_path(file = '') ⇒ Object
Class Method Details
.build_flags(config, keys, prefix: '--') ⇒ Object
40 41 42 43 44 |
# File 'lib/liquid_diagrams/utils.rb', line 40 def build_flags(config, keys, prefix: '--') config.slice(*keys).map do |flag, val| "#{prefix}#{flag}" if val end.join(' ').strip end |
.build_options(config, keys, prefix: '--', sep: ' ') ⇒ Object
34 35 36 37 38 |
# File 'lib/liquid_diagrams/utils.rb', line 34 def (config, keys, prefix: '--', sep: ' ') config.slice(*keys).map do |opt, val| "#{prefix}#{opt}#{sep}#{val}" end.join(' ').strip end |
.join(args, with:) { ... } ⇒ String
Join the args with prefix
27 28 29 30 31 32 |
# File 'lib/liquid_diagrams/utils.rb', line 27 def join(args, with:) args = Array(args) args = args.map { |arg| yield arg } if block_given? "#{with}#{args.join(with)}".strip end |
.parse_inline_options(input) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/liquid_diagrams/utils.rb', line 57 def (input) = {} input.scan(INLINE_OPTIONS_REGEXP) do |key, value| value.delete!('"') if value.include?('"') [key.to_s] = value end end |
.run_jar(jar) ⇒ Object
46 47 48 |
# File 'lib/liquid_diagrams/utils.rb', line 46 def run_jar(jar) "java -Djava.awt.headless=true -jar #{jar}" end |
.vendor_path(file = '') ⇒ Object
50 51 52 |
# File 'lib/liquid_diagrams/utils.rb', line 50 def vendor_path(file = '') File.join(__dir__, '../../vendor', file) end |