Sha256: 2c1860cf946ad2e974c47d654decaf624d130a66c2848524a264b2b38fa56287

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module MDQT
  class CLI

    class Defaults

      class << self

        def base_url
          ENV['MDQT_SERVICE'] || ENV['MDQ_BASE_URL'] || guess_service
        end

        def force_hash?
          false
        end

        def cli_defaults
          {
            hash: force_hash?,
            cache: false
          }
        end

        def guess_service

          locale = ENV['LANG']

          #STDERR.puts("Detected locale #{locale}")

          service = case locale
                    when 'en_GB.UTF-8'
                      'http://mdq.ukfederation.org.uk/'
                    when 'en_US.UTF-8'
                      'http://mdq-beta.incommon.org/global'
                    else
                      abort "Please specify an MDQ service using --service, MDQT_SERVICE or MDQ_BASE_URL"
                    end

          STDERR.puts "MDQT is assuming that you want to use #{service}\nPlease configure this using --service, MDQT_SERVICE or MDQ_BASE_URL\n\n"

          service

        end

      end

    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mdqt-0.4.0 lib/mdqt/cli/defaults.rb
mdqt-0.3.1 lib/mdqt/cli/defaults.rb
mdqt-0.3.0 lib/mdqt/cli/defaults.rb
mdqt-0.2.1 lib/mdqt/cli/defaults.rb
mdqt-0.2.0 lib/mdqt/cli/defaults.rb