Sha256: d43fd5171e01c6c1027ed103e29a2a39b20aabf21d86605122775cf225e1d3b4

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

module AnchorUi
  module Sprockets
    module Assets
      class CoreUi < Base
        include(
          AnchorUi::Core::Assets::Concerns::CoreUi,
          AnchorUi::Core::Assets::Concerns::Zip
        )

        def self.asset_name
          'coreui'
        end

        def update
          download url, zip_path
          unzip
          compile_coreui_scss
          compile_variables_scss
          move_files
          clear
        end

        private

        def zip_name
          "v#{version}.zip"
        end

        def url
          "https://github.com/coreui/coreui/archive/#{zip_name}"
        end

        def stylesheets_destination_path
          stylesheets_path.join asset_name
        end

        def javascripts_destination_path
          javascripts_path.join asset_name
        end

        def extraction_path
          tmp_path.join directory_name
        end

        def javascripts_source_path
          extraction_path.join javascripts_relative_path
        end

        def stylesheets_source_path
          extraction_path.join stylesheets_relative_path
        end

        def templates_path
          root_path.join 'lib/generators/anchor_ui/sprockets/templates'
        end

        def compile_coreui_scss
          super 'coreui'
        end

        def compile_variables_scss
          super(
            <<~SCSS,
              @import
                'bootstrap/functions',
                'bootstrap/variables';

            SCSS
            <<~SCSS

              // Paths
              $coreui-icons-font-path: 'coreui-icons';
            SCSS
          )
        end

        def move_files
          FileUtils.rm_rf javascripts_destination_path
          FileUtils.mv(
            javascripts_source_path,
            javascripts_destination_path
          )
          FileUtils.rm_rf stylesheets_destination_path
          FileUtils.mv(
            stylesheets_source_path,
            stylesheets_destination_path
          )
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anchor_ui-sprockets-5.2.0.1 lib/anchor_ui/sprockets/assets/core_ui.rb