<commit_before>=begin
  Copyright 2006 <NAME>

  This file is part of Rassmalog.

  Rassmalog is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  Rassmalog is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Rassmalog; if not, write to the Free Software Foundation,
  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
=end

require 'rake/clean'
require 'config/format'
require 'yaml'
require 'ostruct'
require 'date'

require 'erb'
include ERB::Util


## project information

GENERATOR = OpenStruct.new(
  :name     => 'Rassmalog',
  :version  => '3.0.0',
  :date     => '2007-03-04',
  :url      => 'http://rassmalog.rubyforge.org'
)

class << GENERATOR
  def to_s
    name + ' ' + version
  end

  def to_link
    %{<a href="#{u url}">#{self}</a>}
  end
end


## utility logic

class DateTime
  # Returns the RFC-822 representation, which is required by RSS, of this object.
  def rfc822
    strftime "%a, %d %b %Y %H:%M:%S %Z"
  end
end

class String
  # Transforms this string into a vaild file name that can be safely used in a URL.
  # see http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
  def to_file_name
    downcase.               # it's hard to remember capitalization in URLs
    gsub(/\s+/, '-').       # remove the need for %20 escapes in URLs
    gsub(%r{[/;?#]+}, '-'). # these are parts of a URL syntax
    squeeze('-')
  end

  # Transforms this UTF-8 string into HTML entities.
  def to_html_entities
    unpack('U*').map! {|c| "&##{c};"}.join
  end
end

class ERB
  # Renders this template within a fresh object configured by the given block.
  def render_with &aBlock
    dummy = Object.new
    dummy.instance_eval(&aBlock)
    result dummy.instance_eval {binding}
  end
end

# Something that can be (hyper)linked to. Objects that mix-in this module must define a #to_s method, whose value is used when determining the URL for this object.
module Linkable
  # Returns a relative URL to this page.
  def url<commit_msg>import my ERB hack which prevents <% ... %> tags from producing output<commit_after>=begin
  Copyright 2006 <NAME>

  This file is part of Rassmalog.

  Rassmalog is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  Rassmalog is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Rassmalog; if not, write to the Free Software Foundation,
  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
=end

require 'rake/clean'
require 'config/format'
require 'yaml'
require 'ostruct'
require 'date'

require 'erb'
include ERB::Util


## project information

GENERATOR = OpenStruct.new(
  :name     => 'Rassmalog',
  :version  => '3.0.0',
  :date     => '2007-03-04',
  :url      => 'http://rassmalog.ruby<EMAIL>'
)

class << GENERATOR
  def to_s
    name + ' ' + version
  end

  def to_link
    %{<a href="#{u url}">#{self}</a>}
  end
end


## utility logic

class DateTime
  # Returns the RFC-822 representation, which is required by RSS, of this object.
  def rfc822
    strftime "%a, %d %b %Y %H:%M:%S %Z"
  end
end

class String
  # Transforms this string into a vaild file name that can be safely used in a URL.
  # see http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
  def to_file_name
    downcase.               # it's hard to remember capitalization in URLs
    gsub(/\s+/, '-').       # remove the need for %20 escapes in URLs
    gsub(%r{[/;?#]+}, '-'). # these are parts of a URL syntax
    squeeze('-')
  end

  # Transforms this UTF-8 string into HTML entities.
  def to_html_entities
    unpack('U*').map! {|c| "&##{c};"}.join
  end
end

class ERB
  alias old_initialize initialize

  # A version of ERB whose embedding tags behave like those of PHP. That is, only <%= ... %> tags produce output, whereas <% ... %> tags do *not* produce any output.
  def initialize aInput, *aArgs
    # ensure that only <%= ... %> tags generate output
      input = aInput.gsub %r{<%=.*?%>}m do |s|
        if ($' =~ /\r?\n/) == 0
          s << $&
        else
          s
        end
      end

      aArgs[1] = '>'

    old_initialize input, *aArgs
  end

  # Renders this template within a fresh object configured by the given block.
  def render_with &aBlock
    dummy = Object.new
    dummy.instance_eval(&aBlock)
    result dummy.instance_eval {binding}
  end
end

# Something that can be (hyper)linked to. Objects that mix-in this module must define a #to_s method, whose value is used when determining the URL for this object.
module Linkable
  # Returns a relative URL to this page.
  def url
{'fraction_non_alphanumeric': 0.09794776119402986, 'fraction_numerical': 0.013805970149253732, 'mean_word_length': 3.095492742551566, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, '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': '2520416', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1641, 'n_words': 692}