Class: VMC::Detector
- Inherits:
-
Object
- Object
- VMC::Detector
- Defined in:
- lib/vmc/detect.rb
Constant Summary collapse
- PSEUDO_FRAMEWORKS =
“Basic” framework names for a detected language
{ :node => "node", :python => "wsgi", :java => "java_web", :php => "php", :erlang => "otp_rebar", :dotnet => "dotNet" }
- FRAMEWORK_NAMES =
Mismatched framework names
{ :rails => "rails3" }
- LANGUAGE_RUNTIMES =
Clouseau language symbol => matching runtime names
{ :ruby => /^ruby.*/, :java => /^java.*/, :node => /^node.*/, :erlang => /^erlang.*/, :dotnet => /^dotNet.*/, :python => /^python.*/, :php => /^php.*/ }
Instance Method Summary collapse
-
#all_frameworks ⇒ Object
helper so that this is cached somewhere.
-
#all_runtimes ⇒ Object
helper so that this is cached somewhere.
-
#detect_framework ⇒ Object
detect the framework.
-
#detect_runtimes ⇒ Object
detect the language and return the appropriate runtimes.
- #detected ⇒ Object
-
#initialize(client, path) ⇒ Detector
constructor
A new instance of Detector.
-
#runtimes(framework) ⇒ Object
determine runtimes for a given framework based on the language its detector reports itself as.
-
#suggested_memory(framework) ⇒ Object
determine suitable memory allocation via the framework’s detector.
Constructor Details
#initialize(client, path) ⇒ Detector
Returns a new instance of Detector.
34 35 36 37 |
# File 'lib/vmc/detect.rb', line 34 def initialize(client, path) @client = client @path = path end |
Instance Method Details
#all_frameworks ⇒ Object
helper so that this is cached somewhere
76 77 78 |
# File 'lib/vmc/detect.rb', line 76 def all_frameworks @all_frameworks ||= @client.frameworks end |
#all_runtimes ⇒ Object
helper so that this is cached somewhere
71 72 73 |
# File 'lib/vmc/detect.rb', line 71 def all_runtimes @all_runtimes ||= @client.runtimes end |
#detect_framework ⇒ Object
detect the framework
40 41 42 |
# File 'lib/vmc/detect.rb', line 40 def detect_framework detected && frameworks[detected] end |
#detect_runtimes ⇒ Object
detect the language and return the appropriate runtimes
45 46 47 48 49 50 51 |
# File 'lib/vmc/detect.rb', line 45 def detect_runtimes if detected && lang = detected.language_name runtimes_for(lang) else [] end end |
#detected ⇒ Object
80 81 82 |
# File 'lib/vmc/detect.rb', line 80 def detected @detected ||= Clouseau.detect(@path) end |
#runtimes(framework) ⇒ Object
determine runtimes for a given framework based on the language its detector reports itself as
55 56 57 58 59 60 61 |
# File 'lib/vmc/detect.rb', line 55 def runtimes(framework) if detector = detectors[framework] runtimes_for(detector.language_name) else [] end end |
#suggested_memory(framework) ⇒ Object
determine suitable memory allocation via the framework’s detector
64 65 66 67 68 |
# File 'lib/vmc/detect.rb', line 64 def suggested_memory(framework) if detector = detectors[framework] detector.memory_suggestion end end |