Sha256: 3fd117c54c0f21ca33902d36120ec45ef22fe5b36f07c11942ba8f55fc1c3ef0

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'stickler/repository'
module Stickler::Repository
  #
  # A null repository.  It is in most respecs like a Repository::Local that has
  # nothing in it.
  #
  # The response to +root_dir+ is set by default to be the class name, or
  # whatever is passed to the initializer.
  #
  class Null
    # the root directory of the repository, this is set in the constructor
    attr_reader :root_dir

    def initialize( root_dir = self.class.name )
      @root_dir = root_dir
    end

    def empty_string( junk = "" )
      ""
    end
    alias :uri :empty_string
    alias :gems_uri :empty_string

    def nilish( junk = nil, &block )
      nil
    end
    alias :push :nilish
    alias :delete :nilish
    alias :yank :nilish
    alias :get :nilish
    alias :open :nilish
    alias :uri_for_gem :nilish
    alias :full_path_to_gem :nilish
    alias :full_path_to_specification :nilish

    def last_modified_time
      Time.now
    end

    def empty_array( junk = nil )
      []
    end
    alias :specs :empty_array
    alias :latest_specs :empty_array
    alias :search_for :empty_array

    def specs
      Array.new
    end

    def latest_specs
      Array.new
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stickler-2.2.4 lib/stickler/repository/null.rb
stickler-2.2.3 lib/stickler/repository/null.rb