File: Rakefile

package info (click to toggle)
ruby-did-you-mean 1.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: ruby: 2,701; makefile: 7
file content (80 lines) | stat: -rw-r--r-- 2,402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new do |task|
  task.libs << "test/lib" << "test"

  task.test_files = Dir['test/**/test_*.rb'].reject {|path| path.end_with?("test_explore.rb") }
  task.verbose    = true
  task.warning    = true
  task.ruby_opts  = %w[ --disable-did_you_mean -rhelper ]
end

Rake::TestTask.new("test:explore") do |task|
  task.libs << "test"

  task.pattern   = 'test/tree_spell/test_explore.rb'
  task.verbose   = true
  task.warning   = true
  task.ruby_opts = %w[ --disable-did_you_mean ]
end

task default: %i(test)

task :sync_tool do
  require 'fileutils'
  FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
  FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
  FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
end

namespace :test do
  namespace :accuracy do
    desc "Download Wiktionary's Simple English data and save it as a dictionary"
    task :prepare do
      sh "RUBYOPT='--disable-did_you_mean' ruby evaluation/dictionary_generator.rb"
    end
  end

  desc "Calculate accuracy of the gem's spell checker"
  task :accuracy do
    if !File.exist?("evaluation/dictionary.yml")
      puts 'Generating dictionary for evaluation:'
      Rake::Task["test:accuracy:prepare"].execute
      puts "\n"
    end

    sh "RUBYOPT='--disable-did_you_mean' ruby evaluation/calculator.rb"
  end
end

namespace :benchmark do
  namespace :ips do
    desc "Measure performance of the gem's Jaro distance implementation"
    task :jaro do
      sh "RUBYOPT='--disable-did_you_mean' ruby benchmark/jaro_winkler/speed.rb"
    end

    desc "Benchmark performance of the gem's Levenshtein distance implementation"
    task :levenshtein do
      sh "RUBYOPT='--disable-did_you_mean' ruby benchmark/levenshtein/speed.rb"
    end
  end

  desc "Benchmark memory usage in the gem's spell checker"
  task :memory do
    sh "RUBYOPT='--disable-did_you_mean' ruby benchmark/memory_usage.rb"
  end

  namespace :memory do
    desc "Benchmark memory usage in the gem's Jaro distance implementation"
    task :jaro do
      sh "RUBYOPT='--disable-did_you_mean' ruby benchmark/jaro_winkler/memory_usage.rb"
    end

    desc "Benchmark memory usage in the gem's Levenshtein distance implementation"
    task :levenshtein do
      sh "RUBYOPT='--disable-did_you_mean' ruby benchmark/levenshtein/memory_usage.rb"
    end
  end
end