cloulu 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDg1ODU1YjgyODdhZDdiMzY2N2UwMjIyMzBlMzA2ZDU4OWJlNWQ5MQ==
4
+ NDYwZjcxZmI4MmM2MmM0ZDc1NWFlOTQwYWQxOTkxNDlmNjAzZWQ1MQ==
5
5
  data.tar.gz: !binary |-
6
- NTQxNjEzMDQ2MDkxNjNiZjhmMzMyNThhZGZhZmU1NzM3NmE1MmQ5Yg==
6
+ ZjA5NmNlMDNiNGZkOTMzYjgwZWY3ZTMyY2RkODQwZDg4ZWMzZTg4Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWM2ZWUzZDk2ZTliNWI3MDllODU0NDJjMjdkNjA5YTYzNTdjZjllNDZhZWZl
10
- YjJhODQ0ZjQ1MWFiZjI1ZDE0ZTMxY2RhMzc3OWNjNzBjYzFiOGYxYWRhMmJi
11
- NjEwMGNiNzI3OWEwZGQwMTViZDE5NDBhOWUxYmNjOWE5YTM0ZTc=
9
+ NTM5MTE1MTJhYjJiNGVlZmVjMGI5NDE1N2E0MWZmNTMzYzBhZmJhODUxNGQ0
10
+ MmVmMWMyOTdiYzdiZmE5ZGZmOWU5ZWJlODRiN2JjMjRiOWYxZTM3YzUxYTE0
11
+ MmEzM2QzN2UwYTYwNjU1MjgzZjIyMDUxZmEzOWVhMmUzY2M2YTc=
12
12
  data.tar.gz: !binary |-
