Sha256: 5f1e42374d756974683516109a8f06e2451bcfde00e8671c45644fa8e80164ed

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module RailsAppGenerator
  # Custom add-ons for RailsAppGenerator
  module AddOns
    # Add Chartkick to rails application
    class Chartkick < AddOn
      required_gem gem.version('chartkick', '4.2.1', 'Create beautiful JavaScript charts with one line of Ruby')

      def apply
        puts 'Applying Chartkick'
        # say 'Setting up Chartkick'
        # template('chartkick_template.rb', 'target/chartkick.rb', force: true)
        # template('app/javascript/stylesheets/components.scss')
        # create_file('target/chartkick.rb', 'put your content here')
        # directory 'app/template', 'app/target', force: true
        # empty_directory 'app/target'
        # inject_into_file('app/application.js', "some content")
        # rails_command('tailwindcss:install')
      end

      def before_bundle
        puts 'Setting up Chartkick (before bundle)'
      end

      def after_bundle
        puts 'Setting up Chartkick (after bundle)'
        append_to_file('config/importmap.rb', <<~RUBY)
          pin "chartkick", to: "chartkick.js"
          pin "Chart.bundle", to: "Chart.bundle.js"
        RUBY

        append_to_file('app/javascript/application.js', <<~RUBY)
          import "chartkick"
          import "Chart.bundle"
        RUBY
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_app_generator-0.1.20 lib/rails_app_generator/addons/chartkick.rb
rails_app_generator-0.1.19 lib/rails_app_generator/addons/chartkick.rb
rails_app_generator-0.1.18 lib/rails_app_generator/addons/chartkick.rb