Class: Silhouette::Options
- Inherits:
-
Object
- Object
- Silhouette::Options
- Defined in:
- lib/silhouette/setup.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
Returns the value of attribute all.
-
#compress ⇒ Object
Returns the value of attribute compress.
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#describe ⇒ Object
Returns the value of attribute describe.
-
#file ⇒ Object
Returns the value of attribute file.
-
#follow_lines ⇒ Object
Returns the value of attribute follow_lines.
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
- #detect_compressor(file) ⇒ Object
- #import_env ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #setup_args ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
5 6 7 8 9 10 11 12 13 |
# File 'lib/silhouette/setup.rb', line 5 def initialize @compress = true @follow_lines = false @file = "silhouette.out" @coverage = false @all = false @describe = false @location = false end |
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
16 17 18 |
# File 'lib/silhouette/setup.rb', line 16 def all @all end |
#compress ⇒ Object
Returns the value of attribute compress.
15 16 17 |
# File 'lib/silhouette/setup.rb', line 15 def compress @compress end |
#coverage ⇒ Object
Returns the value of attribute coverage.
15 16 17 |
# File 'lib/silhouette/setup.rb', line 15 def coverage @coverage end |
#describe ⇒ Object
Returns the value of attribute describe.
16 17 18 |
# File 'lib/silhouette/setup.rb', line 16 def describe @describe end |
#file ⇒ Object
Returns the value of attribute file.
15 16 17 |
# File 'lib/silhouette/setup.rb', line 15 def file @file end |
#follow_lines ⇒ Object
Returns the value of attribute follow_lines.
15 16 17 |
# File 'lib/silhouette/setup.rb', line 15 def follow_lines @follow_lines end |
#location ⇒ Object
Returns the value of attribute location.
16 17 18 |
# File 'lib/silhouette/setup.rb', line 16 def location @location end |
Instance Method Details
#detect_compressor(file) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/silhouette/setup.rb', line 18 def detect_compressor(file) `which bzip2` if $?.exitstatus == 0 file.replace "#{file}.bz2" return "bzip2 -c > #{file}" end `which gzip` if $?.exitstatus == 0 file.replace "#{file}.gz" return "gzip -c > #{file}" end return nil end |
#import_env ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/silhouette/setup.rb', line 33 def import_env if ENV["SILHOUETTE_FILE"] @file = ENV["SILHOUETTE_FILE"] end if ENV["NO_COMPRESS"] @compress = false end if ENV["FOLLOW_LINES"] @follow_lines = true end if ENV["COVERAGE"] @coverage = true end if ENV["ALL"] @all = true end end |
#setup_args ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/silhouette/setup.rb', line 55 def setup_args args = [] gzip = nil output = @file unless IO === @file if @compress compress = detect_compressor(file) if compress gzip = IO.popen(compress, "w") output = gzip else # Couldn't auto detect a compressor. end end end args << output if @follow_lines args << true end if @coverage if @describe STDERR.puts "Generating coverage information only." end args << Silhouette::COVERAGE end if @all args << Silhouette::ALL end unless @location @location = @file end at_exit { Silhouette.stop_profile STDERR.puts "Flushed profile information to #{@location}" } return [args, @location] end |