Sha256: 0b72037e1b72e4d4725dd36f8c960f1f43c0097453f73375dbaebf4bb70d16ef
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
class IndexTableGroongaGenerator < Rails::Generator::NamedBase default_options :type => nil, :tokenizer => nil def manifest record do |m| m.migration_template 'migration.rb', 'db/groonga/migrate', :assigns => { :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}", :type => (options[:type] || :patricia_trie).inspect, :default_tokenizer_name => (options[:tokenizer] || "TokenBigram").inspect, }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" end end private def banner "Usage: #{$0} #{spec.name} index_table_name\n" + " e.g.: #{$0} #{spec.name} terms" end def add_options!(opt) opt.separator '' opt.separator 'Options:' opt.on("--type=TYPE", %w(array patricia_trie hash), "Use TYPE as a table type") do |value| options[:type] = value end opt.on("--tokenizer=TOKENIZER", %w(unigram bigram trigram mecab), "Use TOKENIZER as a default tokenizer") do |value| case value when "unigram" options[:tokenizer] = "TokenUnigram" when "bigram" options[:tokenizer] = "TokenBigram" when "trigram" options[:tokenizer] = "TokenTrigram" when "mecab" options[:tokenizer] = "TokenMacab" else options[:tokenizer] = value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activegroonga-0.0.7 | rails_generators/index_table_groonga/index_table_groonga_generator.rb |
activegroonga-0.0.6 | rails_generators/index_table_groonga/index_table_groonga_generator.rb |