|
| 1 | +# Encoding: utf-8 |
| 2 | +# Cloud Foundry Java Buildpack |
| 3 | +# Copyright 2013 the original author or authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +require 'java_buildpack/util' |
| 18 | + |
| 19 | +module JavaBuildpack::Util |
| 20 | + |
| 21 | + # Utilities for dealing with Groovy applications |
| 22 | + class GroovyUtils |
| 23 | + |
| 24 | + # Indicates whether a file has a +main()+ method in it |
| 25 | + # |
| 26 | + # @param [File] file the file to scan |
| 27 | + # @return [Boolean] +true+ if the file contains a +main()+ method, +false+ otherwise. |
| 28 | + def self.main_method?(file) |
| 29 | + file.read =~ /static void main\(/ |
| 30 | + end |
| 31 | + |
| 32 | + # Indicates whether a file is a POGO |
| 33 | + # |
| 34 | + # @param [File] file the file to scan |
| 35 | + # @return [Boolean] +true+ if the file is a POGO, +false+ otherwise. |
| 36 | + def self.pogo?(file) |
| 37 | + file.read =~ /class [\w]+ [\s\w]*{/ |
| 38 | + end |
| 39 | + |
| 40 | + # Indicates whether a file has a shebang |
| 41 | + # |
| 42 | + # @param [File] file the file to scan |
| 43 | + # @return [Boolean] +true+ if the file has a shebang, +false+ otherwise. |
| 44 | + def self.shebang?(file) |
| 45 | + file.read =~ /#!/ |
| 46 | + end |
| 47 | + |
| 48 | + end |
| 49 | + |
| 50 | +end |
0 commit comments