run_tasks 1.2.5 → 1.2.7
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/src/run/markdown.rb +35 -0
- data/src/run/string.rb +56 -0
- data/src/run.rb +2 -2
- metadata +3 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: da3ec2cfa88571c506d40137ccf45d89ee9fbee8929d90ae8473655283b6d670
         | 
| 4 | 
            +
              data.tar.gz: f16ab0960472b63733244160e327844baeb3151d29434a7bd56948444df074a9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d201af5c988bfad270cac3a72b4128bb2abd8366631bd84f1e35883662e84ce9e620769ede8d9fbff83ee74fe2c85a399a573ce3d082dd07d3f7cb857eb22efc
         | 
| 7 | 
            +
              data.tar.gz: caa52f6153fb91d953a0e25218e8a62493b0fb35bc3c3c2af7488cc96f93285c2e6ae1117a509f9df86c7b6c86d84ad203416cd0c82eaa4519ac84ae2c9e91ad
         | 
    
        data/src/run/markdown.rb
    ADDED
    
    | @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require_relative "./string"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Markdown
         | 
| 4 | 
            +
              def initialize(string)
         | 
| 5 | 
            +
                @string = string
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def to_ansi
         | 
| 9 | 
            +
                # Apply private methods onto string.
         | 
| 10 | 
            +
                private_methods(false).reject{ |name| name == :initialize }
         | 
| 11 | 
            +
                                      .reduce(@string) do |string, method|
         | 
| 12 | 
            +
                                        send(method, string)
         | 
| 13 | 
            +
                                      end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              private
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def bold(string)
         | 
| 19 | 
            +
                string.gsub(/([^*_])[*_]{2}([^*_]+)[*_]{2}([^*_])/) do
         | 
| 20 | 
            +
                  Regexp.last_match[1] + Regexp.last_match[2].bold + Regexp.last_match[3]
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def code(string)
         | 
| 25 | 
            +
                string.gsub(/([^`])`([^*_]+)`([^`])/) do
         | 
| 26 | 
            +
                  Regexp.last_match[1] + Regexp.last_match[2].blue.inverse + Regexp.last_match[3]
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def italic(string)
         | 
| 31 | 
            +
                string.gsub(/([^*_])[*_]{1}([^*_]+)[*_]{1}([^*_])/) do
         | 
| 32 | 
            +
                  Regexp.last_match[1] + Regexp.last_match[2].italic + Regexp.last_match[3]
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
    
        data/src/run/string.rb
    ADDED
    
    | @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            # https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class String
         | 
| 4 | 
            +
              @@styles = {
         | 
| 5 | 
            +
                :bold              => "1",
         | 
| 6 | 
            +
                :dim               => "2",
         | 
| 7 | 
            +
                :italic            => "3",
         | 
| 8 | 
            +
                :underline         => "4",
         | 
| 9 | 
            +
                :inverse           => "7",
         | 
| 10 | 
            +
                :strikethrough     => "9",
         | 
| 11 | 
            +
                :fg_black          => "30",
         | 
| 12 | 
            +
                :fg_red            => "31",
         | 
| 13 | 
            +
                :fg_green          => "32",
         | 
| 14 | 
            +
                :fg_yellow         => "33",
         | 
| 15 | 
            +
                :fg_blue           => "34",
         | 
| 16 | 
            +
                :fg_magenta        => "35",
         | 
| 17 | 
            +
                :fg_cyan           => "36",
         | 
| 18 | 
            +
                :fg_white          => "37",
         | 
| 19 | 
            +
                :fg_bright_black   => "30;1",
         | 
| 20 | 
            +
                :fg_bright_red     => "31;1",
         | 
| 21 | 
            +
                :fg_bright_green   => "32;1",
         | 
| 22 | 
            +
                :fg_bright_yellow  => "33;1",
         | 
| 23 | 
            +
                :fg_bright_blue    => "34;1",
         | 
| 24 | 
            +
                :fg_bright_magenta => "35;1",
         | 
| 25 | 
            +
                :fg_bright_cyan    => "36;1",
         | 
| 26 | 
            +
                :fg_bright_white   => "37;1",
         | 
| 27 | 
            +
              }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              # To be able to handle more styles (with method chaining) we should refactor this.
         | 
| 30 | 
            +
              def stylize(style)
         | 
| 31 | 
            +
                "\033[#{@@styles[style.to_sym]}m#{self}\033[0m"
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def bold;              stylize(:bold); end
         | 
| 35 | 
            +
              def dim;               stylize(:dim); end
         | 
| 36 | 
            +
              def italic;            stylize(:italic); end
         | 
| 37 | 
            +
              def underline;         stylize(:underline); end
         | 
| 38 | 
            +
              def inverse;           stylize(:inverse); end
         | 
| 39 | 
            +
              def strikethrough;     stylize(:strikethrough); end
         | 
| 40 | 
            +
              def black;             stylize(:fg_black); end
         | 
| 41 | 
            +
              def red;               stylize(:fg_red); end
         | 
| 42 | 
            +
              def green;             stylize(:fg_green); end
         | 
| 43 | 
            +
              def yellow;            stylize(:fg_yellow); end
         | 
| 44 | 
            +
              def blue;              stylize(:fg_blue); end
         | 
| 45 | 
            +
              def magenta;           stylize(:fg_magenta); end
         | 
| 46 | 
            +
              def cyan;              stylize(:fg_cyan); end
         | 
| 47 | 
            +
              def white;             stylize(:fg_white); end
         | 
| 48 | 
            +
              def bright_black;      stylize(:fg_bright_black); end
         | 
| 49 | 
            +
              def bright_red;        stylize(:fg_bright_red); end
         | 
| 50 | 
            +
              def bright_green;      stylize(:fg_bright_green); end
         | 
| 51 | 
            +
              def bright_yellow;     stylize(:fg_bright_yellow); end
         | 
| 52 | 
            +
              def bright_blue;       stylize(:fg_bright_blue); end
         | 
| 53 | 
            +
              def bright_magenta;    stylize(:fg_bright_magenta); end
         | 
| 54 | 
            +
              def bright_cyan;       stylize(:fg_bright_cyan); end
         | 
| 55 | 
            +
              def bright_white;      stylize(:fg_bright_white); end
         | 
| 56 | 
            +
            end
         | 
    
        data/src/run.rb
    CHANGED
    
    | @@ -9,8 +9,8 @@ require "securerandom" | |
| 9 9 |  | 
| 10 10 | 
             
            ##########################################################################################
         | 
| 11 11 |  | 
| 12 | 
            -
            require_relative " | 
| 13 | 
            -
            require_relative " | 
| 12 | 
            +
            require_relative "#{__dir__}/run/markdown"
         | 
| 13 | 
            +
            require_relative "#{__dir__}/run/string"
         | 
| 14 14 |  | 
| 15 15 | 
             
            ##########################################################################################
         | 
| 16 16 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: run_tasks
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Aurélien Delogu
         | 
| @@ -19,6 +19,8 @@ extra_rdoc_files: [] | |
| 19 19 | 
             
            files:
         | 
| 20 20 | 
             
            - bin/run
         | 
| 21 21 | 
             
            - src/run.rb
         | 
| 22 | 
            +
            - src/run/markdown.rb
         | 
| 23 | 
            +
            - src/run/string.rb
         | 
| 22 24 | 
             
            homepage: https://github.com/pyrsmk/run
         | 
| 23 25 | 
             
            licenses:
         | 
| 24 26 | 
             
            - MIT
         |