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.11.3 lib/generators/avo/card_generator.rb
avo-3.11.2 lib/generators/avo/card_generator.rb
avo-3.11.1 lib/generators/avo/card_generator.rb
avo-3.11.0 lib/generators/avo/card_generator.rb
avo-3.10.10 lib/generators/avo/card_generator.rb
avo-3.10.9 lib/generators/avo/card_generator.rb
avo-3.10.8 lib/generators/avo/card_generator.rb
avo-3.10.7 lib/generators/avo/card_generator.rb
avo-3.10.6 lib/generators/avo/card_generator.rb
avo-3.10.5 lib/generators/avo/card_generator.rb
avo-3.10.4 lib/generators/avo/card_generator.rb
avo-3.10.3 lib/generators/avo/card_generator.rb
avo-3.10.2 lib/generators/avo/card_generator.rb
avo-3.10.1 lib/generators/avo/card_generator.rb
avo-3.10.0 lib/generators/avo/card_generator.rb
avo-3.9.2 lib/generators/avo/card_generator.rb
avo-3.9.1 lib/generators/avo/card_generator.rb
avo-3.8.2 lib/generators/avo/card_generator.rb
avo-3.9.0 lib/generators/avo/card_generator.rb
avo-3.8.1 lib/generators/avo/card_generator.rb