Sha256: cfc959729d9487d5137c7470462344fbd6d8579d311a8783a5990fc2caa33ba3

Contents?: true

Size: 796 Bytes

Versions: 3

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

namespace :canard do
  desc 'Upgrades deprecated ability definition syntax and moves the files from abilities to app/abilities'
  task upgrade: :environment do
    require 'rake/clean'
    source_path = 'abilities'
    destination_path = Canard::Abilities.definition_paths.first

    Dir.mkdir(destination_path) unless Dir.exist?(destination_path)

    if Dir.exist?(source_path)
      Dir[File.join(source_path, '*.rb')].each do |input_file|
        input = File.read(input_file)
        output = input.gsub(/abilities_for/, 'Canard::Abilities.for')
        output_file = File.expand_path(File.basename(input_file), destination_path)
        File.write(output_file, output)
        File.delete(input_file)
      end
      Dir.delete(source_path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canard-0.6.2.pre lib/tasks/canard.rake
canard-0.6.1.pre lib/tasks/canard.rake
canard-0.6.0.pre lib/tasks/canard.rake