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



837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
# File 'lib/inkmake.rb', line 837

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