class GithubPagesRakeTasks::State

Keeps all attributes for {GithubPagesRakeTasks::PublishTask}. These attributes control how the task works.

All attributes have sensible defaults which will cause {GithubPagesRakeTasks::PublishTask} to completely overwrite the project's `gh-pages` branch with the contents of the project's `doc` directory.

Most used attributes are {doc_dir}, {project_root}, {repo_url}, and {branch_name}.

Attributes

branch_name[W]
doc_dir[W]
interface[W]
project_root[W]
rake_namespace[W]
remote_name[W]
repo_url[W]
staging_dir[W]

Public Instance Methods

branch_name() click to toggle source

The branch to push documentation to.

The default value is 'gh-pages'

@return [String] the branch name

# File lib/github_pages_rake_tasks/state.rb, line 65
def branch_name
  @branch_name ||= 'gh-pages'
end
doc_dir() click to toggle source

The directory, relative to {project_root}, that contains the documentation to publish to GitHub.

The default value is 'doc'

@return [String] directory

# File lib/github_pages_rake_tasks/state.rb, line 28
def doc_dir
  @doc_dir ||= 'doc'
end
interface() click to toggle source

An object that implements all methods that touch the world outside of the PublishTask class. This includes dealing with the file system, issuing shell commands, etc.

The default value is a new instance of {GithubPagesRakeTasks::Interface}

@note {interface} is used for mocking during testing of this gem and is probably

not useful for users of this gem.

@return [GithubPagesRakeTasks::Instance] an interface object

# File lib/github_pages_rake_tasks/state.rb, line 155
def interface
  @interface ||= Interface.new
end
project_root() click to toggle source

The absolute path to the project's Git repository. {doc_dir} is relative to this path.

The default value is the value returned from `git rev-parse –show-toplevel` when run in the current working directory

@return [String] directory

# File lib/github_pages_rake_tasks/state.rb, line 41
def project_root
  @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
end
quiet() click to toggle source

@!attribute quiet Silence all output from the `github-pages:publish` task.

When {quiet} is true, the `github-pages:publish` task will not emit any output

unless there is an error.

Setting {quiet} to true will also set {verbose} to false.

The default value is false

@return [Boolean] the quiet flag value

# File lib/github_pages_rake_tasks/state.rb, line 99
def quiet
  return @quiet if instance_variable_defined?(:@quiet)

  @quiet = false
end
quiet=(value) click to toggle source
# File lib/github_pages_rake_tasks/state.rb, line 105
def quiet=(value)
  @quiet = value
  @verbose = false if quiet
end
rake_namespace() click to toggle source

The Rake namespace for the publish task.

The default value is 'github-pages'

@return [String] Rake namespace

# File lib/github_pages_rake_tasks/state.rb, line 166
def rake_namespace
  @rake_namespace ||= 'github-pages'
end
remote_name() click to toggle source

The name of the Git remote to use for pushing documentation.

The default value is 'origin'

@return [String] the Git remote name

# File lib/github_pages_rake_tasks/state.rb, line 139
def remote_name
  @remote_name ||= 'origin'
end
repo_url() click to toggle source

The URL to the remote repository to push documentation.

The default value is the value returned from `git config –get remote.origin.url`

@return [String] url

# File lib/github_pages_rake_tasks/state.rb, line 52
def repo_url
  @repo_url ||= Dir.chdir(project_root) do |_path|
    interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
  end
end
staging_dir() click to toggle source

The directory where the documentation is staged prior to pushing to the Git remote. All files are copied from {doc_dir} to {staging_dir} where the push to the Git remote is done.

@note This directory is deleted at the end of the publish task.

The default value is a temporary directory created with [Dir.mktmpdir](ruby-doc.org/stdlib-2.6.3/libdoc/tmpdir/rdoc/Dir.html) with the prefix 'github-pages-publish-'

@return [String] a temporary directory.

# File lib/github_pages_rake_tasks/state.rb, line 82
def staging_dir
  @staging_dir ||= interface.mktmpdir('github-pages-publish-')
end
verbose() click to toggle source

@!attribute verbose Make the `github-pages:publish` emit extra output.

When {verbose} is true, the `github-pages:publish` task will emit extra output

that is useful for debugging.

Setting {verbose} to true will also set {quiet} to false.

The default value is false

@return [Boolean] the verbose flag value

# File lib/github_pages_rake_tasks/state.rb, line 122
def verbose
  return @verbose if instance_variable_defined?(:@verbose)

  @verbose = false
end
verbose=(value) click to toggle source
# File lib/github_pages_rake_tasks/state.rb, line 128
def verbose=(value)
  @verbose = value
  @quiet = false if verbose
end