class SiteHook::Senders::Jekyll::Build

Constants

JEKYLL_SOURCE_VAR

Public Class Methods

new(options) click to toggle source
# File lib/site_hook/sender.rb, line 11
def initialize(options)
  @options = options
end

Public Instance Methods

do_build() click to toggle source
# File lib/site_hook/sender.rb, line 41
def do_build
  jekyll_source = Jekyll.instance_variable_get(JEKYLL_SOURCE_VAR)
  build_dest = Jekyll.instance_variable_get('@build_dest')
  log = Jekyll.instance_variable_get('@log')
  Open3.popen2e({'BUNDLE_GEMFILE' => Pathname(jekyll_source).join('Gemfile').to_path}, "bundle exec jekyll build --source #{Pathname(jekyll_source).realdirpath.to_path} --destination #{Pathname(build_dest).to_path} --config #{Pathname(jekyll_source).join(@options[:config])}") { |in_io, outerr_io, thr|
    pid = thr.pid

    outerr = outerr_io.read.lines
    outerr.each do |line|
      line = Paint.unpaint(line)
      line.squish!
      # Configuration file: /home/ken/sites/iotaspencer.me/_config.yml
      # Source: /home/ken/sites/iotaspencer.me
      # Destination: /var/www/iotaspencer.me
      # Incremental build: disabled. Enable with --incremental
      # Generating...
      # GitHub Metadata: No GitHub API authentication could be found.
      # Some fields may be missing or have incorrect data.
      # done in 6.847 seconds.
      # Auto-regeneration: disabled. Use --watch to enable.
      case
      when line =~ /done in .*/
        log.info(line)
      when line =~ /Generating.../
        log.info(line)
      when line =~ /Configuration file:|Source:|Destination:/
        log.debug(line)
      when line =~ /Incremental build: disabled.|Auto-regeneration/
        print ''
      else
        log.debug line
      end
    end
    thr.value
  }

end
do_grab_version() click to toggle source
# File lib/site_hook/sender.rb, line 17
def do_grab_version
  jekyll_source = Jekyll.instance_variable_get(JEKYLL_SOURCE_VAR)
  log = Jekyll.instance_variable_get('@log')
  begin
    stdout_str, status = Open3.capture2({'BUNDLE_GEMFILE' => Pathname(jekyll_source).join('Gemfile').to_path}, "jekyll --version --source #{jekyll_source}")
    log.info("Jekyll Version: #{stdout_str.chomp!}")
  rescue Errno::ENOENT
    log.fatal('Jekyll not installed! Gem and Webhook will not function')
    Process.kill('INT', Process.pid)
  end
end
do_pull() click to toggle source
# File lib/site_hook/sender.rb, line 29
def do_pull
  fakelog = SiteHook::Log.fake
  reallog = SiteHook::Log.git
  jekyll_source = Jekyll.instance_variable_get(JEKYLL_SOURCE_VAR)
  # build_dest = Jekyll.instance_variable_get('@build_dest')
  g = Git.open(jekyll_source, log: fakelog)
  g.pull
  fakelog.entries.each do |level, entries|
    entries.each { |entry| reallog.send(level.to_s, entry) }
  end
end