Class: GraphQL::Doctor::Source::Loader
- Inherits:
-
Object
- Object
- GraphQL::Doctor::Source::Loader
- Defined in:
- lib/graphql/doctor/source/loader.rb
Instance Method Summary collapse
- #discover(paths = []) ⇒ Object
-
#initialize(root: Dir.pwd, config: Config.new, cache: true) ⇒ Loader
constructor
A new instance of Loader.
- #load(paths = [], jobs: 1) ⇒ Object
Constructor Details
#initialize(root: Dir.pwd, config: Config.new, cache: true) ⇒ Loader
Returns a new instance of Loader.
10 11 12 13 14 15 |
# File 'lib/graphql/doctor/source/loader.rb', line 10 def initialize(root: Dir.pwd, config: Config.new, cache: true) @root = File.(root) @config = config @cache = cache && Cache.new(directory: File.join(@root, ".graphql-doctor/cache")) @config_digest = Digest::SHA256.hexdigest(JSON.generate(config.values)) end |
Instance Method Details
#discover(paths = []) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/graphql/doctor/source/loader.rb', line 25 def discover(paths = []) patterns = paths.empty? ? @config["include"] : paths included = patterns.flat_map { |pattern| (pattern) }.uniq excluded = @config["exclude"].flat_map { |pattern| (pattern) } (included - excluded).select { |path| File.file?(path) && File.extname(path) == ".rb" }.sort end |