Sha256: de52e05f1671b162b6d95b4bbb4586404e152aadea1d87924be95f188deb68bd

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

#
# Ronin Gen - A Ruby library for Ronin that provides various generators.
#
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

require 'ronin/gen/file_generator'

module Ronin
  module Gen
    #
    # A {FileGenerator} class for creating Ruby files.
    #
    class SourceCodeGenerator < FileGenerator

      class_option :editor, :default => ENV['EDITOR']
      class_option :no_edit, :type => :boolean, :default => false

      #
      # Generates the source-code file and spawns a text-editor.
      #
      def self.generate(options={},arguments=[],&block)
        generator = super(options,arguments,&block)

        if (generator.options.no_edit? && generator.options.editor)
          system(generator.options.editor,generator.path)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-gen-1.0.0.pre2 lib/ronin/gen/source_code_generator.rb
ronin-gen-1.0.0.pre1 lib/ronin/gen/source_code_generator.rb