From 73e1e7b9daad911bd3b96d7efac9c426bebc7356 Mon Sep 17 00:00:00 2001 From: Oliver Kennedy Date: Fri, 27 Apr 2018 20:47:45 -0400 Subject: [PATCH] debugging --- lib/pipeline.rb | 2 ++ lib/util.rb | 4 ++-- src/grants/index.erb | 2 +- src/papers/index.erb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pipeline.rb b/lib/pipeline.rb index 8c6c101f..7f88fe08 100644 --- a/lib/pipeline.rb +++ b/lib/pipeline.rb @@ -1,3 +1,5 @@ +require "stringio" + class Pipeline def initialize(source) diff --git a/lib/util.rb b/lib/util.rb index e980e1bd..f9666761 100644 --- a/lib/util.rb +++ b/lib/util.rb @@ -118,7 +118,7 @@ class Array Math.sqrt((avg ** 2 - (map{|i| i.to_f ** 2}.avg)).abs) end - def my_reduce(&reducer) + def reduce(&reducer) ret = Hash.new; each do |k,v| ret[k] = Array.new unless ret.has_key? k; @@ -289,7 +289,7 @@ class Array map { |x| [x, 0] }. to_h. join(map { |x| (x.to_f / bin_width).to_i * bin_width }. - my_reduce { |k,v| v.count }, + reduce { |k,v| v.count }, :left ). map { |bin, cnt| [bin, cnt.compact.sum] }. diff --git a/src/grants/index.erb b/src/grants/index.erb index 69fa43bb..c1c4471b 100644 --- a/src/grants/index.erb +++ b/src/grants/index.erb @@ -8,7 +8,7 @@ title: Funding Sources <% $db["cv/okennedy/grants"]. where { |grant| ["accepted", "completed"].include? grant["status"] }. map { |grant| [grant["start"].split(/\//)[-1].to_i, grant] }. - my_reduce. + reduce. sort_by { |x| -x[0] }. each do |year, grants| %>

<%=year%>

diff --git a/src/papers/index.erb b/src/papers/index.erb index e5c71e85..354bc0c3 100644 --- a/src/papers/index.erb +++ b/src/papers/index.erb @@ -4,7 +4,7 @@ title: Publications
 
- <% $db["publications"].map { |pub| [pub["year"].to_i, pub] }.my_reduce.each do |year, pubs| %> + <% $db["publications"].map { |pub| [pub["year"].to_i, pub] }.reduce.each do |year, pubs| %>

<%= year %>