Sha256: 093f3ae08adaf76544cc811fdc190ccdd766df64d43b15ed7f237b8c6d92f0fa

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

require "uri"
require "watirsplash/version"

module WatirSplash
  module Generators
    class NewProject < Thor::Group
      include Thor::Actions
      include Helper

      argument :name 
      argument :url
      argument :framework

      def self.source_root
        File.dirname(__FILE__) + "/templates"
      end

      def generate
        directory("new_project", name)
        template("../../../../Gemfile", "#{name}/Gemfile")

        gsub_file("#{name}/Gemfile", "gemspec", %Q{gem "watirsplash", "#{WatirSplash::Version::WATIRSPLASH}"})
        gsub_file("#{name}/Gemfile", /WatirSplash::Version::WATIR_WEBDRIVER/, "\"#{WatirSplash::Version::WATIR_WEBDRIVER}\"")
        gsub_file("#{name}/Gemfile", /WatirSplash::Version::WATIR/, "\"#{WatirSplash::Version::WATIR}\"")
        gsub_file("#{name}/Gemfile", /WatirSplash::Version::WIN32SCREENSHOT/, "\"#{WatirSplash::Version::WIN32SCREENSHOT}\"")
      end

      def formatted_url
        uri = URI.parse(url)
        if !default_url? && uri.relative?
          %Q[URI.join(#{formatted_name}::Config::URL, "#{uri}").to_s] 
        else
          %Q["#{uri}"]
        end
      end

      def formatted_name
        Thor::Util.camel_case name.gsub("-", "_")
      end

      def default_url?
        url.to_s == "about:blank"
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
watirsplash-2.4.4 lib/watirsplash/generators/new_project.rb
watirsplash-2.4.3 lib/watirsplash/generators/new_project.rb
watirsplash-2.4.2 lib/watirsplash/generators/new_project.rb
watirsplash-2.4.1 lib/watirsplash/generators/new_project.rb
watirsplash-2.4.0 lib/watirsplash/generators/new_project.rb
watirsplash-2.3.2 lib/watirsplash/generators/new_project.rb
watirsplash-2.3.1 lib/watirsplash/generators/new_project.rb
watirsplash-2.3.0 lib/watirsplash/generators/new_project.rb
watirsplash-2.2.0 lib/watirsplash/generators/new_project.rb
watirsplash-2.1.1 lib/watirsplash/generators/new_project.rb
watirsplash-2.1.0 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.1.rc5 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.1.rc4 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.1.rc3 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.1.rc1 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.0 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.0.rc2 lib/watirsplash/generators/new_project.rb
watirsplash-2.0.0.rc1 lib/watirsplash/generators/new_project.rb