Sha256: dcff341bb969c675b46a9ea3328bf200be96691df0616ca1fe5ea6b290750564

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

require 'rails/generators'

module NewspaperWorks
  class AssetsGenerator < Rails::Generators::Base
    desc "This generator installs the newspaper_works CSS assets into your application"

    source_root File.expand_path('../templates', __FILE__)

    def inject_css
      copy_file "newspaper_works.scss", "app/assets/stylesheets/newspaper_works.scss"
    end

    def inject_js
      return if newspaper_works_js_installed?
      insert_into_file 'app/assets/javascripts/application.js', after: '//= require hyrax' do
        <<-JS.strip_heredoc

        //= require newspaper_works
        JS
      end
    end

    private

      def newspaper_works_js_installed?
        IO.read("app/assets/javascripts/application.js").include?('newspaper_works')
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 lib/generators/newspaper_works/assets_generator.rb
newspaper_works-1.0.0 lib/generators/newspaper_works/assets_generator.rb
newspaper_works-0.1.0 lib/generators/newspaper_works/assets_generator.rb