Class: Jekyll::RemoteTheme::Theme
- Inherits:
-
Theme
- Object
- Theme
- Jekyll::RemoteTheme::Theme
- Defined in:
- lib/jekyll-remote-theme/theme.rb
Constant Summary collapse
- OWNER_REGEX =
%r!(?<owner>[a-z0-9\-]+)!i.freeze
- NAME_REGEX =
%r!(?<name>[a-z0-9\._\-]+)!i.freeze
- REF_REGEX =
May be a branch, tag, or commit
%r!@(?<ref>[a-z0-9\._\-]+)!i.freeze
- THEME_REGEX =
%r!\A#{OWNER_REGEX}/#{NAME_REGEX}(?:#{REF_REGEX})?\z!i.freeze
Instance Method Summary collapse
- #git_ref ⇒ Object
- #host ⇒ Object
-
#initialize(raw_theme) ⇒ Theme
constructor
Initializes a new Jekyll::RemoteTheme::Theme.
- #inspect ⇒ Object
- #name ⇒ Object
- #name_with_owner ⇒ Object (also: #nwo)
- #owner ⇒ Object
- #root ⇒ Object
- #scheme ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(raw_theme) ⇒ Theme
Initializes a new Jekyll::RemoteTheme::Theme
raw_theme can be in the form of:
-
owner/theme-name - a GitHub owner + theme-name string
-
owner/theme-name@git_ref - a GitHub owner + theme-name + Git ref string
-
http://github.<yourEnterprise>.com/owner/theme-name
-
An enterprise GitHub instance + a GitHub owner + a theme-name string
-
http://github.<yourEnterprise>.com/owner/theme-name@git_ref
-
An enterprise GitHub instance + a GitHub owner + a theme-name + Git ref string
21 22 23 24 |
# File 'lib/jekyll-remote-theme/theme.rb', line 21 def initialize(raw_theme) @raw_theme = raw_theme.to_s.downcase.strip super(@raw_theme) end |
Instance Method Details
#git_ref ⇒ Object
53 54 55 |
# File 'lib/jekyll-remote-theme/theme.rb', line 53 def git_ref theme_parts[:ref] || "master" end |
#host ⇒ Object
34 35 36 |
# File 'lib/jekyll-remote-theme/theme.rb', line 34 def host uri&.host end |
#inspect ⇒ Object
61 62 63 64 |
# File 'lib/jekyll-remote-theme/theme.rb', line 61 def inspect "#<Jekyll::RemoteTheme::Theme host=\"#{host}\" owner=\"#{owner}\" name=\"#{name}\"" \ " ref=\"#{git_ref}\" root=\"#{root}\">" end |
#name ⇒ Object
26 27 28 |
# File 'lib/jekyll-remote-theme/theme.rb', line 26 def name theme_parts[:name] end |
#name_with_owner ⇒ Object Also known as: nwo
42 43 44 |
# File 'lib/jekyll-remote-theme/theme.rb', line 42 def name_with_owner [owner, name].join("/") end |
#owner ⇒ Object
30 31 32 |
# File 'lib/jekyll-remote-theme/theme.rb', line 30 def owner theme_parts[:owner] end |
#root ⇒ Object
57 58 59 |
# File 'lib/jekyll-remote-theme/theme.rb', line 57 def root @root ||= File.realpath Dir.mktmpdir(TEMP_PREFIX) end |
#scheme ⇒ Object
38 39 40 |
# File 'lib/jekyll-remote-theme/theme.rb', line 38 def scheme uri&.scheme end |
#valid? ⇒ Boolean
47 48 49 50 51 |
# File 'lib/jekyll-remote-theme/theme.rb', line 47 def valid? return false unless uri && theme_parts && name && owner host && valid_hosts.include?(host) end |