Sha256: 54a2a62e87cccacfc17012a0dc867260a0c1b79f2194421025f7850d5f3a69d2

Contents?: true

Size: 906 Bytes

Versions: 11

Compression:

Stored size: 906 Bytes

Contents

module EmberCli
  module Helpers
    extend self

    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 current_environment
      rails_config_for(:ember_cli_rails_mode){ default_environment }.to_s
    end

    private

    def default_environment
      if Rails.env.test?
        "test"
      elsif Rails.env.production? || !rails_config_for(:consider_all_requests_local)
        "production"
      else
        "development"
      end
    end

    def rails_config_for(key)
      if Rails.configuration.respond_to?(key)
        Rails.configuration.public_send(key)
      else
        yield
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ember-cli-rails-0.6.1 lib/ember_cli/helpers.rb
ember-cli-rails-0.6.0 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.8 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.7 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.6 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.5 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.4 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.3 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.2 lib/ember_cli/helpers.rb
ember-cli-rails-0.5.1 lib/ember-cli/helpers.rb
ember-cli-rails-0.5.0 lib/ember-cli/helpers.rb