Sha256: b6928fb5cf488a735c16c00072df355a204f7c03fb6887699aed29ef689d8737

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 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 = Dir.chdir(@path) do
        Gem::Specification.load(@generator.generated_files['[name].gemspec'])
      end
    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

6 entries across 6 versions & 1 rubygems

Version Path
ore-0.10.0 spec/helpers/generator.rb
ore-0.9.4 spec/helpers/generator.rb
ore-0.9.3 spec/helpers/generator.rb
ore-0.9.2 spec/helpers/generator.rb
ore-0.9.1 spec/helpers/generator.rb
ore-0.9.0 spec/helpers/generator.rb