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/collection.rb,
lib/yerba/formatting.rb,
ext/yerba/yerba.c
Defined Under Namespace
Modules: Formatting
Classes: Collection, CompilationError, Document, Error, ExecutableNotFoundError, Location, Map, ParseError, PathNotFoundError, PathValidationError, Scalar, Sequence, UnsupportedPlatformError
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",
"arm64-linux" => "aarch64-linux",
"x86_64-linux" => "x86_64-linux",
}.freeze
- VERSION =
"0.3.0"
Class Method Summary
collapse
Class Method Details
.document(path) ⇒ Object
131
132
133
|
# File 'lib/yerba.rb', line 131
def self.document(path)
Document.new(path)
end
|
.executable(exe_path: nil) ⇒ Object
41
42
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
|
# File 'lib/yerba.rb', line 41
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
135
136
137
|
# File 'lib/yerba.rb', line 135
def self.files(glob)
Collection.new(glob)
end
|
.parse(content) ⇒ Object
123
124
125
|
# File 'lib/yerba.rb', line 123
def self.parse(content)
Document.parse(content)
end
|
.parse_file(path) ⇒ Object
127
128
129
|
# File 'lib/yerba.rb', line 127
def self.parse_file(path)
Document.new(path)
end
|