Class: Danger::PluginFileResolver
- Inherits:
-
Object
- Object
- Danger::PluginFileResolver
- Defined in:
- lib/danger/plugin_support/plugin_file_resolver.rb
Instance Method Summary collapse
-
#initialize(references) ⇒ PluginFileResolver
constructor
Takes an array of files, gems or nothing, then resolves them into paths that should be sent into the documentation parser.
-
#resolve ⇒ Object
When given existing paths, map to absolute & existing paths When given a list of gems, resolve for list of gems When empty, imply you want to test the current lib folder as a plugin.
Constructor Details
#initialize(references) ⇒ PluginFileResolver
Takes an array of files, gems or nothing, then resolves them into paths that should be sent into the documentation parser
7 8 9 |
# File 'lib/danger/plugin_support/plugin_file_resolver.rb', line 7 def initialize(references) @refs = references end |
Instance Method Details
#resolve ⇒ Object
When given existing paths, map to absolute & existing paths When given a list of gems, resolve for list of gems When empty, imply you want to test the current lib folder as a plugin
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/danger/plugin_support/plugin_file_resolver.rb', line 14 def resolve if !refs.nil? and refs.select { |ref| File.file? ref }.any? paths = refs.select { |ref| File.file? ref }.map { |path| File.(path) } elsif refs and refs.kind_of? Array paths, gems = GemsResolver.new(refs).call else paths = Dir.glob(File.join(".", "lib/**/*.rb")).map { |path| File.(path) } end { paths: paths, gems: gems || [] } end |