Sha256: f268892278ac204f59112d194b28dc3aef7fa60a56035413eeabb0b704189039

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

module Tay
  module CLI
    module Helpers
      DEFAULT_TAYFILE = 'Tayfile'

      protected

      def spec(bust_cache = false)
        @spec = nil if bust_cache
        @spec ||= get_specification
      end

      def get_specification(path = nil)
        path = path ? Pathname.new(path) : tayfile_path

        unless path.exist?
          if options['tayfile'].nil?
            message = "No Tayfile was found in the current directory"
          else
            message = "#{path} does not exist"
          end
          raise SpecificationNotFound.new(message)
        end

        eval(File.open(path).read)
      end

      def tayfile_path
        Pathname.new(options['tayfile'] || DEFAULT_TAYFILE).expand_path
      end

      ##
      # Return the base directory for this extension
      def base_dir
        tayfile_path.dirname
      end

      ##
      # Return the src directory for this extension
      def src_dir
        base_dir.join('src')
      end

      ##
      # Return the build directory for this extension, respecting any command
      # line option
      def build_dir
        base_dir.join(options['build-directory'] || 'build')
      end

      ##
      # Detect if the user has coffee-script in their Gemfile
      def using_coffeescript?
        Gem.loaded_specs.keys.include?('coffee-script')
      end

      ##
      # Detect if the user has haml in their Gemfile
      def using_haml?
        Gem.loaded_specs.keys.include?('haml')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tay-0.1.0 lib/tay/cli/helpers.rb
tay-0.0.5 lib/tay/cli/helpers.rb
tay-0.0.4 lib/tay/cli/helpers.rb