Class: Jekyll::LastModifiedAt::Git
- Inherits:
-
Object
- Object
- Jekyll::LastModifiedAt::Git
- Defined in:
- lib/jekyll-last-modified-at/git.rb
Instance Attribute Summary collapse
-
#site_source ⇒ Object
readonly
Returns the value of attribute site_source.
Instance Method Summary collapse
- #git_repo? ⇒ Boolean
-
#initialize(site_source) ⇒ Git
constructor
A new instance of Git.
- #top_level_directory ⇒ Object
Constructor Details
#initialize(site_source) ⇒ Git
Returns a new instance of Git.
8 9 10 11 |
# File 'lib/jekyll-last-modified-at/git.rb', line 8 def initialize(site_source) @site_source = site_source @is_git_repo = nil end |
Instance Attribute Details
#site_source ⇒ Object (readonly)
Returns the value of attribute site_source.
6 7 8 |
# File 'lib/jekyll-last-modified-at/git.rb', line 6 def site_source @site_source end |
Instance Method Details
#git_repo? ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll-last-modified-at/git.rb', line 25 def git_repo? return @is_git_repo unless @is_git_repo.nil? @is_git_repo = begin Dir.chdir(@site_source) do Executor.sh("git", "rev-parse", "--is-inside-work-tree").eql?("true") end rescue StandardError false end end |
#top_level_directory ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jekyll-last-modified-at/git.rb', line 13 def top_level_directory return unless git_repo? @top_level_directory ||= begin Dir.chdir(@site_source) do @top_level_directory = File.join(Executor.sh("git", "rev-parse", "--show-toplevel"), ".git") end rescue StandardError "" end end |