Commit 46f8e691 authored by Coraline Ehmke's avatar Coraline Ehmke

Better coverage.

parent 98f7377a
......@@ -15,19 +15,6 @@ module Snuffle
lexer = Rouge::Lexers::Ruby.new
end
def preprocessed
preprocessed = formatter.format(lexer.lex(summary.source))
summary.object_candidates.flatten.uniq.compact.each do |keyword|
next unless keyword.present?
begin
preprocessed.gsub!(/\b#{keyword}\b/, "<span class='highlighted'>#{keyword.gsub(/[^a-zA-Z0-9\_]/,'')}</span>")
rescue
preprocessed
end
end
preprocessed
end
def content
Haml::Engine.new(output_template).render(
Object.new, {
......
......@@ -4,7 +4,11 @@ module Snuffle
class Histogram
def self.from(arrays)
arrays.flatten.inject({}) { |h, value| h[value] ||= 0; h[value] += 1; h}
arrays.flatten.inject({}) do |h, value|
h[value] ||= 0;
h[value] += 1
h
end
end
end
......
require 'spec_helper'
describe Snuffle::Util::Histogram do
describe ".from" do
it "creates a histogram" do
arrays = [
['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd'],
['a', 'b', 'c', 'd']
]
results = Snuffle::Util::Histogram::from(arrays)
expect(results).to eq(
{
'a' => 2,
'b' => 3,
'c' => 4,
'd' => 5
}
)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment