class Codestrap::Object::Standard::Files

Static file derived objects

Create objects from .json, .yaml and executable files

Public Class Methods

objects() click to toggle source
# File lib/codestrap/object/standard/files.rb, line 17
def objects
  objects = {}

  glob_array = Array(Files.dirs).map { |file| File.join(File.expand_path(file), '*') }
  Codestrap::Patch::Dir.glob_files(glob_array).each do |file|
    stat = File::Stat.new file
    name = File.basename(file, File.extname(file)).downcase
    case
      when /\.json$/.match(file)
        objects[name] = JSON.load(File.read(file))
      when /\.yaml$/.match(file)
        objects[name] = YAML.load(File.read(file))
      when stat.executable?
        objects[name] = JSON.parse(`#{file}`)
    end
  end

  objects
end
weight() click to toggle source

Object(s) weight @return [Integer]

# File lib/codestrap/object/standard/files.rb, line 13
def weight
  100
end