Sha256: c5bbc41fe301495dd651a3db8e0e0b3ff5f5be521a3fb26028ea83a819e9bda9
Contents?: true
Size: 894 Bytes
Versions: 1
Compression:
Stored size: 894 Bytes
Contents
module Werd class ProjectWordCounter include Contracts attr_reader :project_id, :token Contract String, String => Any def initialize token, project_id @token, @project_id = token, project_id end Contract String => ArrayOf[[String, Num]] def words counts = Hash.new 0 document.split(/\W/).select do |str| str.size > 0 end.map do |chunk| chunk.downcase end.each do |word| counts[word] += 1 end counts.to_a.sort_by(&:last).reverse end Contract None => RespondTo[:project] def client @client ||= TrackerApi::Client.new(token: token) end Contract None => Any def project client.project project_id end Contract None => String def document project.stories.map do |s| [s.name, s.description] end.flatten.join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
werd-0.0.1 | lib/werd/project_word_counter.rb |