Module: Sqlpkg
- Defined in:
- lib/sqlpkg.rb,
lib/sqlpkg/railtie.rb,
lib/sqlpkg/version.rb,
lib/sqlpkg/commands.rb,
lib/sqlpkg/upstream.rb,
lib/sqlpkg/generators/sqlpkg/install_generator.rb
Defined Under Namespace
Modules: Commands, Generators, Upstream Classes: Railtie
Constant Summary collapse
- DIR =
".sqlpkg"- FILE_PATTERN =
"*.{dylib,so,dll}"- Error =
Class.new(StandardError)
- ExtensionNotInstalledError =
Class.new(Error)
- VERSION =
"0.3.0"
Class Method Summary collapse
-
.file_dir ⇒ Object
The directory where
sqlpkgstores installed extensions => “#Rails.root/.sqlpkg” or “./.sqlpkg”. -
.installed_extension_paths ⇒ Object
List of file paths for all installed extensions => [“./.sqlpkg/asg017/ulid/ulid0.dylib”, “./.sqlpkg/nalgeon/uuid/uuid.dylib”].
-
.path_for(identifier) ⇒ Object
(also: [])
File path for identified extension => “./.sqlpkg/nalgeon/uuid/uuid.dylib”.
Class Method Details
.file_dir ⇒ Object
The directory where sqlpkg stores installed extensions
> “#Rails.root/.sqlpkg” or “./.sqlpkg”
23 24 25 26 27 28 29 |
# File 'lib/sqlpkg.rb', line 23 def file_dir if defined?(Rails) && Rails.respond_to?(:root) && Dir.exist?(Rails.root.join(DIR)) Rails.root.join(DIR) else File.join(__dir__, DIR) end end |
.installed_extension_paths ⇒ Object
List of file paths for all installed extensions
> [“./.sqlpkg/asg017/ulid/ulid0.dylib”, “./.sqlpkg/nalgeon/uuid/uuid.dylib”]
33 34 35 |
# File 'lib/sqlpkg.rb', line 33 def installed_extension_paths Dir.glob File.join(file_dir, "**", FILE_PATTERN) end |
.path_for(identifier) ⇒ Object Also known as: []
File path for identified extension
> “./.sqlpkg/nalgeon/uuid/uuid.dylib”
13 14 15 16 17 18 |
# File 'lib/sqlpkg.rb', line 13 def path_for(identifier) path_glob = File.join(file_dir, identifier, FILE_PATTERN) path = Dir.glob(path_glob).first path || raise(ExtensionNotInstalledError, "No extension found for identifier: #{identifier}") end |