Module: Geb

Defined in:
lib/geb.rb,
lib/geb/cli.rb,
lib/geb/git.rb,
lib/geb/page.rb,
lib/geb/site.rb,
lib/geb/config.rb,
lib/geb/server.rb,
lib/geb/partial.rb,
lib/geb/defaults.rb,
lib/geb/template.rb,
lib/geb/site/core.rb,
lib/geb/utilities.rb,
lib/geb/site/build.rb,
lib/geb/site/remote.rb,
lib/geb/site/release.rb,
lib/geb/commands/init.rb,
lib/geb/site/template.rb,
lib/geb/commands/build.rb,
lib/geb/commands/remote.rb,
lib/geb/commands/server.rb,
lib/geb/commands/upload.rb,
lib/geb/commands/release.rb,
lib/geb/commands/version.rb

Overview

Version command definition, based on Dry::CLI framework Prints the current version of the Geb

See Also:

Author:

Copyright:

License:

  • MIT

Title:

  • Geb - Version Command

Defined Under Namespace

Modules: CLI, Defaults, Git Classes: Config, Error, Page, Partial, Server, Site, Template

Constant Summary collapse

VERSION =

define the version of the gem

"0.1.12"
@@suppress_log_output =

initialise a flag for suppressing output

false

Class Method Summary collapse

Class Method Details

.copy_paths_to_directory(source_path, paths, destination_path, quiet = false) ⇒ Object

copy the specified file and directory paths to the destination directory

Parameters:

  • source_path (String)

    the source directory

  • paths (Array)

    the paths to copy (still full paths, but from source directory)

  • destination_path (String)

    the destination directory

  • quiet (Boolean) (defaults to: false)

    the flag to suppress output

Raises:

  • (Geb::Error)

    if the any of the file operations fail



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/geb/utilities.rb', line 80

def self.copy_paths_to_directory(source_path, paths, destination_path, quiet = false)

  # step through the resolved template paths and copy them to the site path, taking care of files vs directories
  paths.each do |path|

    # get the relative path of the resolved template path and build the destination path
    relative_template_path = path.gsub(source_path, "")
    destination_file_path = File.join(destination_path, relative_template_path)

    # ensure the destination directory exists
    FileUtils.mkdir_p(File.dirname(destination_file_path))

    # copy the resolved template path to the destination path
    if File.directory?(path)
      Geb.log_start " - copying directory and all sub-directories from #{path} to #{destination_file_path} ... " unless quiet
      FileUtils.cp_r(path, destination_file_path)
    else
      Geb.log_start " - copying file from #{path} to #{destination_file_path} ... " unless quiet
      FileUtils.cp(path, destination_file_path)
    end # if else
    Geb.log "done." unless quiet

  end # each

rescue Exception => e
  raise Geb::Error.new("Failed to copy paths to directory: #{e.message}")

end

.log(message) ⇒ Object

Note:

this method will print a newline character at the end of the message

Note:

this method will print the message to the console if the suppress log output flag is not set

log method for printing messages to the console

Parameters:

  • message (String)

    the message to print



41
42
43
# File 'lib/geb/utilities.rb', line 41

def self.log(message)
  puts message unless @@suppress_log_output
end

.log_start(message) ⇒ Object

Note:

this method will not print a newline character at the end of the message

Note:

this method will print the message to the console if the suppress log output flag is not set

log method for printing messages to the console

Parameters:

  • message (String)

    the message to print



49
50
51
# File 'lib/geb/utilities.rb', line 49

def self.log_start(message)
  print message unless @@suppress_log_output
end

.no_log { ... } ⇒ Object

method to suppress log output within a block

Yields:

  • the block to suppress log output

Returns:

  • (Object)

    the return value of the block



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/geb/utilities.rb', line 56

def self.no_log

  # store the original value of the suppress log output flag (just in case)
  original_value = @@suppress_log_output

  # set the suppress log output flag
  @@suppress_log_output = true

  # yield the block
  yield

ensure

  # reset the suppress log output flag
  @@suppress_log_output = original_value

end