logaling-command 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +18 -0
- data/README.md +5 -5
- data/bin/loga +1 -2
- data/lib/logaling/command/application.rb +383 -0
- data/lib/logaling/command/version.rb +22 -0
- data/lib/logaling/command.rb +2 -357
- data/lib/logaling/config.rb +86 -0
- data/lib/logaling/external_glossaries/freebsd_jpman.rb +38 -0
- data/lib/logaling/external_glossaries/mozilla_japan.rb +48 -0
- data/lib/logaling/glossary.rb +27 -17
- data/lib/logaling/glossary_db.rb +102 -53
- data/lib/logaling/repository.rb +8 -4
- data/logaling-command.gemspec +3 -3
- data/spec/logaling/command_spec.rb +78 -91
- data/spec/logaling/glossary_spec.rb +13 -11
- data/spec/logaling/repository_spec.rb +67 -42
- data/spec/spec_helper.rb +13 -3
- metadata +24 -19
@@ -21,26 +21,72 @@ require "fileutils"
|
|
21
21
|
module Logaling
|
22
22
|
describe Repository do
|
23
23
|
let(:project) { "spec" }
|
24
|
-
let(:
|
25
|
-
let(:
|
26
|
-
let(:
|
24
|
+
let(:logaling_home) { @logaling_home }
|
25
|
+
let(:glossary) { Glossary.new(project, 'en', 'ja', logaling_home) }
|
26
|
+
let(:glossary_path) { glossary.source_path }
|
27
|
+
let(:repository) { Logaling::Repository.new(logaling_home) }
|
28
|
+
let(:db_home) { File.join(logaling_home, "db") }
|
27
29
|
|
28
30
|
before do
|
29
|
-
FileUtils.remove_entry_secure(File.join(
|
31
|
+
FileUtils.remove_entry_secure(File.join(logaling_home, 'projects', 'spec'), true)
|
30
32
|
FileUtils.mkdir_p(File.dirname(glossary_path))
|
31
33
|
end
|
32
34
|
|
33
35
|
describe '#lookup' do
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
context 'with arguments show existing bilingual pair' do
|
37
|
+
before do
|
38
|
+
glossary.add("user-logaling", "ユーザ", "ユーザーではない")
|
39
|
+
glossary.add("user-logaling", "ユーザー", "")
|
40
|
+
File.stub!(:mtime).and_return(Time.now - 1)
|
41
|
+
repository.index
|
42
|
+
@terms = repository.lookup("user-logaling", glossary)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'succeed at find by term' do
|
46
|
+
@terms.size.should == 2
|
47
|
+
end
|
37
48
|
end
|
38
49
|
|
39
|
-
context 'with
|
40
|
-
|
50
|
+
context 'with dictionary option' do
|
51
|
+
before do
|
52
|
+
glossary.add("user", "ユーザ", "ユーザーではない")
|
53
|
+
glossary.add("user-logaling", "ユーザ", "ユーザーではない")
|
54
|
+
glossary.add("user-logaling test", "ユーザーてすと", "")
|
55
|
+
glossary.add("ゆーざ", "test user-logaling test text", "")
|
56
|
+
File.stub!(:mtime).and_return(Time.now - 1)
|
57
|
+
repository.index
|
58
|
+
@terms = repository.lookup("user-logaling", glossary, true)
|
59
|
+
@result = [{
|
60
|
+
:glossary_name=>"spec",
|
61
|
+
:source_language=>"en",
|
62
|
+
:target_language=>"ja",
|
63
|
+
:source_term=>"user-logaling",
|
64
|
+
:snipped_source_term=>["", {:keyword=>"user-logaling"}],
|
65
|
+
:target_term=>"ユーザ",
|
66
|
+
:snipped_target_term=>[],
|
67
|
+
:note=>"ユーザーではない"},
|
68
|
+
{
|
69
|
+
:glossary_name=>"spec",
|
70
|
+
:source_language=>"en",
|
71
|
+
:target_language=>"ja",
|
72
|
+
:source_term=>"user-logaling test",
|
73
|
+
:snipped_source_term=>["", {:keyword=>"user-logaling"}, " test"],
|
74
|
+
:target_term=>"ユーザーてすと",
|
75
|
+
:snipped_target_term=>[],
|
76
|
+
:note=>""},
|
77
|
+
{
|
78
|
+
:glossary_name=>"spec",
|
79
|
+
:source_language=>"en",
|
80
|
+
:target_language=>"ja",
|
81
|
+
:source_term=>"ゆーざ",
|
82
|
+
:snipped_source_term=>[],
|
83
|
+
:target_term=>"test user-logaling test text",
|
84
|
+
:snipped_target_term=>["test", {:keyword=>" user-logaling"}, " test text"],
|
85
|
+
:note=>""}]
|
86
|
+
end
|
41
87
|
|
42
88
|
it 'succeed at find by term' do
|
43
|
-
should
|
89
|
+
@terms.should == @result
|
44
90
|
end
|
45
91
|
end
|
46
92
|
|
@@ -50,14 +96,13 @@ module Logaling
|
|
50
96
|
before do
|
51
97
|
FileUtils.mkdir_p(File.dirname(tsv_path))
|
52
98
|
FileUtils.touch(tsv_path)
|
53
|
-
File.open(tsv_path, "w"){|f| f.puts "
|
99
|
+
File.open(tsv_path, "w"){|f| f.puts "test-logaling\tユーザー\ntest-logaling\tユーザ"}
|
54
100
|
repository.index
|
101
|
+
@terms = repository.lookup("test-logaling", glossary)
|
55
102
|
end
|
56
103
|
|
57
|
-
subject {repository.lookup("user", "en", "ja", project)}
|
58
|
-
|
59
104
|
it 'succeed at find by term' do
|
60
|
-
should
|
105
|
+
@terms.size.should == 2
|
61
106
|
end
|
62
107
|
|
63
108
|
after do
|
@@ -67,7 +112,6 @@ module Logaling
|
|
67
112
|
end
|
68
113
|
|
69
114
|
describe '#index' do
|
70
|
-
let(:db_home) { File.join(LOGALING_HOME, "db") }
|
71
115
|
let(:logaling_db) { Logaling::GlossaryDB.new }
|
72
116
|
let(:tsv_path) { File.join(File.dirname(glossary_path), "spec.en.ja.tsv") }
|
73
117
|
let(:csv_path) { File.join(File.dirname(glossary_path), "spec.en.ja.csv") }
|
@@ -78,12 +122,11 @@ module Logaling
|
|
78
122
|
FileUtils.touch(glossary_path)
|
79
123
|
glossary.add("spec_logaling", "スペック", "備考")
|
80
124
|
repository.index
|
125
|
+
@terms = repository.lookup("spec_logaling", glossary)
|
81
126
|
end
|
82
127
|
|
83
|
-
subject { logaling_db.open(db_home, "utf8"){|db| logaling_db.lookup("spec_logaling")} }
|
84
|
-
|
85
128
|
it 'glossaries should be indexed' do
|
86
|
-
should
|
129
|
+
@terms.size.should == 1
|
87
130
|
end
|
88
131
|
|
89
132
|
after do
|
@@ -95,14 +138,14 @@ module Logaling
|
|
95
138
|
before do
|
96
139
|
FileUtils.mkdir_p(File.dirname(glossary_path))
|
97
140
|
FileUtils.touch(tsv_path)
|
98
|
-
File.open(tsv_path, "w"){|f| f.puts "user\tユーザ"}
|
141
|
+
File.open(tsv_path, "w"){|f| f.puts "user-logaling\tユーザ"}
|
99
142
|
repository.index
|
143
|
+
@terms = repository.lookup("user-logaling", glossary)
|
100
144
|
end
|
101
145
|
|
102
|
-
subject { logaling_db.open(db_home, "utf8"){|db| logaling_db.lookup("user")} }
|
103
146
|
|
104
147
|
it 'glossaries should be indexed' do
|
105
|
-
should
|
148
|
+
@terms.size.should == 1
|
106
149
|
end
|
107
150
|
|
108
151
|
after do
|
@@ -116,12 +159,11 @@ module Logaling
|
|
116
159
|
FileUtils.touch(csv_path)
|
117
160
|
File.open(csv_path, "w"){|f| f.puts "test_logaling,テスト"}
|
118
161
|
repository.index
|
162
|
+
@terms = repository.lookup("test_logaling", glossary)
|
119
163
|
end
|
120
164
|
|
121
|
-
subject { logaling_db.open(db_home, "utf8"){|db| logaling_db.lookup("test_logaling")} }
|
122
|
-
|
123
165
|
it 'glossaries should be indexed' do
|
124
|
-
should
|
166
|
+
@terms.size.should == 1
|
125
167
|
end
|
126
168
|
|
127
169
|
after do
|
@@ -130,25 +172,8 @@ module Logaling
|
|
130
172
|
end
|
131
173
|
end
|
132
174
|
|
133
|
-
context 'when glossary exist but not modified' do
|
134
|
-
let(:index_at) { File.join(LOGALING_HOME, 'db', 'index_at') }
|
135
|
-
before do
|
136
|
-
glossary.add("index_test", "インデックスのテスト", "備考")
|
137
|
-
repository.index
|
138
|
-
@timestamp = File.mtime(index_at)
|
139
|
-
sleep(1)
|
140
|
-
repository.index
|
141
|
-
end
|
142
|
-
|
143
|
-
subject { File.mtime(index_at) }
|
144
|
-
|
145
|
-
it 'should not be indexed' do
|
146
|
-
should == @timestamp
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
175
|
after do
|
151
|
-
FileUtils.remove_entry_secure(File.join(
|
176
|
+
FileUtils.remove_entry_secure(File.join(logaling_home, 'projects', 'spec'), true)
|
152
177
|
end
|
153
178
|
end
|
154
179
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,10 +17,9 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
|
17
17
|
require 'logaling'
|
18
18
|
|
19
19
|
require "fileutils"
|
20
|
+
require 'tmpdir'
|
20
21
|
require 'stringio'
|
21
22
|
|
22
|
-
LOGALING_HOME = File.expand_path("~/.logaling.d")
|
23
|
-
|
24
23
|
RSpec.configure do |config|
|
25
24
|
def capture(stream)
|
26
25
|
begin
|
@@ -35,6 +34,17 @@ RSpec.configure do |config|
|
|
35
34
|
result
|
36
35
|
end
|
37
36
|
|
37
|
+
config.before(:suite) do
|
38
|
+
LOGALING_HOME = Dir.mktmpdir
|
39
|
+
end
|
40
|
+
|
41
|
+
config.before(:all) do
|
42
|
+
@logaling_home = LOGALING_HOME
|
43
|
+
end
|
44
|
+
|
45
|
+
config.after(:suite) do
|
46
|
+
FileUtils.remove_entry_secure(LOGALING_HOME, true)
|
47
|
+
end
|
48
|
+
|
38
49
|
alias :silence :capture
|
39
50
|
end
|
40
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logaling-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,11 +13,11 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-
|
16
|
+
date: 2012-02-29 00:00:00.000000000Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: thor
|
20
|
-
requirement: &
|
20
|
+
requirement: &2154467460 !ruby/object:Gem::Requirement
|
21
21
|
none: false
|
22
22
|
requirements:
|
23
23
|
- - ! '>='
|
@@ -25,10 +25,10 @@ dependencies:
|
|
25
25
|
version: 0.14.6
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
|
-
version_requirements: *
|
28
|
+
version_requirements: *2154467460
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
|
-
requirement: &
|
31
|
+
requirement: &2154466980 !ruby/object:Gem::Requirement
|
32
32
|
none: false
|
33
33
|
requirements:
|
34
34
|
- - ! '>='
|
@@ -36,10 +36,10 @@ dependencies:
|
|
36
36
|
version: '1.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
|
-
version_requirements: *
|
39
|
+
version_requirements: *2154466980
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rroonga
|
42
|
-
requirement: &
|
42
|
+
requirement: &2154466500 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
@@ -47,10 +47,10 @@ dependencies:
|
|
47
47
|
version: 1.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
|
-
version_requirements: *
|
50
|
+
version_requirements: *2154466500
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rainbow
|
53
|
-
requirement: &
|
53
|
+
requirement: &2154466120 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
56
56
|
- - ! '>='
|
@@ -58,10 +58,10 @@ dependencies:
|
|
58
58
|
version: '0'
|
59
59
|
type: :runtime
|
60
60
|
prerelease: false
|
61
|
-
version_requirements: *
|
61
|
+
version_requirements: *2154466120
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: nokogiri
|
64
|
-
requirement: &
|
64
|
+
requirement: &2154465660 !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ! '>='
|
@@ -69,10 +69,10 @@ dependencies:
|
|
69
69
|
version: '0'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
|
-
version_requirements: *
|
72
|
+
version_requirements: *2154465660
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
75
|
-
requirement: &
|
74
|
+
name: activesupport
|
75
|
+
requirement: &2154465240 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
78
78
|
- - ! '>='
|
@@ -80,10 +80,10 @@ dependencies:
|
|
80
80
|
version: '0'
|
81
81
|
type: :runtime
|
82
82
|
prerelease: false
|
83
|
-
version_requirements: *
|
83
|
+
version_requirements: *2154465240
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rake
|
86
|
-
requirement: &
|
86
|
+
requirement: &2156056340 !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
89
89
|
- - ! '>='
|
@@ -91,10 +91,10 @@ dependencies:
|
|
91
91
|
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
|
-
version_requirements: *
|
94
|
+
version_requirements: *2156056340
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rspec
|
97
|
-
requirement: &
|
97
|
+
requirement: &2156055920 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ! '>='
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
version: '0'
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
|
-
version_requirements: *
|
105
|
+
version_requirements: *2156055920
|
106
106
|
description: A command line interface for logaling.
|
107
107
|
email:
|
108
108
|
- koji.shimada@enishi-tech.com
|
@@ -125,10 +125,15 @@ files:
|
|
125
125
|
- bin/loga
|
126
126
|
- lib/logaling.rb
|
127
127
|
- lib/logaling/command.rb
|
128
|
+
- lib/logaling/command/application.rb
|
129
|
+
- lib/logaling/command/version.rb
|
130
|
+
- lib/logaling/config.rb
|
128
131
|
- lib/logaling/external_glossaries/debian_project.rb
|
129
132
|
- lib/logaling/external_glossaries/edict.rb
|
133
|
+
- lib/logaling/external_glossaries/freebsd_jpman.rb
|
130
134
|
- lib/logaling/external_glossaries/gene95.rb
|
131
135
|
- lib/logaling/external_glossaries/gnome_project.rb
|
136
|
+
- lib/logaling/external_glossaries/mozilla_japan.rb
|
132
137
|
- lib/logaling/external_glossaries/postgresql_manual.rb
|
133
138
|
- lib/logaling/external_glossary.rb
|
134
139
|
- lib/logaling/glossary.rb
|