<commit_before>require 'spec_helper'

describe Vines::Storage::Sql do
  include StorageSpecs

  DB_FILE = "./xmpp_testcase.db"
  ActiveRecord::Migration.verbose = false

  before do
    storage.create_schema(:force => true)
    Vines::Storage::Sql::User.new(:jid => '<EMAIL>', :name => '', :password => '').save
    Vines::Storage::Sql::User.new(:jid => '<EMAIL>', :name => '', :password => '').save
    Vines::Storage::Sql::User.new(:jid => '<EMAIL>', :name => '',
      :password => '<PASSWORD>').save
    Vines::Storage::Sql::User.new(:jid => '<EMAIL>', :name => '',
      :password => <PASSWORD>('<PASSWORD>')).save
    groups = %w[Group1 Group2 Group3 Group4].map do |name|
      Vines::Storage::Sql::Group.find_or_create_by_name(name)
    end
    full = Vines::Storage::Sql::User.new(
      :jid => '<EMAIL>',
      :name => 'Tester',
      :password => <PASSWORD>('<PASSWORD>'),
      :vcard => vcard.to_xml)
    full.contacts << Vines::Storage::Sql::Contact.new(
      :jid => '<EMAIL>',
      :name => 'Contact1',
      :groups => groups[0, 2],
      :subscription => 'both')
    full.contacts << Vines::Storage::Sql::Contact.new(
      :jid => '<EMAIL>',
      :name => 'Contact2',
      :groups => groups[2, 2],
      :subscription => 'both')
    full.save

    partial = Vines::Storage::Sql::Fragment.new(
      :user => full,
      :root => 'characters',
      :namespace => 'urn:wonderland',
      :xml => fragment.to_xml)
    partial.save
  end

  after do
    File.delete(DB_FILE) if File.exist?(DB_FILE)
  end

  def storage
    Vines::Storage::Sql.new { adapter 'sqlite3'; database DB_FILE }<commit_msg>Less syntax.<commit_after>require 'spec_helper'

describe Vines::Storage::Sql do
  include StorageSpecs

  DB_FILE = "./xmpp_testcase.db"
  ActiveRecord::Migration.verbose = false

  before do
    storage.create_schema(force: true)
    Vines::Storage::Sql::User.new(jid: '<EMAIL>', name: '', password: '').save
    Vines::Storage::Sql::User.new(jid: '<EMAIL>', name: '', password: '').save
    Vines::Storage::Sql::User.new(jid: '<EMAIL>', name: '', password: '<PASSWORD>').save
    Vines::Storage::Sql::User.new(jid: '<EMAIL>', name: '',
      password: <PASSWORD>('<PASSWORD>')).save
    groups = %w[Group1 Group2 Group3 Group4].map do |name|
      Vines::Storage::Sql::Group.find_or_create_by_name(name)
    end
    full = Vines::Storage::Sql::User.new(
      jid: '<EMAIL>',
      name: 'Tester',
      password: <PASSWORD>('<PASSWORD>'),
      vcard: vcard.to_xml)
    full.contacts << Vines::Storage::Sql::Contact.new(
      jid: '<EMAIL>',
      name: 'Contact1',
      groups: groups[0, 2],
      subscription: 'both')
    full.contacts << Vines::Storage::Sql::Contact.new(
      jid: '<EMAIL>',
      name: 'Contact2',
      groups: groups[2, 2],
      subscription: 'both')
    full.save

    partial = Vines::Storage::Sql::Fragment.new(
      user: full,
      root: 'characters',
      namespace: 'urn:wonderland',
      xml: fragment.to_xml)
    partial.save
  end

  after do
    File.delete(DB_FILE) if File.exist?(DB_FILE)
  end

  def storage
    Vines::Storage::Sql.new { adapter 'sqlite3'; database DB_FILE }
{'fraction_non_alphanumeric': 0.19218551461245234, 'fraction_numerical': 0.00698856416772554, 'mean_word_length': 3.4857549857549857, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2099108', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1089, 'n_words': 205}