SUZUKI Miho
null+****@clear*****
Tue Oct 30 14:33:36 JST 2012
SUZUKI Miho 2012-10-30 14:33:36 +0900 (Tue, 30 Oct 2012) New Revision: 824c282f41c8a7f98a1f4e43150bdc5ef147a7b1 https://github.com/logaling/logaling-command/commit/824c282f41c8a7f98a1f4e43150bdc5ef147a7b1 Merged 2e9a0db: Merge pull request #86 from logaling/add-index-interface Log: Add 'loga index' command line interface Modified files: lib/logaling/command/application.rb spec/logaling/command_spec.rb Modified: lib/logaling/command/application.rb (+11 -0) =================================================================== --- lib/logaling/command/application.rb 2012-10-30 11:22:59 +0900 (0af57d2) +++ lib/logaling/command/application.rb 2012-10-30 14:33:36 +0900 (cade1d2) @@ -52,6 +52,7 @@ module Logaling::Command '-n' => :new, '-r' => :register, '-U' => :unregister, + '-I' => :index, '-L' => :list, '-s' => :show, '-v' => :version, @@ -158,6 +159,16 @@ module Logaling::Command say "#{@config.glossary} is not yet registered." end + desc 'index', 'Index glossaries' + def index + check_logaling_home_exists + + @repository.index + say 'Complete index.' + rescue Logaling::CommandFailed => e + say e.message + end + desc 'config [KEY] [VALUE] [--global(optional)]', 'Set config.' method_option "global", type: :boolean, default: false def config(key, value) Modified: spec/logaling/command_spec.rb (+34 -0) =================================================================== --- spec/logaling/command_spec.rb 2012-10-30 11:22:59 +0900 (75ece9b) +++ spec/logaling/command_spec.rb 2012-10-30 14:33:36 +0900 (9fba53a) @@ -178,6 +178,40 @@ describe Logaling::Command::Application do end end + describe '#index' do + before do + command.options = base_options.merge("output" => "terminal", "no-pager" => true) + command.new('spec', 'en', 'ja') + end + + context 'when new term added' do + before do + command.add("spec", "スペック", "備考") + command.index + @stdout = capture(:stdout) { command.lookup("spec") } + end + + it 'should be indexed' do + @stdout.should include "spec" + @stdout.should include "スペック" + @stdout.should include "# 備考" + @stdout.should_not include "now index spec..." + end + end + + context 'when logaling_home does not exists' do + before do + command.add("spec", "スペック", "備考") + FileUtils.rm_rf(logaling_home) + @stdout = capture(:stdout) { command.index } + end + + it 'should print message and failed index' do + @stdout.should include "Input existing directory as logaling-home." + end + end + end + describe '#config' do let(:project_config) { File.join(logaling_config, 'config') } let(:global_config) { File.join(logaling_home, 'config') } -------------- next part -------------- An HTML attachment was scrubbed...Download