class BBFlow::Misc
Public Class Methods
edit(text = '')
click to toggle source
@param [String] text
@return [String]
# File lib/bb_flow/misc.rb, line 31 def edit(text = '') file = Tempfile.new(%w(bb-flow .md)) file.write(text) file.flush system(*[*Misc.editor, file.path]) File.read(file.path) ensure file.close file.unlink end
editor()
click to toggle source
# File lib/bb_flow/misc.rb, line 52 def editor [`git config --global core.editor`.chomp.split(/\s+/), ['vi']].reject(&:empty?).first end
execute(*args)
click to toggle source
@param [Array<Object>] args
@return [String]
# File lib/bb_flow/misc.rb, line 24 def execute(*args) Open3.popen3(*args) { |_i, o| return o.read } end
git()
click to toggle source
# File lib/bb_flow/misc.rb, line 45 def git Git.open(Dir.pwd) rescue ArgumentError Printer.panic("This directory (#{__dir__}) is not a git repository.") end
open_url(url)
click to toggle source
@param [String] url
@return [void]
# File lib/bb_flow/misc.rb, line 11 def open_url(url) if Gem::Platform.local.os == 'darwin' execute("open #{url}") else # FIXME: I'm not sure what's the proper way to open URLs on either Linux # or Windows. If it's important for you, don't hesitate to edit. puts(url) end end
pluralize(word, count)
click to toggle source
@param [String] word @param [Fixnum] count
@return [String]
# File lib/bb_flow/misc.rb, line 60 def pluralize(word, count) count == 1 ? word : word + 's' end