Class: Detroit::Grancher
- Inherits:
-
Tool
- Object
- Tool
- Detroit::Grancher
- Includes:
- Standard
- Defined in:
- lib/detroit-grancher.rb
Overview
This tool may only works with Ruby 1.8.x.
This tool copies designated files to a git branch. This is useful for dealing with situations like GitHub’s gh-pages branch for hosting project websites (a poor design copied from the Git project itself).
IMPORTANT! Grancher tool is being deprecated in favor of the new GitHub tool. Grancher has issues with Ruby 1.9 (due to encoding problems in Gash library) that show no signs of being fixed.
The following stations of the standard toolchain are targeted:
-
:pre_publish
-
:publish
Constant Summary collapse
- MANPAGE =
Location of manpage for tool.
File.dirname(__FILE__) + '/../man/detroit-grancher.5'
Instance Attribute Summary collapse
-
#branch ⇒ Object
The brach into which to save the files.
-
#keep ⇒ Object
List of any files/directories to not remove from the branch.
-
#keep_all ⇒ Object
Do not remove any files from the branh.
-
#remote ⇒ Object
The remote to use (defaults to ‘origin’).
-
#sitemap ⇒ Object
List of directories and files to transfer.
Instance Method Summary collapse
-
#assemble?(station, options = {}) ⇒ Boolean, Symbol
This tool ties into the ‘pre_publish` and `publish` stations of the standard assembly.
-
#grancher ⇒ Object
Cached Grancter instance.
-
#prerequisite ⇒ void
Initialize defaults.
-
#publish ⇒ Object
Push files to remote.
-
#transfer ⇒ Object
Commit file to branch.
Instance Attribute Details
#branch ⇒ Object
The brach into which to save the files.
49 50 51 |
# File 'lib/detroit-grancher.rb', line 49 def branch @branch end |
#keep ⇒ Object
List of any files/directories to not remove from the branch.
61 62 63 |
# File 'lib/detroit-grancher.rb', line 61 def keep @keep end |
#keep_all ⇒ Object
Do not remove any files from the branh.
64 65 66 |
# File 'lib/detroit-grancher.rb', line 64 def keep_all @keep_all end |
#remote ⇒ Object
The remote to use (defaults to ‘origin’).
52 53 54 |
# File 'lib/detroit-grancher.rb', line 52 def remote @remote end |
#sitemap ⇒ Object
List of directories and files to transfer. If a single directory entry is given then the contents of that directory will be transfered. Otherwise this can be an associative array or hash mapping seource to destination.
71 72 73 |
# File 'lib/detroit-grancher.rb', line 71 def sitemap @sitemap end |
Instance Method Details
#assemble?(station, options = {}) ⇒ Boolean, Symbol
This tool ties into the ‘pre_publish` and `publish` stations of the standard assembly.
127 128 129 130 131 |
# File 'lib/detroit-grancher.rb', line 127 def assemble?(station, ={}) return :transfer if station == :pre_publish return :publish if station == :publish return false end |
#grancher ⇒ Object
Cached Grancter instance.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/detroit-grancher.rb', line 84 def grancher @grancher ||= ::Grancher.new do |g| g.branch = branch g.push_to = remote #g.repo = repo if repo # defaults to '.' g.keep(*keep) if keep g.keep_all if keep_all #g.message = (quiet? ? '' : 'Tranferred site files to #{branch}.') sitemap.each do |(src, dest)| trace "transfer: #{src} => #{dest}" dest = nil if dest == '.' if directory?(src) dest ? g.directory(src, dest) : g.directory(src) else dest ? g.file(src, dest) : g.file(src) end end end end |
#prerequisite ⇒ void
Does project provide the site directory?
This method returns an undefined value.
Initialize defaults.
41 42 43 44 45 46 |
# File 'lib/detroit-grancher.rb', line 41 def prerequisite @branch ||= 'gh-pages' @remote ||= 'origin' @sitemap ||= default_sitemap #@keep_all ||= trial? end |
#publish ⇒ Object
Push files to remote.
117 118 119 120 121 |
# File 'lib/detroit-grancher.rb', line 117 def publish require 'grancher' grancher.push report "Pushed site files to #{remote}." end |
#transfer ⇒ Object
Commit file to branch.
109 110 111 112 113 114 |
# File 'lib/detroit-grancher.rb', line 109 def transfer sleep 1 # FIXME: had to pause so grancher will not bomb! require 'grancher' grancher.commit report "Tranferred site files to #{branch}." end |