Class: Jekyll::Agda::Runner
- Inherits:
-
Object
- Object
- Jekyll::Agda::Runner
- Defined in:
- lib/jekyll/agda/runner.rb
Constant Summary collapse
- RE_LAGDA_MD_EXT =
/\.lagda\.md$/i
- RE_AGDA_GENERATED_HTML_PATH =
/(?<=\().*?.html(?=\))/
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#successful ⇒ Object
readonly
Returns the value of attribute successful.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(resource, work_dir) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(resource, work_dir) ⇒ Runner
Returns a new instance of Runner.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/agda/runner.rb', line 14 def initialize(resource, work_dir) @resource = resource @source = Pathname.new(@resource.path) @work_dir = Pathname.new(work_dir) @digest = @work_dir.join(@source.basename.sub(RE_LAGDA_MD_EXT, ".md5")) @target = @work_dir.join(@source.basename.sub(RE_LAGDA_MD_EXT, ".md")) @extras = @work_dir.join(@source.basename.sub(RE_LAGDA_MD_EXT, ".dep")) @dependencies = [] @successful = nil end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
12 13 14 |
# File 'lib/jekyll/agda/runner.rb', line 12 def dependencies @dependencies end |
#successful ⇒ Object (readonly)
Returns the value of attribute successful.
12 13 14 |
# File 'lib/jekyll/agda/runner.rb', line 12 def successful @successful end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
12 13 14 |
# File 'lib/jekyll/agda/runner.rb', line 12 def target @target end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jekyll/agda/runner.rb', line 27 def execute new_hash = Digest::MD5.hexdigest(@resource.content) if [@digest, @target, @extras].all?(:exist?) if new_hash == @digest.read @successful = true @dependencies = Marshal.load(@extras.read) return end end log_takeoff stdout, _stderr, status = run_agda if (@successful = status.success?) @digest.write(new_hash) @dependencies = stdout.scan(RE_AGDA_GENERATED_HTML_PATH) @extras.write(Marshal.dump(@dependencies)) log_success else log_failure end end |