Sha256: 09dda2c996feaaeaac6bb9ea85fe25c0644a7d28f9d54f93ec0f2edf77104cd5

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 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').open do |file|
          file.each_line do |line|
            unless (line.empty? && line =~ /\s*\#/)
              @document << line.strip
            end
          end
        end
      end

      return @document
    end

    def gitignore
      unless @gitignore
        @gitignore = []

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

      return @gitignore
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ore-0.8.1 spec/helpers/generator.rb
ore-0.8.0 spec/helpers/generator.rb