Sha256: 0cd06d6405b1f89b752e70bf7d76fa86fd910d35c19f2af044ce9ba091ce94a8

Contents?: true

Size: 1.87 KB

Versions: 18

Compression:

Stored size: 1.87 KB

Contents

module Rake
  module Funnel
    module Integration
      module TeamCity
        class NUnitPlugin
          ENV_VAR = 'teamcity.dotnet.nunitaddin'

          class << self
            def setup(nunit_executable)
              addins = get_addin_dir(ENV[ENV_VAR]) || return
              nunit, version = read_version(nunit_executable) || return

              addin_files = find_teamcity_addins(addins, version) || return

              copy_addin_files(nunit, addin_files, version)
            end

            private
            def get_addin_dir(source)
              return nil unless source

              File.expand_path(source)
            end

            def read_version(executable)
              nunit = Rake::Funnel::Support::Which.which(executable) || return
              version = Rake::Funnel::Support::BinaryVersionReader.read_from(nunit)

              unless version.file_version
                Rake.rake_output_message("Could read version from NUnit executable in #{nunit}")
                return
              end

              [nunit, version.file_version.split('.').take(3).join('.')]
            end

            def find_teamcity_addins(addins, version)
              addin_files = Dir.glob("#{addins}-#{version}.*")

              if addin_files.none?
                Rake.rake_output_message("Could not find TeamCity NUnit addin for version #{version} in #{addins}")
                return
              end

              addin_files
            end

            def copy_addin_files(nunit, addin_files, version)
              Rake.rake_output_message("Installing TeamCity NUnit addin for version #{version} in #{nunit}")

              destination = File.join(File.dirname(nunit), 'addins')

              RakeFileUtils.mkdir_p(destination)
              RakeFileUtils.cp(addin_files, destination, preserve: true)
            end
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.17.0 lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.16.1 lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.16.0 lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.15.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.14.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.13.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.12.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.11.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.10.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.9.1.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.9.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.8.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.7.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.6.1.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.6.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.5.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb
rake-funnel-0.4.0.pre lib/rake/funnel/integration/teamcity/nunit_plugin.rb