vmc 0.4.0.beta.56 → 0.4.0.beta.57
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/lib/vmc/cli/app.rb +6 -12
- data/vmc-ng/lib/vmc/detect.rb +55 -74
- data/vmc-ng/lib/vmc/version.rb +1 -1
- metadata +6 -6
data/vmc-ng/lib/vmc/cli/app.rb
CHANGED
@@ -847,27 +847,21 @@ module VMC
|
|
847
847
|
all_frameworks = detector.all_frameworks
|
848
848
|
all_runtimes = detector.all_runtimes
|
849
849
|
|
850
|
-
|
851
|
-
|
852
|
-
if detected_frameworks.size == 1
|
853
|
-
default_framework = detected_frameworks.first
|
854
|
-
end
|
855
|
-
|
856
|
-
if detected_frameworks.empty?
|
857
|
-
framework = input[:framework, all_frameworks]
|
858
|
-
else
|
850
|
+
if detected_framework = detector.detect_framework
|
859
851
|
framework = input[
|
860
852
|
:framework,
|
861
|
-
|
862
|
-
|
853
|
+
[detected_framework],
|
854
|
+
detected_framework,
|
863
855
|
all_frameworks,
|
864
856
|
:other
|
865
857
|
]
|
858
|
+
else
|
859
|
+
framework = input[:framework, all_frameworks]
|
866
860
|
end
|
867
861
|
|
868
862
|
|
869
863
|
if framework.name == "standalone"
|
870
|
-
detected_runtimes = detector.
|
864
|
+
detected_runtimes = detector.detect_runtimes
|
871
865
|
else
|
872
866
|
detected_runtimes = detector.runtimes(framework)
|
873
867
|
end
|
data/vmc-ng/lib/vmc/detect.rb
CHANGED
@@ -25,114 +25,95 @@ module VMC
|
|
25
25
|
:php => /^php.*/
|
26
26
|
}
|
27
27
|
|
28
|
-
# [Framework]
|
29
|
-
attr_reader :matches
|
30
|
-
|
31
|
-
# Framework
|
32
|
-
attr_reader :default
|
33
|
-
|
34
28
|
def initialize(client, path)
|
35
29
|
@client = client
|
36
30
|
@path = path
|
37
31
|
end
|
38
32
|
|
39
|
-
|
40
|
-
|
33
|
+
# detect the framework
|
34
|
+
def detect_framework
|
35
|
+
detected && frameworks[detected]
|
36
|
+
end
|
37
|
+
|
38
|
+
# detect the language and return the appropriate runtimes
|
39
|
+
def detect_runtimes
|
40
|
+
if detected && lang = detected.language_name
|
41
|
+
runtimes_for(lang)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# determine runtimes for a given framework based on the language its
|
46
|
+
# detector reports itself as
|
47
|
+
def runtimes(framework)
|
48
|
+
if detector = detectors[framework]
|
49
|
+
runtimes_for(detector.language_name)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# determine suitable memory allocation via the framework's detector
|
54
|
+
def suggested_memory(framework)
|
55
|
+
if detector = detectors[framework]
|
56
|
+
detector.memory_suggestion
|
57
|
+
end
|
41
58
|
end
|
42
59
|
|
60
|
+
# helper so that this is cached somewhere
|
43
61
|
def all_runtimes
|
44
62
|
@all_runtimes ||= @client.runtimes
|
45
63
|
end
|
46
64
|
|
65
|
+
# helper so that this is cached somewhere
|
47
66
|
def all_frameworks
|
48
67
|
@all_frameworks ||= @client.frameworks
|
49
68
|
end
|
50
69
|
|
51
|
-
|
52
|
-
return @matches if @matches
|
53
|
-
|
54
|
-
frameworks = all_frameworks
|
55
|
-
|
56
|
-
@matches = {}
|
57
|
-
|
58
|
-
Clouseau.matches(@path).each do |detected|
|
59
|
-
if name = detected.framework_name
|
60
|
-
framework = frameworks.find { |f|
|
61
|
-
f.name == name.to_s
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
if !framework && lang = detected.language_name
|
66
|
-
framework = frameworks.find { |f|
|
67
|
-
f.name == PSEUDO_FRAMEWORKS[lang]
|
68
|
-
}
|
69
|
-
end
|
70
|
-
|
71
|
-
next unless framework
|
72
|
-
|
73
|
-
@matches[framework] = detected
|
74
|
-
end
|
70
|
+
private
|
75
71
|
|
76
|
-
|
72
|
+
def detected
|
73
|
+
@detected ||= Clouseau.detect(@path)
|
77
74
|
end
|
78
75
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
76
|
+
def map_detectors!
|
77
|
+
@framework_detectors = {}
|
78
|
+
@detector_frameworks = {}
|
82
79
|
|
83
|
-
|
84
|
-
|
80
|
+
Clouseau.detectors.each do |d|
|
81
|
+
name = d.framework_name.to_s
|
82
|
+
lang = d.language_name
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
84
|
+
framework = all_frameworks.find { |f|
|
85
|
+
f.name == name
|
86
|
+
}
|
91
87
|
|
92
|
-
|
88
|
+
framework ||= all_frameworks.find { |f|
|
89
|
+
f.name == PSEUDO_FRAMEWORKS[lang]
|
90
|
+
}
|
93
91
|
|
94
|
-
|
95
|
-
|
92
|
+
next unless framework
|
93
|
+
|
94
|
+
@framework_detectors[framework] = d
|
95
|
+
@detector_frameworks[d] = framework
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
nil
|
99
99
|
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
# Framework -> Detector
|
102
|
+
def detectors
|
103
|
+
map_detectors! unless @framework_detectors
|
104
|
+
@framework_detectors
|
105
105
|
end
|
106
106
|
|
107
|
-
|
108
|
-
|
107
|
+
# Detector -> Framework
|
108
|
+
def frameworks
|
109
|
+
map_detectors! unless @detector_frameworks
|
110
|
+
@detector_frameworks
|
109
111
|
end
|
110
112
|
|
111
|
-
private
|
112
|
-
|
113
113
|
def runtimes_for(language)
|
114
114
|
all_runtimes.select do |r|
|
115
115
|
LANGUAGE_RUNTIMES[language] === r.name
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
119
|
-
def find_top(entries)
|
120
|
-
found = false
|
121
|
-
|
122
|
-
entries.each do |e|
|
123
|
-
is_toplevel =
|
124
|
-
e.ftype == :directory && e.name.index("/") + 1 == e.name.size
|
125
|
-
|
126
|
-
if is_toplevel && e.name !~ /^(\.|__MACOSX)/
|
127
|
-
if found
|
128
|
-
return false
|
129
|
-
else
|
130
|
-
found = e.name
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
found
|
136
|
-
end
|
137
118
|
end
|
138
119
|
end
|
data/vmc-ng/lib/vmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1537108025
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.4.0.beta.
|
11
|
+
- 57
|
12
|
+
version: 0.4.0.beta.57
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- VMware
|
@@ -265,12 +265,12 @@ dependencies:
|
|
265
265
|
requirements:
|
266
266
|
- - ~>
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
hash:
|
268
|
+
hash: 85
|
269
269
|
segments:
|
270
270
|
- 0
|
271
271
|
- 3
|
272
|
-
-
|
273
|
-
version: 0.3.
|
272
|
+
- 35
|
273
|
+
version: 0.3.35
|
274
274
|
type: :runtime
|
275
275
|
version_requirements: *id015
|
276
276
|
- !ruby/object:Gem::Dependency
|