Class: Brut::CLI::Apps::BuildAssets::Images

Inherits:
BaseCommand show all
Defined in:
lib/brut/cli/apps/build_assets.rb

Instance Attribute Summary

Attributes inherited from Commands::BaseCommand

#parent_command

Instance Method Summary collapse

Methods inherited from BaseCommand

#bootstrap?, #default_rack_env, #friendly_name, #opts

Methods inherited from Commands::BaseCommand

#accepts, #args_description, #argv, #bootstrap?, #commands, #default_rack_env, #delegate_to_command, #env, #env_vars, #execute, #name, #options, #opts, #puts, #stdin, #system!, #theme

Instance Method Details

#descriptionObject



67
# File 'lib/brut/cli/apps/build_assets.rb', line 67

def description = "Copy images to the public folder"

#detailed_descriptionObject



68
69
70
# File 'lib/brut/cli/apps/build_assets.rb', line 68

def detailed_description = %{
This is to ensure that any images your code references will end up in the public directory, so they are served properly. This is not for managing images that may be referenced in CSS files. See the `css` command for information on that.
}

#runObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/brut/cli/apps/build_assets.rb', line 72

def run
  src_dir  = Brut.container.images_src_dir
  dest_dir = Brut.container.images_root_dir

  puts "Syncing images from #{theme.code.render(friendly_name(src_dir.to_s))} to #{theme.code.render(friendly_name(dest_dir.to_s))}"
  rsync_args = [
    "--archive",
    "--verbose",
  ]
  if options.clean?(default: options.env != "production")
    puts "Deleting old images from #{theme.code.render(friendly_name(dest_dir.to_s))}"
    rsync_args << "--delete"
  end
  system! "rsync #{rsync_args.join(' ')} \"#{src_dir}/\" \"#{dest_dir}\""
end