Class: GithubPagesRakeTasks::Interface

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/github_pages_rake_tasks/interface.rb

Overview

Whenever the publish task has to interact with things outside of itself, it uses an instance of the interface class. This makes the tests easy to mock.

Inject an object into an instance of PublishTask in order to mock the task's interaction with the outside world.

Examples:

interface = Interface.new
interface.chdir(path) do |path|
  interface.sh('git clone https://github.com/jcouball/project')
end
PublishTask.new do |t|
  t.interface = Object.new
    def chdir(path); end
    ...
  end
end

See Also:

Instance Method Summary collapse

Constructor Details

#initialize

Creates a new interface object

This object will delegate methods to the objects passed in as defined in the Forwardable def_delegators above.

Examples:

interface = GithubPagesRakeTasks.new
interface.chdir('test') do
  interface.cp_r(src, dest)
end


57
58
59
60
61
# File 'lib/github_pages_rake_tasks/interface.rb', line 57

def initialize
  @file_utils = Rake::FileUtilsExt
  @dir = Dir
  @file = File
end