Class: Polyspec::RunnerFactory
- Inherits:
-
Object
- Object
- Polyspec::RunnerFactory
- Defined in:
- lib/polyspec/runner_factory.rb
Constant Summary collapse
- PROJECT_TYPE_MATCHERS =
{ DjangoProjectRunner => ->(project_files) { project_files.any? {|f| next if File.extname(f) == '.pyc'; File.read(f).match(/django/i) } }, GolangProjectRunner => ->(project_files) { project_files.any? {|f| File.extname(f) == '.go' } }, }
Instance Attribute Summary collapse
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(project_path) ⇒ RunnerFactory
constructor
A new instance of RunnerFactory.
Constructor Details
#initialize(project_path) ⇒ RunnerFactory
Returns a new instance of RunnerFactory.
6 7 8 |
# File 'lib/polyspec/runner_factory.rb', line 6 def initialize(project_path) @project_path = project_path end |
Instance Attribute Details
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
5 6 7 |
# File 'lib/polyspec/runner_factory.rb', line 5 def project_path @project_path end |
Instance Method Details
#get ⇒ Object
15 16 17 18 |
# File 'lib/polyspec/runner_factory.rb', line 15 def get project_files = Find.find(project_path).select {|f| File.file?(f) } PROJECT_TYPE_MATCHERS.find {|runner, matcher| matcher.call(project_files) }.first end |