Sha256: 64018fed8ca1764ad7fa79a873cbebe95c181c900eb7af1ccb049acd615b6964

Contents?: true

Size: 980 Bytes

Versions: 4

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

require 'colorize'
require 'pathname'

module Branch
  module Name
    module Locatable
      module_function

      def home_folder
        Dir.home
      end
      alias global_folder home_folder
      singleton_class.alias_method :global_folder, :home_folder

      def local_folder
        Dir.pwd
      end

      def system_folder
        system_folder = Pathname.new('/')
        unless system_folder.exist? && system_folder.directory?
          puts "WARNING: system folder #{system_folder} does not exist, " \
               "using global folder instead (#{global_folder})".red

          return global_folder
        end
        system_folder.to_s
      end

      def project_folder(options: {})
        return home_folder if options.blank?

        home_folder
      end

      def system_folder_equals_global_folder?
        syetem_folder == global_folder
      end

      def temp_folder
        Dir.tmpdir
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
branch-name-2.0.1.pre.beta lib/branch/name/locatable.rb
branch-name-2.0.0.pre.beta lib/branch/name/locatable.rb
branch-name-1.0.1.pre.beta lib/branch/name/locatable.rb
branch-name-1.0.0.pre.beta lib/branch/name/locatable.rb