Class: Appydave::Tools::AppContext::AppQuery
- Inherits:
-
Object
- Object
- Appydave::Tools::AppContext::AppQuery
- Defined in:
- lib/appydave/tools/app_context/app_finder.rb
Overview
Queries locations.json to find app files via context.globs.json patterns.
Follows the same find/find_meta pattern as BrainQuery and OmiQuery.
Instance Method Summary collapse
-
#find ⇒ Object
Return absolute file paths matching the query.
-
#find_meta ⇒ Object
Return structured metadata about the query results.
-
#initialize(options, jump_config: nil) ⇒ AppQuery
constructor
A new instance of AppQuery.
-
#list_apps ⇒ Object
List all apps that have context.globs.json.
-
#list_globs(app_name) ⇒ Object
List all available glob names for a specific app.
Constructor Details
#initialize(options, jump_config: nil) ⇒ AppQuery
Returns a new instance of AppQuery.
12 13 14 15 |
# File 'lib/appydave/tools/app_context/app_finder.rb', line 12 def initialize(, jump_config: nil) @options = @jump_config = jump_config end |
Instance Method Details
#find ⇒ Object
Return absolute file paths matching the query
18 19 20 21 22 23 24 25 |
# File 'lib/appydave/tools/app_context/app_finder.rb', line 18 def find return [] unless @options.query? apps = resolve_apps return [] if apps.empty? apps.flat_map { |app| (app) }.uniq.sort end |
#find_meta ⇒ Object
Return structured metadata about the query results
28 29 30 31 32 33 34 35 |
# File 'lib/appydave/tools/app_context/app_finder.rb', line 28 def return [] unless @options.query? apps = resolve_apps return [] if apps.empty? apps.map { |app| (app) } end |
#list_apps ⇒ Object
List all apps that have context.globs.json
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/appydave/tools/app_context/app_finder.rb', line 49 def list_apps jump_config.locations .select { |loc| File.exist?(File.join((loc.path), 'context.globs.json')) } .map do |loc| loader = build_loader(loc) { 'key' => loc.key, 'path' => (loc.path), 'pattern' => loader.pattern, 'glob_count' => loader.globs.size } end end |
#list_globs(app_name) ⇒ Object
List all available glob names for a specific app
38 39 40 41 42 43 44 45 46 |
# File 'lib/appydave/tools/app_context/app_finder.rb', line 38 def list_globs(app_name) location = find_location(app_name) return [] unless location loader = build_loader(location) return [] unless loader.available? loader.available_names end |