Class: MDQT::CLI::Defaults

Inherits:
Object
  • Object
show all
Defined in:
lib/mdqt/cli/defaults.rb

Class Method Summary collapse

Class Method Details

.base_urlObject



8
9
10
# File 'lib/mdqt/cli/defaults.rb', line 8

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

.cli_defaultsObject



16
17
18
19
20
21
# File 'lib/mdqt/cli/defaults.rb', line 16

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

.force_hash?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/mdqt/cli/defaults.rb', line 12

def force_hash?
  false
end

.guess_serviceObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mdqt/cli/defaults.rb', line 23

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