Class: Jekyll::GitHubMetadata::Pages

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-github-metadata/pages.rb

Constant Summary collapse

DEFAULTS =
{
  'PAGES_ENV'             => 'dotcom'.freeze,
  'PAGES_API_URL'         => 'https://api.github.com'.freeze,
  'PAGES_HELP_URL'        => 'https://help.github.com'.freeze,
  'PAGES_GITHUB_HOSTNAME' => 'github.com'.freeze,
  'PAGES_PAGES_HOSTNAME'  => 'github.io'.freeze,
  'SSL'                   => 'false'.freeze,
  'SUBDOMAIN_ISOLATION'   => 'false'.freeze
}.freeze

Class Method Summary collapse

Class Method Details

.api_urlObject



47
48
49
# File 'lib/jekyll-github-metadata/pages.rb', line 47

def api_url
  trim_last_slash env_var('PAGES_API_URL', ENV['API_URL'])
end

.custom_domains_enabled?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jekyll-github-metadata/pages.rb', line 31

def custom_domains_enabled?
  dotcom? || test?
end

.dotcom?Boolean

Returns:

  • (Boolean)


28
# File 'lib/jekyll-github-metadata/pages.rb', line 28

def dotcom?;     env == 'dotcom' end

.enterprise?Boolean

Returns:

  • (Boolean)


29
# File 'lib/jekyll-github-metadata/pages.rb', line 29

def enterprise?; env == 'enterprise' end

.envObject



35
36
37
# File 'lib/jekyll-github-metadata/pages.rb', line 35

def env
  env_var 'PAGES_ENV'
end

.github_hostnameObject



55
56
57
# File 'lib/jekyll-github-metadata/pages.rb', line 55

def github_hostname
  trim_last_slash env_var('PAGES_GITHUB_HOSTNAME', ENV['GITHUB_HOSTNAME'])
end

.github_urlObject



39
40
41
42
43
44
45
# File 'lib/jekyll-github-metadata/pages.rb', line 39

def github_url
  if dotcom?
    "https://github.com".freeze
  else
    "#{scheme}://#{github_hostname}"
  end
end

.help_urlObject



51
52
53
# File 'lib/jekyll-github-metadata/pages.rb', line 51

def help_url
  trim_last_slash env_var('PAGES_HELP_URL', ENV['HELP_URL'])
end

.pages_hostnameObject



59
60
61
# File 'lib/jekyll-github-metadata/pages.rb', line 59

def pages_hostname
  trim_last_slash env_var('PAGES_PAGES_HOSTNAME', ENV['PAGES_HOSTNAME'])
end

.schemeObject



19
20
21
# File 'lib/jekyll-github-metadata/pages.rb', line 19

def scheme
  ssl? ? "https" : "http"
end

.ssl?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/jekyll-github-metadata/pages.rb', line 15

def ssl?
  env_var('SSL') == 'true' || test?
end

.subdomain_isolation?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jekyll-github-metadata/pages.rb', line 23

def subdomain_isolation?
  env_var('SUBDOMAIN_ISOLATION').eql? 'true'
end

.test?Boolean

Returns:

  • (Boolean)


27
# File 'lib/jekyll-github-metadata/pages.rb', line 27

def test?;       env == 'test' end