markdown_exec 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/colorize.rb ADDED
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # encoding=utf-8
4
+
5
+ # │0 │ to restore default │
6
+ # │ │ color │
7
+ # ├───┼───────────────────────┤
8
+ # │ │ │
9
+ # │1 │ for brighter colors │
10
+ # ├───┼───────────────────────┤
11
+ # │ │ │
12
+ # │4 │ for underlined text │
13
+ # ├───┼───────────────────────┤
14
+ # │ │ │
15
+ # │5 │ for flashing text
16
+ class String
17
+ def black
18
+ "\033[30m#{self}\033[0m"
19
+ end
20
+
21
+ def red
22
+ "\033[31m#{self}\033[0m"
23
+ end
24
+
25
+ def bred
26
+ "\033[1;31m#{self}\033[0m"
27
+ end
28
+
29
+ def green
30
+ "\033[32m#{self}\033[0m"
31
+ end
32
+
33
+ def bgreen
34
+ "\033[1;32m#{self}\033[0m"
35
+ end
36
+
37
+ def yellow
38
+ "\033[33m#{self}\033[0m"
39
+ end
40
+
41
+ def byellow
42
+ "\033[1;33m#{self}\033[0m"
43
+ end
44
+
45
+ def blue
46
+ "\033[34m#{self}\033[0m"
47
+ end
48
+
49
+ def magenta
50
+ "\033[35m#{self}\033[0m"
51
+ end
52
+
53
+ def cyan
54
+ "\033[36m#{self}\033[0m"
55
+ end
56
+
57
+ def white
58
+ "\033[37m#{self}\033[0m"
59
+ end
60
+
61
+ def bwhite
62
+ "\033[1;37m#{self}\033[0m"
63
+ end
64
+ end
data/lib/env.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # encoding=utf-8
4
+
5
+ # utility functions to read environment variables
6
+ #
7
+ module Env
8
+ # :reek:BooleanParameter
9
+ # :reek:DataClump
10
+ # :reek:NilCheck
11
+ # :reek:UtilityFunction
12
+ def env_bool(name, default: false)
13
+ return default if name.nil? || (val = ENV[name]).nil?
14
+ return false if val.empty? || val == '0'
15
+
16
+ true
17
+ end
18
+
19
+ # skip :reek:DataClump
20
+ # skip :reek:NilCheck
21
+ # skip :reek:UtilityFunction
22
+ def env_int(name, default: 0)
23
+ return default if name.nil? || (val = ENV[name]).nil?
24
+ return default if val.empty?
25
+
26
+ val.to_i
27
+ end
28
+
29
+ # skip :reek:DataClump
30
+ # skip :reek:NilCheck
31
+ # skip :reek:UtilityFunction
32
+ def env_str(name, default: '')
33
+ return default if name.nil? || (val = ENV[name]).nil?
34
+
35
+ val || default
36
+ end
37
+ end
data/lib/globfiles.rb ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # encoding=utf-8
4
+
5
+ # require 'json'
6
+ # require 'yaml'
7
+
8
+ # require_relative 'env'
9
+ # include Env
10
+
11
+ ## directory listing of saved files matching glob
12
+ #
13
+ class Globfiles
14
+ def initialize(folder, glob)
15
+ @folder = folder
16
+ @glob = glob
17
+ end
18
+
19
+ def list_all
20
+ Dir.glob(File.join(@folder, @glob)).tap_inspect
21
+ end
22
+
23
+ ## single most recent item
24
+ #
25
+ def most_recent(arr = nil)
26
+ arr = list_all if arr.nil?
27
+ return if arr.count < 1
28
+
29
+ arr.max.tap_inspect
30
+ end
31
+
32
+ ## multiple recent items
33
+ #
34
+ def most_recent_list(list_count, arr = nil)
35
+ arr = list_all if arr.nil?
36
+ return if (ac = arr.count) < 1
37
+
38
+ arr.sort[-[ac, list_count].min..].reverse.tap_inspect
39
+ end
40
+ end # class Globfiles
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :reek:TooManyConstants
3
4
  module MarkdownExec
4
5
  APP_DESC = 'Markdown Executor'
5
6
  APP_NAME = 'MDE'
6
7
  BIN_NAME = 'mde'
7
8
  GEM_NAME = 'markdown_exec'
8
- VERSION = '1.1.0'
9
+ TAP_DEBUG = 'MDE_DEBUG'
10
+ VERSION = '1.3.0'
9
11
  end