mushy 0.3.0 → 0.5.2
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/bin/mushy +2 -1
- data/lib/mushy/builder/api.rb +8 -0
- data/lib/mushy/date_parts.rb +30 -0
- data/lib/mushy/flux.rb +4 -0
- data/lib/mushy/fluxs/bash.rb +1 -0
- data/lib/mushy/fluxs/browser.rb +4 -1
- data/lib/mushy/fluxs/document.rb +27 -0
- data/lib/mushy/fluxs/interval.rb +1 -20
- data/lib/mushy/fluxs/ls.rb +119 -15
- data/lib/mushy/fluxs/print.rb +26 -0
- data/lib/mushy/fluxs/pwd.rb +31 -0
- data/lib/mushy/fluxs/screenshot.rb +10 -7
- data/lib/mushy/fluxs/write_file.rb +32 -20
- data/mushy.gemspec +1 -1
- metadata +5 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e8d94c18f18225b3d7b04d1c78731a2d1211e444f8685a4c812368b8025b4357
         | 
| 4 | 
            +
              data.tar.gz: 9df6cbd619217e2d24e8495ad104f49ddb5fc0e68d22ce5098f9a5e39067f85c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 77474ee6b3b8ef571cd3283896c2c9a30bb2b245cc07ad357f2128ab82d5eec3092ae4eb374111b0baffa061b14257ad6daacd9adadf7fb00185c94c032b7bf3
         | 
| 7 | 
            +
              data.tar.gz: 1a5019513bd3223d4106938518026e1790764bf927e14a776b4d9c42889e1b1e380973efe61fb93e81d25db200ba53bffc51dacb8f571c711e646e7b80edf078
         | 
    
        data/bin/mushy
    CHANGED
    
    
    
        data/lib/mushy/builder/api.rb
    CHANGED
    
    | @@ -95,6 +95,14 @@ module Mushy | |
| 95 95 | 
             
                                     details[:config][:sort] = { type: 'text', shrink: true, description: 'Sort by this key.', default: '' }
         | 
| 96 96 | 
             
                                     details[:config][:model] = { type: 'keyvalue', shrink: true, description: 'Reshape the outgoing events.', value: {}, default: {} }
         | 
| 97 97 |  | 
| 98 | 
            +
                                     details[:config][:error_strategy] = {
         | 
| 99 | 
            +
                                       description: 'Error strategy. (return to return an event with "exception" returning the error, or ignore to ignore the exception)',
         | 
| 100 | 
            +
                                       type:        'select',
         | 
| 101 | 
            +
                                       options:     ['', 'return', 'ignore'],
         | 
| 102 | 
            +
                                       value:       '',
         | 
| 103 | 
            +
                                       shrink:      true,
         | 
| 104 | 
            +
                                     }
         | 
| 105 | 
            +
             | 
| 98 106 | 
             
                                     details[:config]
         | 
| 99 107 | 
             
                                            .select { |_, v| v[:type] == 'keyvalue' }
         | 
| 100 108 | 
             
                                            .select { |_, v| v[:editors].nil? }
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            module Mushy
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module DateParts
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.parse now
         | 
| 6 | 
            +
                  {
         | 
| 7 | 
            +
                    year: nil,
         | 
| 8 | 
            +
                    month: nil,
         | 
| 9 | 
            +
                    day: nil,
         | 
| 10 | 
            +
                    hour: nil,
         | 
| 11 | 
            +
                    minute: :min,
         | 
| 12 | 
            +
                    second: :sec,
         | 
| 13 | 
            +
                    nanosecond: :nsec,
         | 
| 14 | 
            +
                    utc_offset: nil,
         | 
| 15 | 
            +
                    weekday: :wday,
         | 
| 16 | 
            +
                    day_of_month: :mday,
         | 
| 17 | 
            +
                    day_of_year: :yday,
         | 
| 18 | 
            +
                    string: :to_s,
         | 
| 19 | 
            +
                    epoch_integer: :to_i,
         | 
| 20 | 
            +
                    epoch_float: :to_f,
         | 
| 21 | 
            +
                  }.reduce({}) do |t, i|
         | 
| 22 | 
            +
                    method = i[1] || i[0]
         | 
| 23 | 
            +
                    t[i[0]] = now.send method
         | 
| 24 | 
            +
                    t
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            end
         | 
    
        data/lib/mushy/flux.rb
    CHANGED
    
    | @@ -77,6 +77,10 @@ module Mushy | |
