Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Fixes Posix Spawn and adds CI #98

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
- { ruby: '2.7' }
- { ruby: '3.0' }
- { ruby: '3.1' }
- { ruby: '3.2' }
name: test (${{ matrix.entry.ruby }})
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.entry.ruby }}
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
- run: bundle exec rake spec
continue-on-error: ${{ matrix.entry.allowed-failure }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Last Modified At Plugin

![Rake Status](https://github.com/gjtorikian/jekyll-last-modified-at/actions/workflows/test.yml/badge.svg)


A liquid tag for Jekyll to indicate the last time a file was modified.

This plugin determines a page's last modified date by checking the last Git commit date of source files. In the event Git is not available, the file's `mtime` is used.
Expand Down
1 change: 0 additions & 1 deletion jekyll-last-modified-at.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/*.rb']

s.add_dependency 'jekyll', '>= 3.7', ' < 5.0'
s.add_dependency 'posix-spawn', '~> 0.3.9'

s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', '~> 3.4'
Expand Down
28 changes: 4 additions & 24 deletions lib/jekyll-last-modified-at/executor.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
# frozen_string_literal: true

require 'posix/spawn'
require 'open3'

module Jekyll
module LastModifiedAt
module Executor
extend POSIX::Spawn

def self.sh(*args)
r, w = IO.pipe
e, eo = IO.pipe
pid = spawn(*args,
:out => w, r => :close,
:err => eo, e => :close)

if pid.positive?
w.close
eo.close
out = r.read
err = e.read
::Process.waitpid(pid)
"#{out} #{err}".strip if out
end
ensure
[r, w, e, eo].each do |io|
begin
io.close
rescue StandardError
nil
end
end
stdout_str, stderr_str, status = Open3.capture3(*args)
return "#{stdout_str} #{stderr_str}".strip if status.success?
end

end
end
end