Sha256: a1fffa8db23615d35351f6c94ce72cf9adb2a15fb4539849a8669bdcfbc7a6f8

Contents?: true

Size: 1.31 KB

Versions: 51

Compression:

Stored size: 1.31 KB

Contents

class Marty::Helper
  include Delorean::Model

  delorean_fn :sleep, sig: 1 do |seconds|
    Kernel.sleep seconds
  end

  delorean_fn :range_step, sig: 3 do |rstart, rend, step|
    (rstart..rend).step(step).to_a
  end

  delorean_fn :my_ip, sig: 0 do
    Marty::Diagnostic::Node.my_ip
  end

  delorean_fn :git, sig: 0 do
    [my_ip, ENV['DELAYED_VER']]
  end

  delorean_fn :infinity_dt, sig: 1 do |pt|
    Mcfly.is_infinity pt
  end

  delorean_fn :constantize, sig: 1 do |class_name|
    raise 'bad class_name' unless class_name.is_a?(String)

    class_name.constantize
  end

  delorean_fn :get_column_types, sig: 1 do |klass|
    Marty::DataConversion.col_types(klass)
  end

  delorean_fn :parse_csv_to_hash, sig: 3 do |txt, comma_sep, types|
    txt ||= ''
    headers, *rows = CSV.parse(txt.strip,
                               headers: true,
                               col_sep: (comma_sep ? ',' : "\t")).to_a
    rows.map do |row|
      headers.zip(row).each_with_object({}) do |(h, v), res|
        res[h] = v.blank? ? nil :
                   Marty::DataConversion.convert(v, (types[h] || 'text').to_sym)
      end
    end
  end

  delorean_fn :to_csv, sig: [1, 2] do |*args|
    # NOTE: can't use |data, config| due to delorean_fn weirdness.
    data, config = args

    Marty::DataExporter.to_csv(data, config)
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
marty-14.3.0 app/models/marty/helper.rb
marty-14.0.0 app/models/marty/helper.rb
marty-13.0.2 app/models/marty/helper.rb
marty-11.0.0 app/models/marty/helper.rb
marty-10.0.3 app/models/marty/helper.rb
marty-10.0.2 app/models/marty/helper.rb
marty-10.0.0 app/models/marty/helper.rb
marty-9.5.1 app/models/marty/helper.rb
marty-9.5.0 app/models/marty/helper.rb
marty-9.3.3 app/models/marty/helper.rb
marty-9.3.2 app/models/marty/helper.rb
marty-9.3.0 app/models/marty/helper.rb
marty-8.5.0 app/models/marty/helper.rb
marty-8.4.1 app/models/marty/helper.rb
marty-8.3.1 app/models/marty/helper.rb
marty-8.2.0 app/models/marty/helper.rb
marty-8.0.0 app/models/marty/helper.rb
marty-6.1.0 app/models/marty/helper.rb
marty-5.2.0 app/models/marty/helper.rb
marty-5.1.4 app/models/marty/helper.rb