Sha256: f5ada99bc0123473531d0584466b2662bcb662fc3924c72296253b2ddaa0f10d

Contents?: true

Size: 652 Bytes

Versions: 5

Compression:

Stored size: 652 Bytes

Contents

require "juicer/dependency_resolver/dependency_resolver"

module Juicer
  # Resolves @depends and @depend statements in comments in JavaScript files.
  # Only the first comment in a JavaScript file is parsed
  #
  class JavaScriptDependencyResolver < DependencyResolver
    @@depends_pattern = /\@depends?\s+([^\s\'\"\;]+)/

    private
    def parse(line, imported_file = nil)
      return $1 if line =~ @@depends_pattern

      # If we have already skimmed through some @depend/@depends or a
      # closing comment we're done.
      throw :done unless imported_file.nil? || !(line =~ /\*\//)
    end

    def extension
      ".js"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
juicer-1.0.18 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb
juicer-1.0.17 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb
juicer-1.0.16 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb
juicer-1.0.15 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb
juicer-1.0.14 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb