Module: Softcover::Commands::Deployment

Extended by:
Deployment
Includes:
Utils
Included in:
Deployment
Defined in:
lib/softcover/commands/deployment.rb

Constant Summary

Constants included from Utils

Utils::UNITS

Instance Method Summary collapse

Methods included from Utils

#add_highlight_class!, #as_size, #current_book, #digest, #executable, #execute, #in_book_directory?, #logged_in?, #mkdir, #path, #reset_current_book!, #rm, #silence, #source, #tmpify, #write_pygments_file

Instance Method Details

#commands(lines) ⇒ Object

Returns the commands from the given lines. We skip comments and blank lines.



36
37
38
39
# File 'lib/softcover/commands/deployment.rb', line 36

def commands(lines)
  skip = /(^\s*#|^\s*$)/
  lines.reject { |line| line =~ skip }.join("\n")
end

#custom_commandsObject

Returns custom commands (if any).



25
26
27
# File 'lib/softcover/commands/deployment.rb', line 25

def custom_commands
  commands(File.readlines(deploy_config).map(&:strip))
end

#default_commandsObject

Returns the default commands.



19
20
21
22
# File 'lib/softcover/commands/deployment.rb', line 19

def default_commands
  commands(['softcover build:all', 'softcover build:preview',
            'softcover publish'])
end

#deploy!Object

Deploy a book by building and publishing it. The deploy steps can be customized using ‘.poly-publish` in the book project’s home directory.



10
11
12
13
14
15
16
# File 'lib/softcover/commands/deployment.rb', line 10

def deploy!
  if File.exist?('.softcover-deploy') && !custom_commands.empty?
    execute custom_commands
  else
    execute default_commands
  end
end

#deploy_configObject

Returns the filename for configuring ‘softcover deploy`.



30
31
32
# File 'lib/softcover/commands/deployment.rb', line 30

def deploy_config
  '.softcover-deploy'
end