Sha256: ead596adb774200820083d1f90a53296f2dc0e13e2d6ed4a6da54fa02e408736
Contents?: true
Size: 629 Bytes
Versions: 5
Compression:
Stored size: 629 Bytes
Contents
class AdminEditorPage < Page class Editor attr_reader :name, :command def exists?; path.present?; end def path; @path ||= `which #{@command}`.strip; end def edit(site); `#{path} #{site.root_directory}`; end def initialize(name, command) @name = name @command = command end end EDITORS = [Editor.new('TextMate', 'mate')] def self.available_editors @available_editors ||= EDITORS.select(&:exists?) end respond_to :get do with :html do if params['editor'] EDITORS.find {|e| e.command == params['editor']}.try(:edit, site) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems