Class: VMC::Cli::Framework
Constant Summary collapse
- DEFAULT_FRAMEWORK =
"http://b20nine.com/unknown"
- DEFAULT_MEM =
'256M'
- FRAMEWORKS =
{ 'Rails' => ['rails/1.0', { :mem => '256M', :description => 'Rails Application'}], 'Spring' => ['spring_web/1.0', { :mem => '512M', :description => 'Java SpringSource Spring Application'}], 'Grails' => ['grails/1.0', { :mem => '512M', :description => 'Java SpringSource Grails Application'}], 'Roo' => ['spring_web/1.0', { :mem => '512M', :description => 'Java SpringSource Roo Application'}], 'JavaWeb' => ['spring_web/1.0', { :mem => '512M', :description => 'Java Web Application'}], 'Sinatra' => [DEFAULT_FRAMEWORK, { :mem => '128M', :description => 'Sinatra Application'}], 'Node' => ['nodejs/1.0', { :mem => '64M', :description => 'Node.js Application'}], }
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#exec ⇒ Object
Returns the value of attribute exec.
-
#memory ⇒ Object
(also: #mem)
readonly
Returns the value of attribute memory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(framework = nil, opts = {}) ⇒ Framework
constructor
A new instance of Framework.
- #to_s ⇒ Object
Constructor Details
#initialize(framework = nil, opts = {}) ⇒ Framework
Returns a new instance of Framework.
85 86 87 88 89 90 |
# File 'lib/cli/frameworks.rb', line 85 def initialize(framework=nil, opts={}) @name = framework || DEFAULT_FRAMEWORK @memory = opts[:mem] || DEFAULT_MEM @description = opts[:description] || 'Unknown Application Type' @exec = opts[:exec] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
80 81 82 |
# File 'lib/cli/frameworks.rb', line 80 def description @description end |
#exec ⇒ Object
Returns the value of attribute exec.
81 82 83 |
# File 'lib/cli/frameworks.rb', line 81 def exec @exec end |
#memory ⇒ Object (readonly) Also known as: mem
Returns the value of attribute memory.
80 81 82 |
# File 'lib/cli/frameworks.rb', line 80 def memory @memory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/cli/frameworks.rb', line 80 def name @name end |
Class Method Details
.detect(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cli/frameworks.rb', line 28 def detect(path) Dir.chdir(path) do # Rails if File.exist?('config/environment.rb') return Framework.lookup('Rails') # Java elsif Dir.glob('*.war').first war_file = Dir.glob('*.war').first contents = ZipUtil.entry_lines(war_file) # Spring Variations if contents =~ /WEB-INF\/lib\/grails-web.*\.jar/ return Framework.lookup('Grails') elsif contents =~ /WEB-INF\/classes\/org\/springframework/ return Framework.lookup('Spring') elsif contents =~ /WEB-INF\/lib\/spring-core.*\.jar/ return Framework.lookup('Spring') else return Framework.lookup('JavaWeb') end # Simple Ruby Apps elsif !Dir.glob('*.rb').empty? matched_file = nil Dir.glob('*.rb').each do |fname| next if matched_file File.open(fname, 'r') do |f| str = f.read # This might want to be limited matched_file = fname if (str && str.match(/^\s*require\s*'sinatra'/)) end end if matched_file f = Framework.lookup('Sinatra') f.exec = "ruby #{matched_file}" return f end # Node.js elsif !Dir.glob('*.js').empty? # Fixme, make other files work too.. if File.exist?('app.js') || File.exist?('index.js') || File.exist?('main.js') return Framework.lookup('Node') end end end nil end |
.known_frameworks ⇒ Object
20 21 22 |
# File 'lib/cli/frameworks.rb', line 20 def known_frameworks FRAMEWORKS.keys end |
.lookup(name) ⇒ Object
24 25 26 |
# File 'lib/cli/frameworks.rb', line 24 def lookup(name) return Framework.new(*FRAMEWORKS[name]) end |
Instance Method Details
#to_s ⇒ Object
92 93 94 |
# File 'lib/cli/frameworks.rb', line 92 def to_s description end |