Sha256: cbd50c122982c0a10a2c9533d920dea0496649e3e9e7f8109781525b1728e228

Contents?: true

Size: 638 Bytes

Versions: 24

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

require_relative "theme_presenter"

module Theme
  module Presenters
    class ThemesPresenter
      ORDER_BY_ROLE = %w(live unpublished development)

      def initialize(ctx, root)
        @ctx = ctx
        @root = root
      end

      def all
        all_themes
          .sort_by { |theme| order_by_role(theme) }
          .map { |theme| ThemePresenter.new(theme) }
      end

      private

      def order_by_role(theme)
        ORDER_BY_ROLE.index(theme.role) || ORDER_BY_ROLE.size
      end

      def all_themes
        ShopifyCLI::Theme::Theme.all(@ctx, root: @root)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
shopify-cli-2.27.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.26.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.25.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.24.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.23.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.22.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.21.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.20.1 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.20.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.19.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.18.1 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.18.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.17.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.16.1 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.16.0 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.15.6 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.15.5 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.15.4 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.15.3 lib/project_types/theme/presenters/themes_presenter.rb
shopify-cli-2.15.2 lib/project_types/theme/presenters/themes_presenter.rb