Sha256: 5e64806f613e2e0bc5491f472045416d74dee3f1d431b90008fd50825da3be4b

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

class DependencyManager

  attr_accessor :options

  def initialize(options)
    @options = options
  end

  def compile_scope
    dependencies = append_freemarker_dependency_if_necessary default_dependencies
    dependencies = append_heroku_dependencies_if_necessary dependencies
    dependencies
  end

  def test_scope
    [Dependency.new("junit", "junit", "4.8.2"),
     Dependency.new("org.hamcrest", "hamcrest-all", "1.1"),
     Dependency.new("org.mockito", "mockito-all", "1.8.5")]
  end

  def provided_scope
    if @options[:heroku]
      return []
    end
    [Dependency.new("javax.servlet", "servlet-api", "2.5"), Dependency.new("javax.servlet.jsp", "jsp-api", "2.1")]
  end

  private
  def default_dependencies
    hibernate_version = "3.6.7.Final"
    [Dependency.new("br.com.caelum", "vraptor", "3.3.1"),
     Dependency.new("org.hsqldb", "hsqldb", "2.2.4"),
     Dependency.new("opensymphony", "sitemesh", "2.4.2"), Dependency.new("javax.servlet", "jstl", "1.2"),
     Dependency.new("org.hibernate", "hibernate-entitymanager", hibernate_version),
     Dependency.new("org.hibernate", "hibernate-c3p0", hibernate_version),
     Dependency.new("org.hibernate", "hibernate-validator", "4.2.0.Final"),
     Dependency.new("joda-time", "joda-time", "2.0")]
  end

  def append_heroku_dependencies_if_necessary dependencies
    if @options[:heroku]
      dependencies += [Dependency.new("org.eclipse.jetty", "jetty-webapp", "7.4.4.v20110707"),
                       Dependency.new("org.mortbay.jetty", "jsp-2.1-glassfish", "2.1.v20100127"),
                       Dependency.new("javax.servlet", "servlet-api", "2.5")]
    end
    dependencies
  end

  def append_freemarker_dependency_if_necessary dependencies
    dependencies << Dependency.new("org.freemarker", "freemarker", "2.3.18") if @options[:template_engine] == 'ftl'
    dependencies
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vraptor-scaffold-1.2.0 lib/vraptor-scaffold/generators/app/dependency_manager.rb