| 77 77 |  | 
| 78 78 | 
             
                  returned_one_result ? results.first : results
         | 
| 79 79 |  | 
| 80 | 
            +
                rescue Exception => e
         | 
| 81 | 
            +
                  raise e if config[:error_strategy].to_s == ''
         | 
| 82 | 
            +
                  return [] if config[:error_strategy] == 'ignore'
         | 
| 83 | 
            +
                  { exception: e.message }
         | 
| 80 84 | 
             
                end
         | 
| 81 85 |  | 
| 82 86 | 
             
                def standardize_these results
         | 
    
        data/lib/mushy/fluxs/bash.rb
    CHANGED
    
    
    
        data/lib/mushy/fluxs/browser.rb
    CHANGED
    
    | @@ -18,7 +18,7 @@ module Mushy | |
| 18 18 | 
             
                                  description: 'Run this browser headless.',
         | 
| 19 19 | 
             
                                  type:        'boolean',
         | 
| 20 20 | 
             
                                  shrink:      true,
         | 
| 21 | 
            -
                                  value:       ' | 
| 21 | 
            +
                                  value:       '',
         | 
| 22 22 | 
             
                                },
         | 
| 23 23 | 
             
                      timeout: {
         | 
| 24 24 | 
             
                                 description: 'The default timeout (in seconds) before closing the browser. Default is 5 seconds.',
         | 
| @@ -90,7 +90,9 @@ module Mushy | |
| 90 90 |  | 
| 91 91 | 
             
                  browser.headers.add get_the_headers_from(event, config)
         | 
| 92 92 |  | 
| 93 | 
            +
                  the_start = Time.now
         | 
| 93 94 | 
             
                  browser.goto config[:url]
         | 
| 95 | 
            +
                  time = Time.now - the_start
         | 
| 94 96 |  | 
| 95 97 | 
             
                  browser.execute(config[:execute]) if config[:execute]
         | 
| 96 98 |  | 
| @@ -102,6 +104,7 @@ module Mushy | |
| 102 104 | 
             
                    title: browser.frames[0].title,
         | 
| 103 105 | 
             
                    cookies: browser.cookies.all.map { |k, v| v.instance_variable_get('@attributes') },
         | 
| 104 106 | 
             
                    headers: browser.headers.get,
         | 
| 107 | 
            +
                    time: time,
         | 
| 105 108 | 
             
                    body: browser.body
         | 
| 106 109 | 
             
                  }
         | 
| 107 110 |  | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            module Mushy
         | 
| 2 | 
            +
              
         | 
| 3 | 
            +
              class Document < Flux
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.details
         | 
| 6 | 
            +
                  {
         | 
| 7 | 
            +
                    name: 'Document',
         | 
| 8 | 
            +
                    description: 'Create a multi-line document.',
         | 
| 9 | 
            +
                    config: {
         | 
| 10 | 
            +
                      document: {
         | 
| 11 | 
            +
                                  description: 'The multi-line document you wish to create.',
         | 
| 12 | 
            +
                                  type:        'textarea',
         | 
| 13 | 
            +
                                  value:       '',
         | 
| 14 | 
            +
                                },
         | 
| 15 | 
            +
                    },
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def process event, config
         | 
| 20 | 
            +
                  {
         | 
| 21 | 
            +
                    document: config[:document],
         | 
| 22 | 
            +
                  }
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            end
         | 
    
        data/lib/mushy/fluxs/interval.rb
    CHANGED
    
    | @@ -48,26 +48,7 @@ module Mushy | |
| 48 48 |  | 
| 49 49 | 
             
                def process event, config
         | 
| 50 50 | 
             
                  now = Time.now
         | 
| 51 | 
            -
                   | 
| 52 | 
            -
                    year: nil,
         | 
| 53 | 
            -
                    month: nil,
         | 
| 54 | 
            -
                    day: nil,
         | 
| 55 | 
            -
                    hour: nil,
         | 
| 56 | 
            -
                    minute: :min,
         | 
| 57 | 
            -
                    second: :sec,
         | 
| 58 | 
            -
                    nanosecond: :nsec,
         | 
| 59 | 
            -
                    utc_offset: nil,
         | 
| 60 | 
            -
                    weekday: :wday,
         | 
| 61 | 
            -
                    day_of_month: :mday,
         | 
| 62 | 
            -
                    day_of_year: :yday,
         | 
| 63 | 
            -
                    string: :to_s,
         | 
| 64 | 
            -
                    epoch_integer: :to_i,
         | 
| 65 | 
            -
                    epoch_float: :to_f,
         | 
| 66 | 
            -
                  }.reduce({}) do |t, i|
         | 
