Sha256: 90fa6e890ab6f66a8e39ec0dc718712346b6e6c3f73ed8fea9038799dca9e683

Contents?: true

Size: 717 Bytes

Versions: 118

Compression:

Stored size: 717 Bytes

Contents

require_relative "named_base_generator"

module Generators
  module Avo
    class Card < NamedBaseGenerator
      namespace "avo:card"
      source_root File.expand_path("templates", __dir__)
      class_option :type, type: :string

      def handle
        raise "Invalid card type '#{options[:type]}'" unless card_types.include? options[:type]

        template "cards/#{options[:type]}_card_sample.tt", "app/avo/cards/#{name.underscore}.rb"

        if options[:type].to_sym == :partial
          template "cards/partial_card_partial.tt", "app/views/avo/cards/_#{name.underscore}.html.erb"
        end
      end

      private

      def card_types
        %w[metric chartkick partial]
      end
    end
  end
end

Version data entries

118 entries across 118 versions & 1 rubygems

Version Path
avo-3.14.3 lib/generators/avo/card_generator.rb
avo-3.14.2 lib/generators/avo/card_generator.rb
avo-3.14.1 lib/generators/avo/card_generator.rb
avo-3.14.0 lib/generators/avo/card_generator.rb
avo-3.13.7 lib/generators/avo/card_generator.rb
avo-3.13.6 lib/generators/avo/card_generator.rb
avo-3.13.5 lib/generators/avo/card_generator.rb
avo-3.13.4 lib/generators/avo/card_generator.rb
avo-3.13.3 lib/generators/avo/card_generator.rb
avo-3.13.2 lib/generators/avo/card_generator.rb
avo-3.13.1 lib/generators/avo/card_generator.rb
avo-3.13.0 lib/generators/avo/card_generator.rb
avo-3.12.0 lib/generators/avo/card_generator.rb
avo-3.11.10 lib/generators/avo/card_generator.rb
avo-3.11.9 lib/generators/avo/card_generator.rb
avo-3.11.8 lib/generators/avo/card_generator.rb
avo-3.11.7 lib/generators/avo/card_generator.rb
avo-3.11.6 lib/generators/avo/card_generator.rb
avo-3.11.5 lib/generators/avo/card_generator.rb
avo-3.11.4 lib/generators/avo/card_generator.rb