@@ -0,0 +1,2595 @@
+/**%0A * Copyright 2012 55 Minutes (http://www.55minutes.com)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage fiftyfive.wicket.js.locator;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A/**%0A * Helper class that parses JavaScript files for special%0A * %3Ca href=%22http://getsprockets.org/%22%3ESprockets%3C/a%3E comments%0A * like these:%0A * %3Cpre class=%22example%22%3E%0A * //= require library_name%0A * //= require ./file_name%3C/pre%3E%0A * %3Cp%3E%0A * Note that paths can also be surrounded by quotes, but they are completely optional:%0A * %3Cpre class=%22example%22%3E%0A * //= require %22library_name%22%0A * //= require %22./file_name%22%3C/pre%3E%0A * %0A * @since 4.0%0A */%0Apublic class SprocketsParserImplV4 implements SprocketsParser%0A%7B%0A    private static final Logger LOGGER = LoggerFactory.getLogger(%0A        SprocketsParserImplV4.class%0A    );%0A    %0A    static final Pattern REQ = Pattern.compile(%22%5E%5C%5Cs*//=%5C%5Cs*require%5C%5Cs+(%5C%5CS.*%5C%5CS)%5C%5Cs*$%22);%0A    %0A    public List%3CSprocket%3E parseSprockets(BufferedReader javascript)%0A        throws IOException%0A    %7B%0A        List%3CSprocket%3E sprockets = new ArrayList%3CSprocket%3E();%0A        %0A        while(true)%0A        %7B%0A            String line = javascript.readLine();%0A            if(null == line) break;%0A            %0A            Matcher require = REQ.matcher(line);%0A            if(!require.find()) continue;%0A            %0A            String path = stripQuotes(require.group(1));%0A            boolean isLibrary = !(path.startsWith(%22./%22) %7C%7C path.startsWith(%22../%22));%0A            sprockets.add(new Sprocket(isLibrary, path));%0A        %7D%0A        return sprockets;%0A    %7D%0A    %0A    private String stripQuotes(String path)%0A    %7B%0A        String%5B%5D quotes = new String%5B%5D %7B %22%5C%22%22, %22'%22 %7D;%0A        for(String q : quotes)%0A        %7B%0A            if(path.startsWith(q) && path.endsWith(q))%0A            %7B%0A                path = path.substring(1, path.length() - 1);%0A                break;%0A            %7D%0A        %7D%0A        return path;%0A    %7D%0A%7D%0A

Introduce parse logic for new sprockets syntax