Module: Eaco::Rake::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/eaco/rake/utils.rb

Overview

Assorted utilities.

Instance Method Summary collapse

Instance Method Details

#capture_stdout(&block) ⇒ String

Captures the stdout emitted by the given block

Parameters:

  • block (Proc)

Returns:

  • (String)

    the captured output


16
17
18
19
20
21
22
23
24
25
# File 'lib/eaco/rake/utils.rb', line 16

def capture_stdout(&block)
  stdout, string = $stdout, StringIO.new
  $stdout = string

  yield

  string.tap(&:rewind).read
ensure
  $stdout = stdout
end

#gemfileString

Returns the current gemfile name.

Returns:

  • (String)

    the current gemfile name


30
31
32
33
34
# File 'lib/eaco/rake/utils.rb', line 30

def gemfile
  gemfile = ENV['BUNDLE_GEMFILE']

  File.basename(gemfile, '.*') if gemfile
end