| 67 | 
            -
                    method = i[1] || i[0]
         | 
| 68 | 
            -
                    t[i[0]] = now.send method
         | 
| 69 | 
            -
                    t
         | 
| 70 | 
            -
                  end
         | 
| 51 | 
            +
                  Mushy::DateParts.parse now
         | 
| 71 52 | 
             
                end
         | 
| 72 53 |  | 
| 73 54 | 
             
              end
         | 
    
        data/lib/mushy/fluxs/ls.rb
    CHANGED
    
    | @@ -6,30 +6,134 @@ module Mushy | |
| 6 6 | 
             
                  {
         | 
| 7 7 | 
             
                    name: 'Ls',
         | 
| 8 8 | 
             
                    description: 'Run the "ls" command.',
         | 
| 9 | 
            -
                    config: {
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 9 | 
            +
                    config: Mushy::Bash.details[:config].tap { |c| c.delete :command },
         | 
| 10 | 
            +
                  }.tap do |c|
         | 
| 11 | 
            +
                    c[:config][:recursive] = {
         | 
| 12 | 
            +
                                               description: 'Pull files recursively.',
         | 
| 13 | 
            +
                                               type:        'boolean',
         | 
| 14 | 
            +
                                               shrink:      true,
         | 
| 15 | 
            +
                                               value:       '',
         | 
| 16 | 
            +
                                             }
         | 
| 17 | 
            +
                    c[:config][:path] = {
         | 
| 18 | 
            +
                                            description: 'Path, used to search for specific files.',
         | 
| 19 | 
            +
                                            type:        'text',
         | 
| 20 | 
            +
                                            shrink:      true,
         | 
| 21 | 
            +
                                            value:       '',
         | 
| 22 | 
            +
                                          }
         | 
| 23 | 
            +
                  end
         | 
| 17 24 | 
             
                end
         | 
| 18 25 |  | 
| 19 26 | 
             
                def process event, config
         | 
| 27 | 
            +
                  arguments = build_the_arguments_from config
         | 
| 20 28 |  | 
| 21 | 
            -
                  config[:command] =  | 
| 22 | 
            -
             | 
| 29 | 
            +
                  config[:command] = build_the_command_from arguments
         | 
| 23 30 | 
             
                  result = super event, config
         | 
| 24 31 |  | 
| 25 | 
            -
                   | 
| 32 | 
            +
                  things = turn_the_ls_output_to_events result, config, event
         | 
| 33 | 
            +
                  things
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def build_the_command_from arguments
         | 
| 37 | 
            +
                  "ls #{arguments.join(' ')}"
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def build_the_arguments_from config
         | 
| 41 | 
            +
                  arguments = ['-A', '-l', '--full-time', '-i']
         | 
| 42 | 
            +
                  arguments << '-R' if config[:recursive].to_s == 'true'
         | 
| 43 | 
            +
                  arguments << '-d' if config[:directory_only].to_s == 'true'
         | 
| 44 | 
            +
                  arguments << config[:path] if config[:path].to_s != ''
         | 
| 45 | 
            +
                  arguments
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def turn_the_ls_output_to_events result, config, event
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  lines = result[:text].split("\n")
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  needs_special_work_for_path = config[:directory_only].to_s != 'true' &&
         | 
| 53 | 
            +
                                                config[:path].to_s != '' &&
         | 
| 54 | 
            +
                                                lines[0] &&
         | 
| 55 | 
            +
                                                lines[0].start_with?('total ')
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  origin = config[:directory] || Dir.pwd
         | 
| 58 | 
            +
                  directory = needs_special_work_for_path ? '||DIRECTORY||' : origin
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  things = lines.map do |x|
         | 
| 61 | 
            +
                    segments = x.split ' '
         | 
| 62 | 
            +
                    result = if segments.count > 5
         | 
| 63 | 
            +
                               pull_file segments, directory
         | 
| 64 | 
            +
                             elsif segments.count == 1
         | 
| 65 | 
            +
                               dir_segments = segments[0].split("\/")
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                               if dir_segments[0] == '.'
         | 
| 68 | 
            +
                                 dir_segments[0] = origin
         | 
| 69 | 
            +
                               else
         | 
| 70 | 
            +
                                 dir_segments.unshift origin
         | 
| 71 | 
            +
                               end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                               dir_segments[-1] = dir_segments[-1].sub ':', ''
         | 
| 74 | 
            +
                               directory = dir_segments.join("\/")
         | 
| 75 | 
            +
                               nil
         | 
| 76 | 
            +
                             else
         | 
| 77 | 
            +
                               nil
         | 
| 78 | 
            +
                             end
         | 
| 79 | 
            +
                  end.select { |x| x }
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  if needs_special_work_for_path
         | 
| 82 | 
            +
                    config[:directory_only] = true
         | 
| 83 | 
            +
                    special_name = process(event, config)[0][:name]
         | 
| 84 | 
            +
                    things.each do |x|
         | 
| 85 | 
            +
                      [:directory, :path].each do |key|
         | 
| 86 | 
            +
                        if x[key].include?('||DIRECTORY||')
         | 
| 87 | 
            +
                          x[key].sub!('||DIRECTORY||', File.join(Dir.pwd, special_name))
         | 
| 88 | 
            +
                        end
         | 
| 89 | 
            +
                      end
         | 
| 90 | 
            +
                    end
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  things
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                def pull_file segments, directory
         | 
| 97 | 
            +
                  result = {}
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  [:inode, :help, :hard_links, :owner, :group, :size].each do |key|
         | 
| 100 | 
            +
                    result[key] = segments.shift; x = segments.join ' '
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  result.tap do |r|
         | 
| 104 | 
            +
                    r[:date] = []
         | 
| 105 | 
            +
                    3.times { r[:date] << segments.shift }
         | 
| 106 | 
            +
                    r[:date] = r[:date].join ' '
         | 
| 107 | 
            +
                    r[:date] = Time.parse r[:date]
         | 
| 108 | 
            +
                  end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  result[:name] = segments.shift
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  result.tap do |r|
         | 
| 113 | 
            +
                    help_segments = r[:help].split ''
         | 
| 114 | 
            +
                    r[:type] = help_segments[0]
         | 
| 115 | 
            +
                    r[:owner_permission] = [1, 2, 3].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
         | 
| 116 | 
            +
                    r[:group_permission] = [4, 5, 6].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
         | 
| 117 | 
            +
                    r[:other_permission] = [7, 8, 9].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
         | 
| 118 | 
            +
                    r.delete :help
         | 
| 119 | 
            +
                  end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  [:hard_links, :size].each { |x| result[x] = result[x].to_i }
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                  result[:date] = Mushy::DateParts.parse result[:date]
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                  result[:directory] = directory
         | 
| 26 126 |  | 
| 27 | 
            -
                  result[: | 
| 28 | 
            -
                     | 
| 29 | 
            -
             | 
| 30 | 
            -
                     | 
| 127 | 
            +
                  if result[:type] == 'd' && result[:directory] == result[:name]
         | 
| 128 | 
            +
                    result[:path] = result[:directory]
         | 
| 129 | 
            +
                    name_segments = result[:name].split "\/"
         | 
| 130 | 
            +
                    result[:name] = name_segments.pop
         | 
| 131 | 
            +
                    result[:directory] = name_segments.join "\/"
         | 
| 132 | 
            +
                  else
         | 
| 133 | 
            +
                    result[:path] = File.join result[:directory], result[:name]
         | 
| 31 134 | 
             
                  end
         | 
| 32 135 |  | 
| 136 | 
            +
                  result
         | 
| 33 137 | 
             
                end
         | 
| 34 138 |  | 
| 35 139 | 
             
              end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            module Mushy
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Print < Flux
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.details
         | 
| 6 | 
            +
                  {
         | 
| 7 | 
            +
                    name: 'Print',
         | 
| 8 | 
            +
                    description: 'Print output to the screen.',
         | 
| 9 | 
            +
                    config: {
         | 
| 10 | 
            +
                      message: {
         | 
| 11 | 
            +
                              description: 'The message to display',
         | 
| 12 | 
            +
                              type:        'text',
         | 
| 13 | 
            +
                              value:       '',
         | 
| 14 | 
            +
                            },
         | 
| 15 | 
            +
                    }
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def process event, config
         | 
| 20 | 
            +
                  puts config[:message]
         | 
| 21 | 
            +
                  {}
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module Mushy
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Pwd < Bash
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.details
         | 
| 6 | 
            +
                  {
         | 
| 7 | 
            +
                    name: 'Pwd',
         | 
| 8 | 
            +
                    description: 'Run the "pwd" command.',
         | 
| 9 | 
            +
                    config: Mushy::Bash.details[:config].tap { |c| c.delete :command },
         | 
| 10 | 
            +
                  }
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def process event, config
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  config[:command] = 'pwd'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  result = super event, config
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  return result unless result[:success]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  pwd = result[:text].to_s.strip
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  {
         | 
| 24 | 
            +
                    pwd: Mushy::Ls.new.process({}, { path: pwd, directory_only: true })[0]
         | 
| 25 | 
            +
                  }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            end
         | 
| @@ -7,11 +7,10 @@ module Mushy | |
| 7 7 | 
             
                  details['name'] = 'Screenshot'
         | 
| 8 8 | 
             
                  details['description'] = 'Take a screenshot of the browser.'
         | 
| 9 9 |  | 
| 10 | 
            -
                  details[:config] | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
                  }
         | 
| 10 | 
            +
                  details[:config].merge!(Mushy::WriteFile.file_saving_config.tap do |x|
         | 
| 11 | 
            +
                    x[x.keys.first][:value] = 'file.jpg'
         | 
| 12 | 
            +
                  end)
         | 
| 13 | 
            +
             | 
| 15 14 | 
             
                  details[:config][:quality] = {
         | 
| 16 15 | 
             
                     description: 'The quality of the image, a value beteen 0-100. Only applies to jpg.',
         | 
| 17 16 | 
             
                     type:        'integer',
         | 
| @@ -33,15 +32,19 @@ module Mushy | |
| 33 32 | 
             
                  the_result  = input[:result]
         | 
| 34 33 | 
             
                  the_config  = input[:config]
         | 
| 35 34 |  | 
| 35 | 
            +
                  file = Mushy::WriteFile.get_file_from the_config
         | 
| 36 36 | 
             
                  options = {
         | 
| 37 | 
            -
                      path:     | 
| 37 | 
            +
                      path:    file,
         | 
| 38 38 | 
             
                      full:    ['true', ''].include?(the_config[:full].to_s),
         | 
| 39 39 | 
             
                      quality: (the_config[:quality].to_s == '' ? '100' : the_config[:quality]).to_i
         | 
| 40 40 | 
             
                  }
         | 
| 41 41 |  | 
| 42 42 | 
             
                  the_browser.screenshot options
         | 
| 43 43 |  | 
| 44 | 
            -
                  options
         | 
| 44 | 
            +
                  the_result[:options] = options
         | 
| 45 | 
            +
                  the_result[:file] = Mushy::Ls.new.process({}, { path: file })[0]
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  the_result
         | 
| 45 48 |  | 
| 46 49 | 
             
                end
         | 
| 47 50 |  | 
| @@ -6,34 +6,46 @@ module Mushy | |
| 6 6 | 
             
                  {
         | 
| 7 7 | 
             
                    name: 'WriteFile',
         | 
| 8 8 | 
             
                    description: 'Write a file.',
         | 
| 9 | 
            -
                    config: {
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                              description: 'The directory in which to write the file. Leave blank for the current directory.',
         | 
| 17 | 
            -
                              type:        'text',
         | 
| 18 | 
            -
                              value:       '',
         | 
| 19 | 
            -
                            },
         | 
| 20 | 
            -
                      data: {
         | 
| 21 | 
            -
                              description: 'The text to write. You can use Liquid templating here to pull data from the event, or write hardcoded data.',
         | 
| 22 | 
            -
                              type:        'text',
         | 
| 23 | 
            -
                              value:       '{{data}}',
         | 
| 24 | 
            -
                            },
         | 
| 25 | 
            -
                    },
         | 
| 9 | 
            +
                    config: file_saving_config.merge({
         | 
| 10 | 
            +
                              data: {
         | 
| 11 | 
            +
                                      description: 'The text to write. You can use Liquid templating here to pull data from the event, or write hardcoded data.',
         | 
| 12 | 
            +
                                      type:        'text',
         | 
| 13 | 
            +
                                      value:       '{{data}}',
         | 
| 14 | 
            +
                                    },
         | 
| 15 | 
            +
                            }),
         | 
| 26 16 | 
             
                  }
         | 
| 27 17 | 
             
                end
         | 
| 28 18 |  | 
| 29 | 
            -
                def  | 
| 30 | 
            -
                   | 
| 19 | 
            +
                def self.file_saving_config
         | 
| 20 | 
            +
                  {
         | 
| 21 | 
            +
                    name: {
         | 
| 22 | 
            +
                            description: 'The name of the file.',
         | 
| 23 | 
            +
                            type:        'text',
         | 
| 24 | 
            +
                            value:       'file.csv',
         | 
| 25 | 
            +
                          },
         | 
| 26 | 
            +
                    directory: {
         | 
| 27 | 
            +
                                 description: 'The directory in which to write the file. Leave blank for the current directory.',
         | 
| 28 | 
            +
                                 shrink:      true,
         | 
| 29 | 
            +
                                 type:        'text',
         | 
| 30 | 
            +
                                 value:       '',
         | 
| 31 | 
            +
                               },
         | 
| 32 | 
            +
                    }
         | 
| 33 | 
            +
                end
         | 
| 31 34 |  | 
| 35 | 
            +
                def self.get_file_from config
         | 
| 36 | 
            +
                  file = config[:name]
         | 
| 32 37 | 
             
                  file = File.join(config[:directory], file) if config[:directory].to_s != ''
         | 
| 38 | 
            +
                  file
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def process event, config
         | 
| 42 | 
            +
                  file = self.class.get_file_from config
         | 
| 33 43 |  | 
| 34 44 | 
             
                  File.open(file, 'w') { |f| f.write config[:data] }
         | 
| 35 45 |  | 
| 36 | 
            -
                  { | 
| 46 | 
            +
                  {
         | 
| 47 | 
            +
                    file: Mushy::Ls.new.process({}, { path: file })[0]
         | 
| 48 | 
            +
                  }
         | 
| 37 49 | 
             
                end
         | 
| 38 50 |  | 
| 39 51 | 
             
              end
         | 
    
        data/mushy.gemspec
    CHANGED
    
    | @@ -4,7 +4,7 @@ require 'mushy/version' | |
| 4 4 |  | 
| 5 5 | 
             
            Gem::Specification.new do |s|
         | 
| 6 6 | 
             
              s.name           = 'mushy'
         | 
| 7 | 
            -
              s.version        = '0. | 
| 7 | 
            +
              s.version        = '0.5.2'
         | 
| 8 8 | 
             
              s.date           = '2020-11-23'
         | 
| 9 9 | 
             
              s.summary        = 'Process streams of work using common modules.'
         | 
| 10 10 | 
             
              s.description    = 'This tool assists in the creation and processing of workflows.'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mushy
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Darren Cauthon
         | 
| @@ -164,6 +164,7 @@ files: | |
| 164 164 | 
             
            - lib/mushy/builder/dark.rb
         | 
| 165 165 | 
             
            - lib/mushy/builder/index.rb
         | 
| 166 166 | 
             
            - lib/mushy/builder/vue.rb
         | 
| 167 | 
            +
            - lib/mushy/date_parts.rb
         | 
| 167 168 | 
             
            - lib/mushy/event.rb
         | 
| 168 169 | 
             
            - lib/mushy/flow.rb
         | 
| 169 170 | 
             
            - lib/mushy/flux.rb
         | 
| @@ -172,6 +173,7 @@ files: | |
| 172 173 | 
             
            - lib/mushy/fluxs/build_csv.rb
         | 
| 173 174 | 
             
            - lib/mushy/fluxs/cli.rb
         | 
| 174 175 | 
             
            - lib/mushy/fluxs/collection.rb
         | 
| 176 | 
            +
            - lib/mushy/fluxs/document.rb
         | 
| 175 177 | 
             
            - lib/mushy/fluxs/environment.rb
         | 
| 176 178 | 
             
            - lib/mushy/fluxs/filter.rb
         | 
| 177 179 | 
             
            - lib/mushy/fluxs/format.rb
         | 
| @@ -181,6 +183,8 @@ files: | |
| 181 183 | 
             
            - lib/mushy/fluxs/ls.rb
         | 
| 182 184 | 
             
            - lib/mushy/fluxs/parse_html.rb
         | 
| 183 185 | 
             
            - lib/mushy/fluxs/pdf.rb
         | 
| 186 | 
            +
            - lib/mushy/fluxs/print.rb
         | 
| 187 | 
            +
            - lib/mushy/fluxs/pwd.rb
         | 
| 184 188 | 
             
            - lib/mushy/fluxs/read_csv.rb
         | 
| 185 189 | 
             
            - lib/mushy/fluxs/read_file.rb
         | 
| 186 190 | 
             
            - lib/mushy/fluxs/screenshot.rb
         |