Class: Inkmake

Inherits:
Object
  • Object
show all
Defined in:
lib/inkmake.rb

Defined Under Namespace

Classes: InkFile, InkImage, InkVariant, InkscapeRemote, InkscapeResolution, InkscapeUnit

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verboseObject (readonly)

Returns the value of attribute verbose.



51
52
53
# File 'lib/inkmake.rb', line 51

def verbose
  @verbose
end

Class Method Details

.run(argv) ⇒ Object



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
# File 'lib/inkmake.rb', line 807

def self.run(argv)
  inkfile_path = nil
  inkfile_opts = {}
  OptionParser.new do |o|
    o.banner = "Usage: #{$0} [options] [Inkfile]"
    o.on("-v", "--verbose", "Verbose output") { @verbose = true }
    o.on("-s", "--svg PATH", "SVG source base path") { |v| inkfile_opts[:svg_path] = v }
    o.on("-o", "--out PATH", "Output base path") { |v| inkfile_opts[:out_path] = v }
    o.on("-f", "--force", "Force regenerate (skip time check)") { |v| inkfile_opts[:force] = true }
    o.on("-i", "--inkscape PATH", "Inkscape binary path", "Default: #{InkscapeRemote.path || "not found"}") { |v| @inkscape_path = v }
    o.on("-h", "--help", "Display help") { puts o; exit }
    begin
      inkfile_path = o.parse!(argv).first
    rescue OptionParser::InvalidOption => e
      puts e.message
      exit 1
    end
  end

  inkfile_path = File.expand_path(inkfile_path || "Inkfile", Dir.pwd)

  begin
    raise "Could not find Inkscape binary (maybe try --inkscape?)" if not InkscapeRemote.path
    raise "Inkscape binary #{InkscapeRemote.path} does not exist or is not executable" if not InkscapeRemote.path or not File.executable? InkscapeRemote.path
  rescue StandardError => e
    puts e.message
    exit 1
  end

  begin
    if not InkFile.new(inkfile_path, inkfile_opts).process
      puts "Everything seems to be up to date"
    end
  rescue InkFile::ProcessError, SystemCallError => e
    puts e.message
    exit 1
  end
end