Class: Hoe::Debugging::ValgrindHelper
- Inherits:
-
Object
- Object
- Hoe::Debugging::ValgrindHelper
- Defined in:
- lib/hoe/debugging.rb
Constant Summary collapse
- DEFAULT_DIRECTORY_NAME =
"suppressions"
Instance Attribute Summary collapse
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
Instance Method Summary collapse
- #formatted_ruby_version ⇒ Object
-
#initialize(project_name, options = {}) ⇒ ValgrindHelper
constructor
A new instance of ValgrindHelper.
- #matching_suppression_file ⇒ Object
- #parse_suppressions_from(logfile_name) ⇒ Object
- #save_suppressions_from(logfile, options = {}) ⇒ Object
- #valgrind ⇒ Object
- #version_matches ⇒ Object
Constructor Details
#initialize(project_name, options = {}) ⇒ ValgrindHelper
Returns a new instance of ValgrindHelper.
129 130 131 132 |
# File 'lib/hoe/debugging.rb', line 129 def initialize project_name, ={} @project_name = project_name @directory = [:directory] || DEFAULT_DIRECTORY_NAME end |
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
127 128 129 |
# File 'lib/hoe/debugging.rb', line 127 def directory @directory end |
#project_name ⇒ Object
Returns the value of attribute project_name.
127 128 129 |
# File 'lib/hoe/debugging.rb', line 127 def project_name @project_name end |
Instance Method Details
#formatted_ruby_version ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/hoe/debugging.rb', line 134 def formatted_ruby_version engine = if defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Ruby Enterprise Edition/ "ree" else defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" end %Q{#{engine}-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}} end |
#matching_suppression_file ⇒ Object
182 183 184 185 186 187 188 |
# File 'lib/hoe/debugging.rb', line 182 def matching_suppression_file version_matches.each do |version_string| matches = Dir[File.join(directory, "#{project_name}_#{version_string}*.supp")] return matches[0] if matches[0] end nil end |
#parse_suppressions_from(logfile_name) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/hoe/debugging.rb', line 151 def parse_suppressions_from logfile_name suppressions = [] File.open logfile_name do |logfile| suppression = nil while ! logfile.eof? do line = logfile.readline if suppression.nil? if line =~ /\<insert_a_suppression_name_here\>/ suppression = String.new "{\n" suppression << line end else suppression << line if line =~ /^\}$/ suppressions << suppression suppression = nil end end end end suppressions.uniq.join end |
#save_suppressions_from(logfile, options = {}) ⇒ Object
174 175 176 177 178 179 180 |
# File 'lib/hoe/debugging.rb', line 174 def save_suppressions_from logfile, ={} ensure_directory_exists suppressions = parse_suppressions_from logfile filename = File.join directory, "#{project_name}_#{formatted_ruby_version}.supp" File.open(filename, "w") { |out| out.write suppressions } filename end |
#valgrind ⇒ Object
190 191 192 193 194 |
# File 'lib/hoe/debugging.rb', line 190 def valgrind # note that valgrind will generally crap out on rubies >= 2.1 # unless we increase the max stack size beyond the default "ulimit -s unlimited && valgrind" end |
#version_matches ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/hoe/debugging.rb', line 143 def version_matches matches = [formatted_ruby_version] matches << formatted_ruby_version.split(".")[0,3].join(".") matches << formatted_ruby_version.split(".")[0,2].join(".") matches << formatted_ruby_version.split(".")[0,1].join(".") matches end |