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, destination, message, handler) ⇒ Deployer
constructor
A new instance of Deployer.
Constructor Details
#initialize(git, source, destination, message, handler) ⇒ Deployer
Returns a new instance of Deployer.
9 10 11 12 13 14 15 |
# File 'lib/ghpages_deploy/deployer.rb', line 9 def initialize(git, source, destination, , handler) @git = git @source = source @destination = destination @handler = handler = || "Deployed to '#{@destination}'." 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?
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ghpages_deploy/deployer.rb', line 32 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
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ghpages_deploy/deployer.rb', line 17 def deploy deploy_site_to(@destination) @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 $stdout.puts "Commit made with message: #{@message}" end end |