Class: GithubPages::Deployer
- Inherits:
-
Object
- Object
- GithubPages::Deployer
- Defined in:
- lib/ghpages_deploy/deployer.rb
Instance Method Summary collapse
-
#clean_destination(dest) ⇒ Object
remove files that are already cached in the destination directory or have return false when passed to Handler#precheck_delete?.
- #deploy ⇒ Object
-
#initialize(git, source, destinations, handler) ⇒ Deployer
constructor
A new instance of Deployer.
Constructor Details
#initialize(git, source, destinations, handler) ⇒ Deployer
Returns a new instance of Deployer.
9 10 11 12 13 14 |
# File 'lib/ghpages_deploy/deployer.rb', line 9 def initialize(git, source, destinations, handler) @git = git @source = source @destinations = destinations @handler = handler end |
Instance Method Details
#clean_destination(dest) ⇒ Object
remove files that are already cached in the destination directory or have return false when passed to Handler#precheck_delete?
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ghpages_deploy/deployer.rb', line 30 def clean_destination(dest) cached = @git.ls_files(dest) if @handler cached.select! do |file| results = @handler.on_precheck_delete?(file) # a file gets removed if there are no results or any result is false results.empty? || results.inject(&:&) end end @git.remove(*cached) end |
#deploy ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ghpages_deploy/deployer.rb', line 16 def deploy @destinations.keep_if { |dest| deploy_site_to(dest) } @git.stage @handler.on_deploy.flatten.uniq if @handler if @git.staged_modifications('.').empty? $stderr.puts 'No changes detected, not commiting.' else @git.commit_and_push end end |