<commit_before>require 'lock_block/version'
require 'ripper'
require 'digest/sha1'

module LockBlock
  def lock_tag source
    tokens = Ripper.tokenize(source).select do |t|
      t.gsub(/\s+/, "") != ''
    end
    Digest::SHA1.hexdigest tokens.to_s
  end

  def decorate source
    indent = source.match(/^(\s+)/)[0] || ""
    h = indent + lock_tag(source)
    "# lock do #{h}\n#{source}# lock end #{h}"
  end
end<commit_msg>Indent tag decoration to match input source<commit_after>require 'lock_block/version'
require 'ripper'
require 'digest/sha1'

module LockBlock
  def lock_tag source
    tokens = Ripper.tokenize(source).select do |t|
      t.gsub(/\s+/, "") != ''
    end
    Digest::SHA1.hexdigest tokens.to_s
  end

  def decorate source
    indent = source.match(/^(\s+)/) ? $1 : ''
    h = lock_tag(source)
    "#{indent}# lock do #{h}\n#{source}#{indent}# lock end #{h}"
  end
end
{'fraction_non_alphanumeric': 0.16331096196868009, 'fraction_numerical': 0.006711409395973154, 'mean_word_length': 3.323671497584541, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2923898', 'n_tokens_mistral': 327, 'n_tokens_neox': 324, 'n_words': 78}