Sha256: 7ef5b9c9b0b622ba971fe261861ef23b609351997ff26e8e5f8ba8073269c2a3

Contents?: true

Size: 1.95 KB

Versions: 46

Compression:

Stored size: 1.95 KB

Contents

module Simp; end
module Simp::Rake
  class Rubygem < ::Rake::TaskLib
    def initialize( package, rakefile_dir = File.pwd )
      @package      = package
      @rakefile_dir = rakefile_dir
      define
    end

    def define_clean_paths
      CLEAN.include "#{@package}-*.gem"
      CLEAN.include 'pkg'
      CLEAN.include 'dist'
      CLEAN.include 'spec/acceptance/files/testpackage/dist'
      Find.find( @rakefile_dir ) do |path|
        if File.directory? path
          CLEAN.include path if File.basename(path) == 'tmp'
        else
          Find.prune
        end
      end
    end

    def define
      define_clean_paths

      desc 'Ensure gemspec-safe permissions on all files'
      task :chmod do
        gemspec = File.expand_path( "#{@package}.gemspec", @rakefile_dir ).strip
        spec = Gem::Specification::load( gemspec )
        spec.files.each do |file|
          FileUtils.chmod 'go=r', file
        end
      end

      namespace :pkg do
        desc "build rubygem package for #{@package}"
        task :gem => :chmod do
          Dir.chdir @rakefile_dir
          Dir['*.gemspec'].each do |spec_file|
            cmd = %Q{SIMP_RPM_BUILD=#{ENV.fetch('SIMP_RPM_BUILD',1)} bundle exec gem build "#{spec_file}"}
            sh cmd
            FileUtils.mkdir_p 'dist'
            FileUtils.mv Dir.glob("#{@package}*.gem"), 'dist/'
          end
        end

        desc "build and install rubygem package for #{@package}"
        task :install_gem => [:clean, :gem] do
          Dir.chdir @rakefile_dir
          Dir.glob("dist/#{@package}*.gem") do |pkg|
            sh %Q{bundle exec gem install #{pkg}}
          end
        end
      end

      desc "Run acceptance tests"
      RSpec::Core::RakeTask.new(:acceptance) do |t|
        t.pattern = 'spec/acceptance'
      end

      desc "Run spec tests"
      RSpec::Core::RakeTask.new(:spec) do |t|
          t.rspec_opts = ['--color']
          t.pattern = 'spec/lib/simp/**/*_spec.rb'
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
simp-rake-helpers-3.7.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.6.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.5.1 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.5.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.4.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.3.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.2.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.1.4 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.1.3 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.1.2 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.1.1 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.1.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.0.2 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.0.1 lib/simp/rake/rubygem.rb
simp-rake-helpers-3.0.0 lib/simp/rake/rubygem.rb
simp-rake-helpers-2.5.7 lib/simp/rake/rubygem.rb
simp-rake-helpers-2.5.5 lib/simp/rake/rubygem.rb
simp-rake-helpers-2.5.4 lib/simp/rake/rubygem.rb
simp-rake-helpers-2.5.3 lib/simp/rake/rubygem.rb
simp-rake-helpers-2.5.2 lib/simp/rake/rubygem.rb