Top Level Namespace

Defined Under Namespace

Classes: Beaver, CacheManager, Command, FileDep, FileInfo, Files, MultiFiles, SilentAll, SilentCommand, SingleFile

Instance Method Summary collapse

Instance Method Details

#all(dep) ⇒ Object

Command will be called for all files at once



85
86
87
# File 'lib/file_dep.rb', line 85

def all(dep)
  return FileDep.new dep, :all
end

#call(cmd) ⇒ Object

Call a command



95
96
97
# File 'lib/beaver.rb', line 95

def call(cmd)
  $beaver.call cmd
end

#changed?(cmd_ctx, file) ⇒ Boolean

Returns wether a file has changed Also returns true if no information about file changes is found

Returns:

  • (Boolean)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/file.rb', line 98

def changed? cmd_ctx, file
  cached_modified = $cache.files.modified cmd_ctx, file

  if cached_modified.nil?
    # probably new file
    return true
  end
  
  last_modified = File.mtime(file).to_i
  if cached_modified < last_modified
    return true
  else
    return false
  end
end

#cmd(name, deps = nil, &fn) ⇒ Object



73
74
75
76
# File 'lib/command.rb', line 73

def cmd(name, deps = nil, &fn)
  cmd = Command.new name, deps, fn
  $beaver.__appendCommand cmd
end

#each(dep) ⇒ Object

Command will be called for each file



80
81
82
# File 'lib/file_dep.rb', line 80

def each(dep)
  return FileDep.new dep, :each
end

#full_silent(strcmd) ⇒ Object

Do not print the command, or the output of the command



41
42
43
# File 'lib/sh.rb', line 41

def full_silent(strcmd)
  return SilentAll.new(strcmd)
end

#reset_cacheObject



87
88
89
90
# File 'lib/file.rb', line 87

def reset_cache
  $cache.files = Files.new(Hash.new)
  $cache.files.add("__BEAVER__CONFIG__", $PROGRAM_NAME)
end

#sh(strcmd) ⇒ Object

Execute shell command



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sh.rb', line 4

def sh(strcmd)
  unless strcmd.is_a?(SilentCommand) || strcmd.is_a?(SilentAll) then
    if $beaver.term_256_color
      puts "\u001b[38;5;246m#{strcmd}\u001b[0m"
    else
      puts "\u001b[30;1m#{strcmd}\u001b[0m"
    end
  end

  if strcmd.is_a? SilentAll
    `#{strcmd}`
  else
    puts `#{strcmd}`
  end

  if $beaver.has(:e)
    exit($?.exitstatus) if $?.exitstatus != 0
  end
end

#silent(strcmd) ⇒ Object

Do not print the command



36
37
38
# File 'lib/sh.rb', line 36

def silent(strcmd)
  return SilentCommand.new(strcmd)
end