13
- YTMyMGRiNGI2MTk0ZDQ5ZTI1MzIwOGQ5MTI5NzY0MWU5YmFhZDEwMTg3YTNj
14
- YTZiZWRlMmI0ZDA2OGE1YTNjYTdlODg5YTNiY2RhYzIyNWI1ZTUzZDZmMGEy
15
- MDQ4MGM5M2VhYzRiMDc0NzNhZmE5NjFmNjJhNTZlMzI1Zjg4NGU=
13
+ NjU2ZTU5Y2QwNjY4ZjFjMmMzNjJkNWVjZThjYWQ4ODdhNTQxYjI2MWE3Zjc4
14
+ YmM1NTg0YjY2YzY5MTk1NDAzYTJhZjRkODMxOTBiYWFjY2MwYzcwMDA5OTQ3
15
+ MjViZWI0YWNjYjVhMzE5ZDhiNjYyMTk1ZGVhZDIyODliZjM1YjI=
@@ -0,0 +1,137 @@
1
+ require "zip/zipfilesystem"
2
+
3
+ module Clouseau
4
+ # array of registered detectors, in the order they'll be tried
5
+ #
6
+ # see Detector.inherited
7
+ def self.detectors
8
+ @detectors ||= []
9
+ end
10
+
11
+ class Detector
12
+ class << self
13
+ attr_accessor :framework_name, :language_name, :memory_suggestion
14
+
15
+ # each detection technique; an array of blocks which when called with
16
+ # a path yield true or false
17
+ def detection
18
+ @detection ||= []
19
+ end
20
+
21
+ # name of the detected framework
22
+ def framework_name
23
+ @framework_name || parent(:framework_name)
24
+ end
25
+
26
+ # name of the detected language
27
+ def language_name
28
+ @language_name || parent(:language_name)
29
+ end
30
+
31
+ # suggested minimum memory allocation for an application of this type
32
+ def memory_suggestion
33
+ @memory_suggestion || parent(:memory_suggestion)
34
+ end
35
+
36
+ private
37
+
38
+ # register the detector, ensuring it's prioritized over its superclass
39
+ def inherited(cls)
40
+ idx =
41
+ Clouseau.detectors.index { |d|
42
+ (cls <=> d) == -1
43
+ }
44
+
45
+ Clouseau.detectors.insert(idx || 0, cls)
46
+ end
47
+
48
+ # set detected framework name
49
+ def framework(name)
50
+ self.framework_name = name
51
+ end
52
+
53
+ # set detected language
54
+ def language(name)
55
+ self.language_name = name
56
+ end
57
+
58
+ # set suggested memory
59
+ def memory(size)
60
+ self.memory_suggestion = size
61
+ end
62
+
63
+ # check for given filenames
64
+ #
65
+ # if given a block, it is called with each file's contents, and if it
66
+ # ever returns true, it is a match
67
+ def file(*files, &check)
68
+ detection << proc { |path|
69
+ files.all? { |f|
70
+ file = "#{path}/#{f}"
71
+
72
+ if File.exists?(file)
73
+ !check || check.call(File.read(file))
74
+ end
75
+ }
76
+ }
77
+ end
78
+
79
+ # check for files described by glob
80
+ #
81
+ # if given a block, it is called with each file's contents, and if it
82
+ # ever returns true, it is a match
83
+ def glob(*globs, &check)
84
+ detection << proc { |path|
85
+ globs.all? do |glob|
86
+ files = Dir.glob("#{path}/#{glob}")
87
+
88
+ unless files.empty?
89
+ !check || files.any? { |f| check.call(f) }
90
+ end
91
+ end
92
+ }
93
+ end
94
+
95
+ # check for an archive (i.e. .war, .zip, .jar)
96
+ #
97
+ # if given a block, it is called with each entry in the archive, and if
98
+ # it ever returns true, it is a match
99
+ def zip(glob, &check)
100
+ detection << proc { |path|
101
+ archives =
102
+ if File.fnmatch(glob, path)
103
+ [path]
104
+ else
105
+ Dir.glob("#{path}/#{glob}")
106
+ end
107
+
108
+ archives.any? do |f|
109
+ found = false
110
+
111
+ Zip::ZipFile.foreach(f) do |entry|
112
+ if check.call(entry)
113
+ found = true
114
+ break
115
+ end
116
+ end
117
+
118
+ found
119
+ end
120
+ }
121
+ end
122
+
123
+ def parent(meth)
124
+ if superclass.respond_to? meth
125
+ superclass.send(meth)
126
+ end
127
+ end
128
+ end
129
+
130
+ # run through the detection methods and return `true' if one matches
131
+ def detect(path)
132
+ self.class.detection.any? do |d|
133
+ d.call(path)
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,10 @@
1
+ require "clouseau/detectors/python"
2
+
3
+ module Clouseau
4
+ class Django < Python
5
+ file "manage.py"
6
+
7
+ framework :django
8
+ memory 128
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Clouseau
2
+ class DotNet < Detector
3
+ file "web.config"
4
+
5
+ language :dotnet
6
+ memory 128
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Clouseau
2
+ class Erlang < Detector
3
+ glob "releases/*/*.rel", "releases/*/*.boot"
4
+
5
+ language :erlang
6
+ memory 64
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ require "clouseau/detectors/python"
2
+
3
+ module Clouseau
4
+ class Flask < Python
5
+ glob "*.py" do |file|
6
+ File.read(file) =~ /[a-zA-Z0-9_]+ *= *Flask *\(.*\)/
7
+ end
8
+
9
+ framework :flask
10
+ memory 256
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require "clouseau/detectors/spring"
2
+
3
+ module Clouseau
4
+ class Grails < Spring
5
+ zip "*.war" do |file|
6
+ file.name =~ /WEB-INF\/lib\/grails-web.*\.jar/
7
+ end
8
+
9
+ framework :grails
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Clouseau
2
+ class Java < Detector
3
+ glob "*.war"
4
+ file "WEB-INF/web.xml"
5
+
6
+ language :java
7
+ memory 512
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require "clouseau/detectors/spring"
2
+
3
+ module Clouseau
4
+ class Lift < Spring
5
+ zip "*.war" do |file|
6
+ file.name =~ /WEB-INF\/lib\/lift-webkit.*\.jar/
7
+ end
8
+
9
+ framework :lift
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Clouseau
2
+ class Node < Detector
3
+ file "server.js"
4
+ file "app.js"
5
+ file "index.js"
6
+ file "main.js"
7
+
8
+ language :node
9
+ memory 64
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module Clouseau
2
+ class PHP < Detector
3
+ glob "*.php"
4
+
5
+ language :php
6
+ memory 128
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ require "clouseau/detectors/java"
2
+
3
+ module Clouseau
4
+ class Play < Java
5
+ zip "*.zip" do |file|
6
+ file.name =~ /lib\/play\..*\.jar/
7
+ end
8
+
9
+ framework :play
10
+ memory 256
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module Clouseau
2
+ class Python < Detector
3
+ file "wsgi.py"
4
+
5
+ language :python
6
+ memory 64
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require "clouseau/detectors/ruby"
2
+
3
+ module Clouseau
4
+ class Rack < Ruby
5
+ file "config.ru"
6
+
7
+ framework :rack
8
+ memory 128
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require "clouseau/detectors/rack"
2
+
3
+ module Clouseau
4
+ class Rails < Rack
5
+ file "config/environment.rb"
6
+
7
+ framework :rails
8
+ memory 256
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Clouseau
2
+ class Ruby < Detector
3
+ glob "*.rb"
4
+
5
+ language :ruby
6
+ memory 128
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require "clouseau/detectors/ruby"
2
+
3
+ module Clouseau
4
+ class Sinatra < Ruby
5
+ glob "*.rb" do |file|
6
+ File.read(file) =~ /^\s*require[\s\(]*['"]sinatra(\/base)?['"]/
7
+ end
8
+
9
+ framework :sinatra
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require "clouseau/detectors/java"
2
+
3
+ module Clouseau
4
+ class Spring < Java
5
+ zip "*.war" do |file|
6
+ case file.name
7
+ when /WEB-INF\/classes\/org\/springframework/,
8
+ /WEB-INF\/lib\/spring-core.*\.jar/,
9
+ /WEB-INF\/lib\/org\.springframework\.core.*\.jar/
10
+ true
11
+ end
12
+ end
13
+
14
+ framework :spring
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ Dir.glob(File.expand_path("../detectors/*.rb", __FILE__)) do |file|
2
+ require file
3
+ end
@@ -0,0 +1,3 @@
1
+ module Clouseau
2
+ VERSION = "0.0.2"
3
+ end
data/lib/clouseau.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "clouseau/detector"
2
+ require "clouseau/detectors"
3
+
4
+ module Clouseau
5
+ class << self
6
+ def detect(path)
7
+ detectors.find do |d|
8
+ d.new.detect(path)
9
+ end
10
+ end
11
+
12
+ def matches(path)
13
+ detectors.select do |d|
14
+ d.new.detect(path)
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/vmc/detect.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "set"
2
2
 
3
+ $:.unshift(File.expand_path("../..", __FILE__)) # for internal clouseau lib.
3
4
  require "clouseau"
4
5
 
5
6
  module VMC
data/lib/vmc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.5.1".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloulu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SKPlanet Cloulu Team
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.2'
70
- - !ruby/object:Gem::Dependency
71
- name: clouseau
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: '0.0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ~>
82
- - !ruby/object:Gem::Version
83
- version: '0.0'
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: addressable
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +189,26 @@ files:
203
189
  - lib/cfoundry/version.rb
204
190
  - lib/cfoundry/zip.rb
205
191
  - lib/cfoundry.rb
192
+ - lib/clouseau/detector.rb
193
+ - lib/clouseau/detectors/django.rb
194
+ - lib/clouseau/detectors/dotnet.rb
195
+ - lib/clouseau/detectors/erlang.rb
196
+ - lib/clouseau/detectors/flask.rb
197
+ - lib/clouseau/detectors/grails.rb
198
+ - lib/clouseau/detectors/java.rb
199
+ - lib/clouseau/detectors/lift.rb
200
+ - lib/clouseau/detectors/node.rb
201
+ - lib/clouseau/detectors/php.rb
202
+ - lib/clouseau/detectors/play.rb
203
+ - lib/clouseau/detectors/python.rb
204
+ - lib/clouseau/detectors/rack.rb
205
+ - lib/clouseau/detectors/rails.rb
206
+ - lib/clouseau/detectors/ruby.rb
207
+ - lib/clouseau/detectors/sinatra.rb
208
+ - lib/clouseau/detectors/spring.rb
209
+ - lib/clouseau/detectors.rb
210
+ - lib/clouseau/version.rb
211
+ - lib/clouseau.rb
206
212
  - lib/manifests-vmc-plugin/errors.rb
207
213
  - lib/manifests-vmc-plugin/lib/manifests-vmc-plugin/errors.rb
208
214
  - lib/manifests-vmc-plugin/lib/manifests-vmc-plugin/loader/builder.rb