Top Level Namespace
Defined Under Namespace
Classes: Fsorg
Constant Summary collapse
- PERMISSIONS_PATTERN =
/[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+/
Instance Method Summary collapse
Instance Method Details
#capture_output ⇒ Object
455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/fsorg.rb', line 455 def capture_output old_stdout = $stdout old_stderr = $stderr $stdout = StringIO.new $stderr = StringIO.new yield return $stdout.string, $stderr.string ensure $stdout = old_stdout $stderr = old_stderr end |
#d(thing) ⇒ Object
8 9 10 11 |
# File 'lib/fsorg.rb', line 8 def d(thing) p thing return thing end |
#deindent(text) ⇒ Object
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/fsorg.rb', line 438 def deindent(text) using_tabs = text.lines(chomp: true).any? { |line| /^\t/ =~ line } indenting_with = using_tabs ? "\t" : " " depth = text.lines.map do |line| count = 0 until line[count] != indenting_with count += 1 end count end.min pattern = /^#{using_tabs ? '\t' : " "}{#{depth}}/ text.lines(chomp: true).map do |line| line.sub pattern, "" end.join "\n" end |