Sha256: 71b190e34e60bdc448c6ed44395ac12123bccf7468fa0d922ce76744052ea923

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

module Nrb
  module Commands
    class InsideGroup < Thor::Group
      include Thor::Actions

      def self.warning
        'NOTE: Available inside a NinjaRuby project' unless Nrb.inside?
      end

      def self.desc_with_warning(description)
        self.desc [description, warning].compact.join('. ')
      end

      def self.source_root
        File.expand_path('..', __dir__)
      end

      def check_inside?
        return if Nrb.inside?
        klass_name = self.class.to_s.split('::').last
        say "You need to be inside a NinjaRuby folder to run the #{klass_name} command."
        exit
      end

      private

      def require_main_file
        assumed_file_name = "#{Nrb.root.split('/').last}.rb"
        assumed_file_path = File.join(Nrb.root, assumed_file_name)

        if File.exist?(assumed_file_path)
          require File.join(Nrb.root, assumed_file_name)
        else
          say 'Could not load file :(.'
          exit
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nrb-1.0.0 lib/nrb/commands/inside_group.rb