Class: GithubPagesRakeTasks::State

Inherits:
Object
  • Object
show all
Defined in:
lib/github_pages_rake_tasks/state.rb

Overview

Keeps all attributes for PublishTask. These attributes control how the task works.

All attributes have sensible defaults which will cause 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.

Instance Attribute Summary collapse

Instance Attribute Details

#branch_nameString

The branch to push documentation to

The default value is 'gh-pages'.

Examples:

branch_name = 'gh-pages'
branch_name #=> 'gh-pages'

Returns:

  • (String)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#doc_dirString

The directory relative to #project_root containing the documentation

The default value is 'doc'.

Examples:

doc_dir = 'doc'
doc_dir #=> 'doc'

Returns:

  • (String)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#interfaceGithubPagesRakeTasks::Instance

Note:

#interface is used for mocking during testing of this gem and is probably not useful for users of this gem.

The object that implements all methods that touch the 'outside' world

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 Interface

Examples:

interface = GithubPagesRakeTasks::Interface.new

Returns:

  • (GithubPagesRakeTasks::Instance)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#project_rootString

The absolute path to the project's root directory

#doc_dir is relative to this directory.

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

Examples:

project_root = '/home/james/my_project'
project_root #=> '/home/james/my_project'

Returns:

  • (String)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#quietBoolean

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

Examples:

quiet = true
quiet #=> true
verbose #=> false

Returns:

  • (Boolean)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#rake_namespaceString

The Rake namespace for the publish task

The default value is 'github-pages'

Examples:

rake_namespace = 'my-docs'
rake_namespace #=> 'my-docs'

Returns:

  • (String)

    Rake namespace



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#remote_nameString

The name of the Git remote to use for pushing documentation

The default value is 'origin'

Examples:

remote_name = 'my_remote'
remote_name #=> 'my_remote'

Returns:

  • (String)

    the Git remote name



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#repo_urlString

The URL to the remote repository to push documentation

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

Examples:

repo_url = 'https://github.com/main-branch/my_project.git'
repo_url #=> 'https://github.com/main-branch/my_project.git'

Returns:

  • (String)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#staging_dirString

Note:

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

The directory where the documentation is staged for pushing to the Git remote

All files are copied from #doc_dir to #staging_dir where the push to the Git remote is done.

The default value is a temporary directory created with Dir.mktmpdir with the prefix 'github-pages-publish-'

Examples:

staging_dir = ''
staging_dir #=> '/home/james/my_project'

Returns:

  • (String)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end

#verboseBoolean

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

Examples:

verbose = true
verbose #=> true
quiet #=> false

Returns:

  • (Boolean)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/github_pages_rake_tasks/state.rb', line 160

class State
  def doc_dir
    @doc_dir ||= 'doc'
  end

  attr_writer :doc_dir, :project_root, :repo_url, :branch_name, :staging_dir, :remote_name,
              :interface, :rake_namespace

  def project_root
    @project_root ||= interface.send(:`, 'git rev-parse --show-toplevel').chomp
  end

  def repo_url
    @repo_url ||= Dir.chdir(project_root) do |_path|
      interface.send(:`, "git config --get remote.#{remote_name}.url").chomp
    end
  end

  def branch_name
    @branch_name ||= 'gh-pages'
  end

  def staging_dir
    @staging_dir ||= interface.mktmpdir('github-pages-publish-')
  end

  def quiet
    return @quiet if instance_variable_defined?(:@quiet)

    @quiet = false
  end

  def quiet=(value)
    @quiet = value
    @verbose = false if quiet
  end

  def verbose
    return @verbose if instance_variable_defined?(:@verbose)

    @verbose = false
  end

  def verbose=(value)
    @verbose = value
    @quiet = false if verbose
  end

  def remote_name
    @remote_name ||= 'origin'
  end

  def interface
    @interface ||= Interface.new
  end

  def rake_namespace
    @rake_namespace ||= 'github-pages'
  end
end