class Cd::Examples::CrystalDir

Overview

An example class for EntryDir.dir and EntryDir.any.

class CrystalDir < Cd::EntryDir
  class SpecDir < Cd::EntryDir
    def files
      glob("**/*_spec.cr")
    end
  end

  dir "spec", SpecDir
  any "shard.yml"

  def shard
    YAML.parse(shard_yml.read)
  end

  def version
    shard["version"].to_s
  end
end

Defined in:

examples/crystal_dir.cr

Instance Method Summary

Instance methods inherited from class Cd::DirEntry

[](*args) [], []?(*args) []?, cd(*args, &) cd, cp(dst : String)
cp(dst : Cd)
cp
, create create, dir(*args) dir, each(&) each, exists? exists?, glob(*patterns, &)
glob(*patterns) : Array(AnyEntry)
glob
, path : String path, remove(recursive = false) remove, tmp(*args, &)
tmp(*args)
tmp

Class methods inherited from class Cd::DirEntry

cd(*args, &) cd, tmp(base = "/tmp", &) tmp

Instance methods inherited from module Cd::AsAnyEntry

append(text) append, basedir basedir, basename(suffix : String | Nil = nil) basename, chmod(mode : Int) chmod, cp(dst : String)
cp(dst : AsAnyEntry)
cp
, directory?(*args) directory?, dirname dirname, executable?(*args) executable?, exists? exists?, file?(*args) file?, join(*args) join, read read, real_path real_path, remove remove, symlink? symlink?, to_dir to_dir, to_s(io : IO) to_s, touch(mode : Int | Nil = nil) touch, write(text, mode : Int | Nil = nil) write

Instance Method Detail

def shard #

Parses shard.yml and returns the result YAML::Any instance.


[View source]
def shard_yml : Cd::AnyEntry #

Returns the "shard.yml" entry.

This method is automatically defined by the Cd library.


[View source]
def shard_yml? : Cd::AnyEntry | Nil #

Returns the "shard.yml" entry if exists.

This method is automatically defined by the Cd library.


[View source]
def spec : SpecDir #

Gets the "spec" directory.

This method is automatically defined by the Cd library.


[View source]
def spec(&block : SpecDir -> ) #

Changes the current directory into the "spec" directory.

This method is automatically defined by the Cd library.


[View source]
def version #

Returns a version string given by shard.yml.


[View source]