module Buildrake::Rush

Public Instance Methods

base_name( path ) click to toggle source
# File lib/buildrake/rush.rb, line 61
def base_name( path )
  File.basename( path )
end
changed( path, &block ) click to toggle source
# File lib/buildrake/rush.rb, line 31
def changed( path, &block )
  Dir.chdir( path, &block )
end
copy( src, dst ) click to toggle source
# File lib/buildrake/rush.rb, line 45
def copy( src, dst )
  FileUtils.cp_r( src, dst )
end
dir?( path ) click to toggle source
# File lib/buildrake/rush.rb, line 27
def dir?( path )
  Dir.exists?( path )
end
dir_path( path ) click to toggle source
# File lib/buildrake/rush.rb, line 69
def dir_path( path )
  File.dirname( path )
end
env( key, value = nil ) click to toggle source
# File lib/buildrake/rush.rb, line 84
def env( key, value = nil )
  if value.nil? && Rush.env?( key )
    value = ENV[ key ]
  else
    ENV[ key ] = value
  end
  value
end
env?( key ) click to toggle source
# File lib/buildrake/rush.rb, line 80
def env?( key )
  ENV.key?( key )
end
ext_name( path ) click to toggle source
# File lib/buildrake/rush.rb, line 65
def ext_name( path )
  File.extname( path ).gsub( /^\./, "" )
end
file?( path ) click to toggle source
# File lib/buildrake/rush.rb, line 23
def file?( path )
  File.exists?( path )
end
find( pattern, &block ) click to toggle source
# File lib/buildrake/rush.rb, line 57
def find( pattern, &block )
  Dir.glob( pattern, &block )
end
full_dir_path( path = "." ) click to toggle source
# File lib/buildrake/rush.rb, line 73
def full_dir_path( path = "." )
  Rush.changed( path ){
    path = Dir.pwd
  }
  path
end
linux?() click to toggle source
# File lib/buildrake/rush.rb, line 114
def linux?
  ( "linux" == Rush.os_type )
end
macos?() click to toggle source
# File lib/buildrake/rush.rb, line 110
def macos?
  ( "macos" == Rush.os_type )
end
maked( path, &block ) click to toggle source
# File lib/buildrake/rush.rb, line 35
def maked( path, &block )
  FileUtils.mkdir_p( path ) if ! Rush.dir?( path )
  Rush.changed( path, &block )
end
os_type() click to toggle source
# File lib/buildrake/rush.rb, line 97
def os_type
  os_type = RbConfig::CONFIG[ "host_os" ]
  case os_type
  when /darwin/
    os_type = "macos"
  when /linux/
    os_type = "linux"
  when /mingw/
    os_type = "windows"
  end
  os_type
end
pascal_case( name ) click to toggle source
# File lib/buildrake/rush.rb, line 93
def pascal_case( name )
  name.split( "_" ).map{|v| v.capitalize}.join
end
remaked( path, &block ) click to toggle source
# File lib/buildrake/rush.rb, line 40
def remaked( path, &block )
  Rush.remove( path )
  Rush.maked( path, &block )
end
remove( path ) click to toggle source
# File lib/buildrake/rush.rb, line 53
def remove( path )
  FileUtils.rm_rf( path ) if Rush.file?( path ) || Rush.dir?( path )
end
rename( src, dst ) click to toggle source
# File lib/buildrake/rush.rb, line 49
def rename( src, dst )
  FileUtils.mv( src, dst )
end
sh( command, options = {}, &block ) click to toggle source
# File lib/buildrake/rush.rb, line 7
def sh( command, options = {}, &block )
  caption = "[#{full_dir_path}] #{command}"
  puts caption
  system( command, options )
  status = $?
  if block_given?
    block.call( status )
  else
    raise "Failed(#{status.exitstatus}): #{caption}" if 0 != status.exitstatus
  end
end
which?( name ) click to toggle source
# File lib/buildrake/rush.rb, line 19
def which?( name )
  Rush.sh( "which #{name}", :out => "/dev/null", :err => "/dev/null" ){|status| return ( 0 == status )}
end
windows?() click to toggle source
# File lib/buildrake/rush.rb, line 118
def windows?
  ( "windows" == Rush.os_type )
end