Class: SudachiInstaller::Resolver
- Inherits:
-
Object
- Object
- SudachiInstaller::Resolver
show all
- Includes:
- SudachiInstaller
- Defined in:
- lib/sudachi-installer/resolver.rb
Overview
Defined Under Namespace
Classes: DictionaryNotDownloaded, ExecutableVersionNotDownloaded
Constant Summary
VERSION
Instance Method Summary
collapse
Instance Method Details
#dict_dir ⇒ String
23
24
25
|
# File 'lib/sudachi-installer/resolver.rb', line 23
def dict_dir
self.class.ancestors[1].config.dict_dir
end
|
#dict_path(revision:, edition: "core") ⇒ String
68
69
70
71
72
73
74
75
76
|
# File 'lib/sudachi-installer/resolver.rb', line 68
def dict_path(revision:, edition: "core")
dir = dictionaries.find { |e| e == "sudachi-dictionary-#{revision}" }
if dir
File.join(dict_dir, dir, "system_#{edition}.dic")
else
raise DictionaryNotDownloaded.new({revision: revision, edition: edition}.to_s)
end
end
|
#dictionaries ⇒ Array
55
56
57
58
59
60
61
|
# File 'lib/sudachi-installer/resolver.rb', line 55
def dictionaries
Dir.chdir(dict_dir) {
Dir.glob("sudachi-dictionary-*").select { |f|
FileTest.directory? f
}
}
end
|
#executable_jars ⇒ Array
30
31
32
33
34
35
36
|
# File 'lib/sudachi-installer/resolver.rb', line 30
def executable_jars
Dir.chdir(jar_dir) {
Dir.glob("sudachi-*-executable").select { |f|
FileTest.directory? f
}
}
end
|
#jar_dir ⇒ string
16
17
18
|
# File 'lib/sudachi-installer/resolver.rb', line 16
def jar_dir
self.class.ancestors[1].config.jar_dir
end
|
#jar_path(revision) ⇒ String
42
43
44
45
46
47
48
49
50
|
# File 'lib/sudachi-installer/resolver.rb', line 42
def jar_path(revision)
dir = executable_jars.find { |e| e == "sudachi-#{revision}-executable" }
if dir
File.join(jar_dir, dir, "sudachi-#{revision}.jar")
else
raise ExecutableVersionNotDownloaded.new(dir)
end
end
|