<commit_before>$: << File.join(File.dirname(__FILE__), '/../../lib')

require 'just_played'
require 'fileutils'
require 'chronic'
require 'spec/expectations'

module SnapsHelper
  def app
    @app ||= JustPlayed.new 'localhost'
  end

  def test_server
    'http://localhost:4567'
  end
  
  def snaps_from_table(t, with_timestamp = nil)
    [['station',  :title],
     ['time',     :subtitle],
     ['title',    :title],
     ['artist',   :subtitle],
     ['subtitle', :subtitle],
     ['link',     :link]].each do |before, after|
       t = t.map_headers({before => after}) if t.headers.include?(before)
    end
    
    t.hashes.map do |h|
      h[:link] = (h[:link] == 'yes') if h.keys.include?(:link)
      h[:created_at] = Chronic.parse(h[:subtitle]) if with_timestamp
      h
    end
  end
end
<commit_msg>JRuby support for Cucumber steps<commit_after>$: << File.join(File.dirname(__FILE__), '/../../lib')

require 'just_played'
require 'fileutils'
require 'chronic'
require 'spec/expectations'

module SnapsHelper
  def app
    @app ||= JustPlayed.new 'localhost'
  end

  def test_server
    'http://localhost:4567'
  end

  def snaps_from_table(t, with_timestamp = nil)
    [['station',  :title],
     ['time',     :subtitle],
     ['title',    :title],
     ['artist',   :subtitle],
     ['subtitle', :subtitle],
     ['link',     :link]].each do |before, after|
       t = t.map_headers({before => after}) if t.headers.include?(before)
    end

    t.hashes.map do |h|
      h2 = h.dup
      h2[:link] = (h2[:link] == 'yes') if h2.keys.include?(:link)
      h2[:created_at] = Chronic.parse(h2[:subtitle]) if with_timestamp
      h2
    end
  end
end

{'fraction_non_alphanumeric': 0.17208182912154033, 'fraction_numerical': 0.009025270758122744, 'mean_word_length': 2.9689737470167064, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2190706', 'n_tokens_mistral': 604, 'n_tokens_neox': 589, 'n_words': 134}