Sha256: f4c266697b7485e7da1a862ca81cb9b6565b5dfe07b511526ddefb86ad74d645

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module EmberCLI
  module Helpers
    extend self

    def match_version?(version, requirement)
      version = Gem::Version.new(version)
      requirement = Gem::Requirement.new(requirement)
      requirement.satisfied_by?(version)
    end

    def which(cmd)
      exts = ENV.fetch("PATHEXT", ?;).split(?;, -1).uniq

      ENV.fetch("PATH").split(File::PATH_SEPARATOR).each do |path|
        exts.each do |ext|
          exe = File.join(path, "#{cmd}#{ext}")
          return exe if File.executable?(exe) && !File.directory?(exe)
        end
      end

      nil
    end

    def non_production?
      !Rails.env.production? && rails_config_for(:consider_all_requests_local)
    end

    def use_middleware?
      rails_config_for(:use_ember_middleware, non_production?)
    end

    def use_live_recompilation?
      rails_config_for(:use_ember_live_recompilation, Rails.env.development?)
    end

    def rails_config_for(key, default=false)
      config = Rails.configuration
      config.respond_to?(key) ? config.public_send(key) : default
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ember-cli-rails-0.1.9 lib/ember-cli/helpers.rb
ember-cli-rails-0.1.8 lib/ember-cli/helpers.rb
ember-cli-rails-0.1.7 lib/ember-cli/helpers.rb
ember-cli-rails-0.1.6 lib/ember-cli/helpers.rb
ember-cli-rails-0.1.5 lib/ember-cli/helpers.rb