Module: Contentful::Bootstrap::Support

Defined in:
lib/contentful/bootstrap/support.rb

Class Method Summary collapse

Class Method Details

.camel_case(a_string) ⇒ Object



6
7
8
# File 'lib/contentful/bootstrap/support.rb', line 6

def self.camel_case(a_string)
  a_string.split('_').each_with_object([]) { |e, a| a.push(a.empty? ? e : e.capitalize) }.join
end

.input(prompt_text, no_input = false) {|answer| ... } ⇒ Object

Yields:

  • (answer)


27
28
29
30
31
32
33
# File 'lib/contentful/bootstrap/support.rb', line 27

def self.input(prompt_text, no_input = false)
  return if no_input

  print prompt_text
  answer = gets.chomp
  yield answer if block_given?
end

.output(text = nil, quiet = false) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/contentful/bootstrap/support.rb', line 18

def self.output(text = nil, quiet = false)
  if text.nil?
    puts unless quiet
    return
  end

  puts text unless quiet
end

.silence_stderrObject



10
11
12
13
14
15
16
# File 'lib/contentful/bootstrap/support.rb', line 10

def self.silence_stderr
  old_stderr = $stderr
  $stderr = StringIO.new
  yield
ensure
  $stderr = old_stderr
end