Class: Dugway::Cli::Build

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/dugway/cli/build.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destination_rootObject



22
23
24
# File 'lib/dugway/cli/build.rb', line 22

def self.destination_root
  File.join(Dir.pwd, 'build')
end

.source_rootObject



18
19
20
# File 'lib/dugway/cli/build.rb', line 18

def self.source_root
  File.join(Dir.pwd, 'source')
end

Instance Method Details

#buildObject



38
39
40
41
42
43
44
45
46
# File 'lib/dugway/cli/build.rb', line 38

def build
  Zip::ZipFile.open(build_file, Zip::ZipFile::CREATE) do |zipfile|
    theme.files.each do |file|
      zipfile.get_output_stream(file) do |f|
        f << theme.build_file(file)
      end
    end
  end
end

#create_destinationObject



34
35
36
# File 'lib/dugway/cli/build.rb', line 34

def create_destination
  empty_directory self.class.destination_root
end

#successObject



48
49
50
# File 'lib/dugway/cli/build.rb', line 48

def success
  say_status(:create, "build/#{ build_name }")
end

#validateObject



26
27
28
29
30
31
32
# File 'lib/dugway/cli/build.rb', line 26

def validate
  unless theme.valid?(validate_colors: !options['skip-color-validation'], validate_layout_attributes: !options['skip-layout-attribute-validation'])
    theme.errors.each { |error| say(error, :red) }
    say("\nTheme is invalid", :red)
    exit(1)
  end
end