<commit_before>require 'spec_helper'
require 'time'

module Ramesh
  describe Util do
    include Ramesh::Util

    describe '#extract_filename' do
      context 'http://tokyo-ame.jwa.or.jp/map/map000.jpg' do
        it 'should return "map000.jpg"' do
          extract_filename('http://tokyo-ame.jwa.or.jp/map/map000.jpg').should == 'map000.jpg'
        end
      end

      context 'http://tokyo-ame.jwa.or.jp/map/' do
        it 'should return ""' do
          extract_filename('http://tokyo-ame.jwa.or.jp/map/').should == ''
        end
      end
    end

    describe '#get_mesh_indexes' do
      before(:all) do
        @indexes = get_mesh_indexes
      end

      context 'downloaded indexes' do
        it 'should be Array' do
          @indexes.class.should == Array
        end

        it 'should have 25 items' do
          @indexes.length.should == 25
        end

        24.times do |i|
          it "should have 5 minutes interval between indexes[#{i}] and indexes[#{i + 1}]" do
            time1 = Time.parse(@indexes[i])
            time2 = Time.parse(@indexes[i + 1])
            (time1 - time2).should == 300 #seconds
          end
        end

        it 'should be sorted decrementally' do
          @indexes.should == @indexes.sort.reverse
        end
      end
    end

    describe '#format_date_str' do
      context '201306281400' do
        it 'should return "2013-06-28 14:00"' do
          format_date_str('201306281400').should == '2013-06-28 14:00'
        end
      end

      context '20130628140' do
        it 'should return nil' do
          format_date_str('20130628140').should be_nil
        end
      end

      context '201313130000' do
        it 'should return nil' do
          format_date_str('201313130000').should be_nil
        end
      end

      context '201306282720' do
        it 'should return nil' do
          format_date_str('201306282720').should be_nil
        end
      end
    end
  end

end
<commit_msg>Add example tests the type of each index<commit_after>require 'spec_helper'
require 'time'

module Ramesh
  describe Util do
    include Ramesh::Util

    describe '#extract_filename' do
      context 'http://tokyo-ame.jwa.or.jp/map/map000.jpg' do
        it 'should return "map000.jpg"' do
          extract_filename('http://tokyo-ame.jwa.or.jp/map/map000.jpg').should == 'map000.jpg'
        end
      end

      context 'http://tokyo-ame.jwa.or.jp/map/' do
        it 'should return ""' do
          extract_filename('http://tokyo-ame.jwa.or.jp/map/').should == ''
        end
      end
    end

    describe '#get_mesh_indexes' do
      before(:all) do
        @indexes = get_mesh_indexes
      end

      context 'downloaded indexes' do
        it 'should be Array' do
          @indexes.class.should == Array
        end

        it 'should be sorted decrementally' do
          @indexes.should == @indexes.sort.reverse
        end

        it 'should have 25 items' do
          @indexes.length.should == 25
        end

        25.times do |i|
          it "indexes[#{i}] should be 12 digit number" do
            @indexes[i].should =~ /^\d{12}$/
          end
        end

        24.times do |i|
          it "should have 5 minutes interval between indexes[#{i}] and indexes[#{i + 1}]" do
            time1 = Time.parse(@indexes[i])
            time2 = Time.parse(@indexes[i + 1])
            (time1 - time2).should == 300 #seconds
          end
        end
      end
    end

    describe '#format_date_str' do
      context '201306281400' do
        it 'should return "2013-06-28 14:00"' do
          format_date_str('201306281400').should == '2013-06-28 14:00'
        end
      end

      context '20130628140' do
        it 'should return nil' do
          format_date_str('20130628140').should be_nil
        end
      end

      context '201313130000' do
        it 'should return nil' do
          format_date_str('201313130000').should be_nil
        end
      end

      context '201306282720' do
        it 'should return nil' do
          format_date_str('201306282720').should be_nil
        end
      end
    end
  end

end

{'fraction_non_alphanumeric': 0.10473876063183475, 'fraction_numerical': 0.07241798298906439, 'mean_word_length': 1.834710743801653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '739002', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1284, 'n_words': 340}