Sha256: daf3b6ad7ddb02500eb0c6d691e2f19f2ec75dd31e0c74ef7dbd581849adb804

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

module Jasmine
  module Dependencies

    class << self
      def rspec2?
        safe_gem_check("rspec", ">= 2.0")
      end

      def rails2?
        safe_gem_check("rails", "~> 2.3") && running_rails2?
      end

      def legacy_rails?
        safe_gem_check("rails", "< 2.3.11") && running_legacy_rails?
      end

      def rails3?
        safe_gem_check("rails", ">= 3.0") && running_rails3?
      end

      def legacy_rack?
        !Rack.constants.include?(:Server)
      end

      def rails_3_asset_pipeline?
        rails3? && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets) && Rails.application.assets
      end

      private

      def running_legacy_rails?
        running_rails? && (Gem::Version.new(Rails.version) < Gem::Version.new("2.3.11"))
      end

      def running_rails2?
        running_rails? && Rails.version.to_i == 2
      end

      def running_rails3?
        running_rails? && Rails.version.to_i == 3
      end

      def running_rails?
        defined?(Rails) && Rails.respond_to?(:version)
      end

      def safe_gem_check(gem_name, version_string)
        if Gem::Specification.respond_to?(:find_by_name)
          Gem::Specification.find_by_name(gem_name, version_string)
        elsif Gem.respond_to?(:available?)
          Gem.available?(gem_name, version_string)
        end
      rescue Gem::LoadError
        false
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rally-jasmine-1.2.0.18 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.12 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.11 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.10 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.8 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.7 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.6 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.5 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.4 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.3 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.2 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0.1 lib/jasmine/dependencies.rb
rally-jasmine-1.2.0 lib/jasmine/dependencies.rb