Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
uoy-faculty-rake / lib / faculty / rake / init_shared.rb
Size: Mime:
# frozen_string_literal: true

require 'rake/tasklib'
require_relative 'helpers'

module Faculty
  module Rake
    # Functions for initializing a new app
    module InitShared
      private

      def create_base_branch
        puts bold 'Creating base branch to aid merging changes from the template in the future'
        system 'git branch base'
        system 'git push --quiet --set-upstream origin base'
      end

      def remove_from_rakefile
        system "sed -i '/#{self.class.name}.new/d' Rakefile"
      end

      def rename_within_files(rename_list)
        title_parts = []
        substitutions = []

        rename_list.each do |rename|
          title_parts.push "#{rename[:from]} -> #{rename[:to]}"
          substitutions.push "'s/#{rename[:from]}/#{rename[:to]}/g'"
        end

        puts bold "Rename #{title_parts.join ', '}"
        system "find ./ -type d -name '.git' -prune -o -type f " \
               "-exec sed -ri -e #{substitutions.join ' -e '} {} \\; -print"
      end
    end
  end
end