Module: Yerba
- Defined in:
- lib/yerba.rb,
lib/yerba/map.rb,
lib/yerba/scalar.rb,
lib/yerba/version.rb,
lib/yerba/document.rb,
lib/yerba/location.rb,
lib/yerba/sequence.rb,
lib/yerba/yerbafile.rb,
lib/yerba/collection.rb,
lib/yerba/formatting.rb,
lib/yerba/query_result.rb,
ext/yerba/yerba.c
Defined Under Namespace
Modules: Formatting
Classes: Collection, CompilationError, Document, Error, ExecutableNotFoundError, Location, Map, ParseError, PathNotFoundError, PathValidationError, QueryResult, Scalar, Sequence, UnsupportedPlatformError, Yerbafile
Constant Summary
collapse
- GEM_NAME =
"yerba"
- EXECUTABLE_NAME =
"yerba"
- NATIVE_PLATFORMS =
{
"arm64-darwin" => "arm64-darwin",
"x86_64-darwin" => "x86_64-darwin",
"aarch64-linux" => "aarch64-linux-gnu",
"arm64-linux" => "aarch64-linux-gnu",
"x86_64-linux" => "x86_64-linux-gnu",
}.freeze
- VERSION =
"0.4.2"
Class Method Summary
collapse
Class Method Details
.document(path) ⇒ Object
137
138
139
|
# File 'lib/yerba.rb', line 137
def self.document(path)
Document.new(path)
end
|
.executable(exe_path: nil) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/yerba.rb', line 43
def self.executable(exe_path: nil)
if exe_path
return exe_path if File.executable?(exe_path)
raise ExecutableNotFoundError, "yerba executable not found at #{exe_path}"
end
if ENV["YERBA_INSTALL_DIR"]
install_dir_exe = File.join(ENV["YERBA_INSTALL_DIR"], EXECUTABLE_NAME)
if File.executable?(install_dir_exe)
return install_dir_exe
end
raise ExecutableNotFoundError, "yerba executable not found at #{install_dir_exe} (set by YERBA_INSTALL_DIR)"
end
platform = Gem::Platform.local
platform_key = "#{platform.cpu}-#{platform.os}"
exe_directory = NATIVE_PLATFORMS[platform_key]
if exe_directory
exe_file = File.expand_path(
File.join("..", "exe", exe_directory, EXECUTABLE_NAME),
__dir__
)
return exe_file if File.executable?(exe_file)
end
compiled = compile_from_source
return compiled if compiled
if exe_directory
raise ExecutableNotFoundError,
"yerba executable not found at exe/#{exe_directory}/yerba. " \
"Try reinstalling the gem: gem install yerba"
else
raise UnsupportedPlatformError,
"yerba does not have a precompiled binary for #{platform_key}. " \
"Install Rust (https://rustup.rs) and reinstall the gem to compile from source, " \
"or set YERBA_INSTALL_DIR to use a custom binary."
end
end
|
.files(glob) ⇒ Object
141
142
143
|
# File 'lib/yerba.rb', line 141
def self.files(glob)
Collection.new(glob)
end
|
.parse(content) ⇒ Object
129
130
131
|
# File 'lib/yerba.rb', line 129
def self.parse(content)
Document.parse(content)
end
|
.parse_file(path) ⇒ Object
133
134
135
|
# File 'lib/yerba.rb', line 133
def self.parse_file(path)
Document.new(path)
end
|