Sha256: c14c1b402d506e00f06ef9e9e48620cb68673c3daa21244e97db83e1e4035ad2

Contents?: true

Size: 1.2 KB

Versions: 28

Compression:

Stored size: 1.2 KB

Contents

require 'zip/zip'

module Dugway
  module Cli
    class Build < Thor::Group
      include Thor::Actions
      
      def self.source_root
        File.join(Dir.pwd, 'source')
      end
      
      def self.destination_root
        File.join(Dir.pwd, 'build')
      end
      
      def validate
        unless theme.valid?
          theme.errors.each { |error| say(error, :red) }
          raise "Theme is invalid"
        end
      end
      
      def create_destination
        empty_directory self.class.destination_root
      end
      
      def build
        Zip::ZipFile.open(build_file, Zip::ZipFile::CREATE) { |zipfile|
          theme.files.each { |file|
            zipfile.get_output_stream(file) { |f|
              f << theme.build_file(file)
            }
          }
        }
      end
      
      def success
        say_status(:create, "build/#{ build_name }")
      end
      
      private
      
      def theme
        @theme ||= Dugway.theme
      end
      
      def build_name
        @build_name ||= "#{ theme.name.parameterize }-#{ theme.version }.zip"
      end
      
      def build_file
        @build_file ||= File.join(self.class.destination_root, build_name)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
dugway-0.10.3 lib/dugway/cli/build.rb
dugway-0.10.2 lib/dugway/cli/build.rb
dugway-0.10.1 lib/dugway/cli/build.rb
dugway-0.10.0 lib/dugway/cli/build.rb
dugway-0.9.0 lib/dugway/cli/build.rb
dugway-0.8.4 lib/dugway/cli/build.rb
dugway-0.8.3 lib/dugway/cli/build.rb
dugway-0.8.2 lib/dugway/cli/build.rb
dugway-0.8.1 lib/dugway/cli/build.rb
dugway-0.8.0 lib/dugway/cli/build.rb
dugway-0.7.1 lib/dugway/cli/build.rb
dugway-0.7.0 lib/dugway/cli/build.rb
dugway-0.6.7 lib/dugway/cli/build.rb
dugway-0.6.6 lib/dugway/cli/build.rb
dugway-0.6.5 lib/dugway/cli/build.rb
dugway-0.6.4 lib/dugway/cli/build.rb
dugway-0.6.3 lib/dugway/cli/build.rb
dugway-0.6.2 lib/dugway/cli/build.rb
dugway-0.6.1 lib/dugway/cli/build.rb
dugway-0.6.0 lib/dugway/cli/build.rb