Rakefile in phonetics-1.5.4 vs Rakefile in phonetics-1.8.0
- old
+ new
@@ -3,26 +3,37 @@
require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
+EXT_PATH = 'ext/c_levenshtein'
+
Rake::ExtensionTask.new('c_levenshtein') do |extension|
- extension.ext_dir = 'ext/c_levenshtein'
+ extension.ext_dir = EXT_PATH
extension.lib_dir = 'lib/phonetics'
end
-PHONETIC_COST_C_EXTENSION = File.expand_path('ext/c_levenshtein/phonetic_cost.c', __dir__)
+PHONETIC_COST_C_EXTENSION = File.join(EXT_PATH, 'phonetic_cost.c')
+NEXT_PHONEME_LENGTH_C_EXTENSION = File.join(EXT_PATH, 'next_phoneme_length.c')
-namespace :compile do
- desc 'Write phonetic_cost.c using Phonetic values'
- task :phonetic_cost do
- require_relative './lib/phonetics'
- file = File.open(PHONETIC_COST_C_EXTENSION, 'w')
- Phonetics.generate_phonetic_cost_c_code(file)
- puts "Wrote #{PHONETIC_COST_C_EXTENSION}"
- end
+require_relative './lib/phonetics/code_generator'
+
+desc 'Write phonetic_cost.c using Phonetic values'
+task PHONETIC_COST_C_EXTENSION do
+ file = File.open(PHONETIC_COST_C_EXTENSION, 'w')
+ Phonetics::CodeGenerator.new(file).generate_phonetic_cost_c_code
+ puts "Wrote #{PHONETIC_COST_C_EXTENSION}"
end
-task compile: 'compile:phonetic_cost'
+
+desc 'Write phonemes.c using a lookup table of byte arrays'
+task NEXT_PHONEME_LENGTH_C_EXTENSION do
+ file = File.open(NEXT_PHONEME_LENGTH_C_EXTENSION, 'w')
+ Phonetics::CodeGenerator.new(file).generate_next_phoneme_length_c_code
+ puts "Wrote #{NEXT_PHONEME_LENGTH_C_EXTENSION}"
+end
+
+task compile: PHONETIC_COST_C_EXTENSION
+task compile: NEXT_PHONEME_LENGTH_C_EXTENSION
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new