Sha256: e7133d0d893094621c539a9f98684ffb0650d9816eb945095d02b5a51d3c3925

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'tempfile'
require 'pathname'
require 'yaml'
require 'fileutils'

module Helpers
  module Generator
    ROOT = File.join(Dir.tmpdir,'ore')

    def generate!(path,options={})
      path = File.join(ROOT,path)

      @generator = Ore::Generator.new(
        [path],
        options.merge(:quiet => true)
      )
      @generator.invoke_all

      @path = Pathname.new(path)
      @gemspec = YAML.load_file(@path.join('gemspec.yml'))
    end

    def rspec_opts
      @path.join('.rspec').read
    end

    def yard_opts
      @path.join('.yardopts').read
    end

    def document
      unless @document
        @document = []

        @path.join('.document').read.each_line do |line|
          unless (line.empty? && line =~ /\s*\#/)
            @document << line.strip
          end
        end
      end

      return @document
    end

    def gitignore
      unless @gitignore
        @gitignore = []

        @path.join('.gitignore').read.each_line do |line|
          unless (line.empty? && line =~ /\s*\#/)
            @gitignore << line.strip
          end
        end
      end

      return @gitignore
    end

    def cleanup!
      FileUtils.rm_r(ROOT)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ore-0.7.2 spec/helpers/generator.rb