Sha256: 10aedb0af971dabd2b554133e6207e51c26ab277f8781ee802febd15524705b5

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

namespace :ci do
  namespace :dependencies do
    desc 'setup'
    task :setup do
      require 'highline/import'
      ENV['PROJECT_NAME'] = gem_name || ask('Project Name: ')
    end

    desc 'process'
    task process: :setup do
      # Usage: bundle exec rake ci:dependencies:process
      arr = [
        ENV['PROJECT_NAME'],
        RUBY_VERSION,
        gem_requirement('rails'),
        gem_requirement('activemodel-caution'),
        gem_requirement('ndr_dev_support'),
        gem_requirement('ndr_error'),
        gem_requirement('ndr_import'),
        gem_requirement('ndr_support'),
        gem_requirement('ndr_ui'),
        gem_requirement('ndr_workflow'),
        jquery_version,
        bootstrap_version
      ]
      puts "| #{arr.join(' | ')} |"
    end

    def current_dependencies
      @current_dependencies ||= Bundler.environment.current_dependencies
    end

    # There is probably a simpler way of getting this information
    def gem_name
      self_dependency = current_dependencies.detect do |dep|
        dep.source && dep.source.path.to_s == '.'
      end
      self_dependency && self_dependency.name
    end

    def gem_requirement(name)
      dependency = current_dependencies.detect { |dep| dep.name == name }

      return '-' if dependency.nil? || (dependency.source && dependency.source.path.to_s == '.')
      return "@#{dependency.source.ref}@" if dependency.source
      dependency.requirement.to_s
    end

    def jquery_version
      Jquery::Rails::JQUERY_VERSION
    rescue NameError
      '-'
    end

    def bootstrap_version
      require 'bootstrap-sass'
      Bootstrap::VERSION
    rescue LoadError
      '-'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ndr_dev_support-3.1.2 lib/tasks/ci/dependencies.rake