Module: FrameworkIdentificator

Defined in:
lib/framework_identificator.rb,
lib/framework_identificator/version.rb,
lib/framework_identificator/framework.rb,
lib/framework_identificator/testing_frameworks.rb,
lib/framework_identificator/application_frameworks.rb,
lib/framework_identificator/testing_frameworks/rspec.rb,
lib/framework_identificator/testing_frameworks/cucumber.rb,
lib/framework_identificator/application_frameworks/rails.rb

Defined Under Namespace

Modules: ApplicationFrameworks, Framework, TestingFrameworks

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Class Method Details

.from(source) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/framework_identificator.rb', line 12

def self.from(source)
  raise ArgumentError unless ["String", "Pathname", "Git::Base"].include?(source.class.name)

  # Use source itself if Pathname otherwise fetch the Git dir path
  source = source.class.name == "Git::Base" ? source.dir.path : source
  raise ArgumentError if source == ""

  frameworks = {application: nil, testing: []}

  # Try to detect an application framework using the source
  FrameworkIdentificator::ApplicationFrameworks.available.detect do |framework|
    frameworks[:application] = framework.new(source) if framework.recognized?(source)
  end

  # Try to detect a testing framework using the source
  FrameworkIdentificator::TestingFrameworks.available.each do |framework|
    frameworks[:testing] << framework.new(source) if framework.recognized?(source)
  end

  frameworks
end