Created
December 6, 2010 17:18
-
-
Save jdwyah/730593 to your computer and use it in GitHub Desktop.
A text editor benchmark
This file contains 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
# MavMark v 0.1 | |
######################### | |
# Indent a messed up ruby file. | |
# Goal: | |
#def excluded_description | |
# excludes_that_exist = @report.excludes.inject({}) do |memo, (dim,excludes)| | |
# swap_unrep = (@report.original_dim_labels[dim.to_sym] || []).map{|l| l.blank? ? 'Unreported' : l} | |
# memo[dim] = excludes & swap_unrep | |
# memo | |
# end | |
# dims_w_excludes = @report.all_dims.uniq.select{|dim| !excludes_that_exist[dim.value.to_s].empty? } | |
# dims_w_excludes.map do |dim| | |
# "#{dim.title}: #{excludes_that_exist[dim.value.to_s].to_sentence}" | |
# end.join('. ') | |
#end | |
def excluded_description | |
excludes_that_exist = @report.excludes.inject({}) do |memo, (dim,excludes)| | |
swap_unrep = (@report.original_dim_labels[dim.to_sym] || []).map{|l| l.blank? ? 'Unreported' : l} | |
memo[dim] = excludes & swap_unrep | |
memo | |
end | |
dims_w_excludes = @report.all_dims.uniq.select{|dim| !excludes_that_exist[dim.value.to_s].empty? } | |
dims_w_excludes.map do |dim| | |
"#{dim.title}: #{excludes_that_exist[dim.value.to_s].to_sentence}" | |
end.join('. ') | |
end | |
######################### | |
# Fix bad variable names | |
# Goal: | |
#def excluded_description | |
# excludes_that_exist = @report.excludes.inject({}) do |memo, (dim,excludes)| | |
# swap_unrep = (@report.original_dim_labels[dim.to_sym] || []).map{|l| l.blank? ? 'Unreported' : l} | |
# memo[dim] = excludes & swap_unrep | |
# memo | |
# end | |
# dims_w_excludes = @report.all_dims.uniq.select{|dim| !excludes_that_exist[dim.value.to_s].empty? } | |
# dims_w_excludes.map do |dim| | |
# "#{dim.title}: #{excludes_that_exist[dim.value.to_s].to_sentence}" | |
# end.join('. ') | |
#end | |
def excl_desc | |
exs = @report.excludes.inject({}) do |memo, (dim,x)| | |
sw = (@report.original_dim_labels[dim.to_sym] || []).map{|l| l.blank? ? 'Unreported' : l} | |
memo[dim] = x & sw | |
memo | |
end | |
dwe = @report.all_dims.uniq.select{|dim| !exs[dim.value.to_s].empty? } | |
dwe.map do |dim| | |
"#{dim.title}: #{exs[dim.value.to_s].to_sentence}" | |
end.join('. ') | |
end | |
########################## | |
# Change some arrays to hashes. | |
# Goal: | |
#a = {} | |
#a[1] = 62 | |
#a[2] = {:foo => 'bar'} | |
#a[3] = {:ball => 'baz'} | |
#a[4] = {:ball => 'baz'} | |
a = [] | |
a << [1, 62] | |
a << [2, {:foo => 'bar'}] | |
a << [3, {:ball => 'baz'}] | |
a << [4, {:ball => 'baz'}] | |
######################### | |
# Write some template code. | |
# Goal: | |
#h1 Welcome to the #{@page} page | |
#.content | |
# - @posts.each do |p| | |
# = partial "post", :post => p | |
# | |
#%aside | |
# Authors: | |
# %ul | |
# - @authors.each do |a| | |
# %li.author | |
# = link_to "#{a.first_name} #{a.last_name}", author_path(a) | |
########################## | |
# Haml-ize some erb manually. | |
# Goal: | |
#h1 Welcome to the #{@page} page | |
#.content | |
# - @posts.each do |p| | |
# = partial "post", :post => p | |
# | |
#%aside | |
# - if @authors.any? | |
# Authors: | |
# %ul | |
# - @authors.each do |a| | |
# %li.author | |
# = link_to "#{a.first_name} #{a.last_name}", author_path(a) | |
# - else | |
# No Authors | |
<h1> Welcome to the <%= @page %> page</h1> | |
<div class='content'> | |
<% @posts.each do |p| %> | |
<%= partial "post", :post => p %> | |
<% end %> | |
</div> | |
<aside> | |
<% if @authors.any? %> | |
Authors: | |
<ul> | |
<% @authors.each do |a| %> | |
<li class='author'> | |
<%= link_to "#{a.first_name} #{a.last_name}", author_path(a) %> | |
</li> | |
</ul> | |
<% else %> | |
No Authors | |
<% end %> | |
</aside> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment