Module: Rfix::Rake::Support

Defined in:
lib/rfix/rake/support.rb

Defined Under Namespace

Classes: Utils

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rfix/rake/support.rb', line 14

def self.extended(base)
  super

  utils = Utils.new

  %i[cd sh rm_rf rm_f rm mkdir_p chdir].each do |name|
    base.define_singleton_method("_#{name}".to_sym, &utils.method(name))
  end
end

Instance Method Details

#cd(*args, &block) ⇒ Object



57
58
59
60
# File 'lib/rfix/rake/support.rb', line 57

def cd(*args, &block)
  colorize :cd, args
  _cd(*args, &block)
end

#chdir(*args, &block) ⇒ Object



42
43
44
45
# File 'lib/rfix/rake/support.rb', line 42

def chdir(*args, &block)
  colorize :cd, args
  _chdir(*args, &block)
end

#clone_and_run(&block) ⇒ Object



67
68
69
70
71
72
# File 'lib/rfix/rake/support.rb', line 67

def clone_and_run(&block)
  Dir.mktmpdir do |repo|
    sh "git clone", Bundle::Complex::FILE, repo, "--branch", "master"
    Dir.chdir(repo) { block.call(repo) }
  end
end

#directory(*args) ⇒ Object



32
33
34
# File 'lib/rfix/rake/support.rb', line 32

def directory(*args)
  mkdir_p args
end

#gemfilesObject



24
25
26
# File 'lib/rfix/rake/support.rb', line 24

def gemfiles
  Dir["Gemfile*", "ci/Gemfile*"]
end

#mkdir_p(*args) ⇒ Object



62
63
64
65
# File 'lib/rfix/rake/support.rb', line 62

def mkdir_p(*args)
  colorize :mkdir, args
  _mkdir_p(*args)
end

#rm_f(*args) ⇒ Object



52
53
54
55
# File 'lib/rfix/rake/support.rb', line 52

def rm_f(*args)
  colorize :rm, args
  _rm_f(*args)
end

#rm_rf(*args) ⇒ Object



47
48
49
50
# File 'lib/rfix/rake/support.rb', line 47

def rm_rf(*args)
  colorize :rm, args
  _rm_rf(*args)
end

#say(msg) ⇒ Object



28
29
30
# File 'lib/rfix/rake/support.rb', line 28

def say(msg)
  warn "#{'==>'.color(:blue)} #{to_relative(msg).italic}"
end

#sh(*args) ⇒ Object



36
37
38
39
40
# File 'lib/rfix/rake/support.rb', line 36

def sh(*args)
  args = args.map(&:to_s).map(&:shellsplit).flatten
  colorize args
  _sh(*args)
end