This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here are two Ruby programs that do exactly the same thing. One is written to be readable and maintainable, and the other is not. | |
# | |
# BAD RUBY | |
# | |
d = Hash.new([]) | |
File.foreach('scale_test_timing_log.csv') { |line| d[line.split(',')[2]] = d[line.split(',')[2]] << line.chomp.split(',')[3].to_f } | |
d.keys.sort.each { |act| File.open('a.csv', 'a') { |a| a.puts("#{act},#{((d[act].sort[((d[act].length - 1) / 2.0).floor] + d[act].sort[((d[act].length - 1) / 2.0).ceil]) / 2.0).round(1)},#{d[act].last},#{d[act].select { |elapsed_secs| elapsed_secs >= 4 }.length}") } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Documents/GitHub/classifier$ lein cloverage | |
Retrieving me/raynes/conch/0.5.0/conch-0.5.0.pom from central | |
Retrieving useful/useful/0.8.5-alpha2/useful-0.8.5-alpha2.pom from clojars | |
Retrieving spyscope/spyscope/0.1.3/spyscope-0.1.3.pom from clojars | |
Retrieving me/raynes/conch/0.5.0/conch-0.5.0.jar from central | |
Retrieving puppetlabs/certificate-authority/0.5.0/certificate-authority-0.5.0.jar from clojars | |
Retrieving spyscope/spyscope/0.1.3/spyscope-0.1.3.jar from clojars | |
Retrieving useful/useful/0.8.5-alpha2/useful-0.8.5-alpha2.jar from clojars | |
Retrieving puppetlabs/pe-rbac-service/0.1.13/pe-rbac-service-0.1.13-test.jar from releases | |
Retrieving puppetlabs/pe-rbac-service/0.1.13/pe-rbac-service-0.1.13.jar from releases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @note Instead of commenting out a test or using skip_test(), use this! | |
# | |
# Tells an assert that it's supposed to fail due to a product bug, an | |
# undelivered feature, or some similar situation. | |
# | |
# This converts failing asserts into passing asserts (so we can continue to | |
# run the test even though there are underlying product bugs), and converts | |
# passing asserts into failing asserts (so we know when the underlying product | |
# bug has been fixed). | |
# |