Sha256: 89f8003cddab55c825f113adcbe1126ff014471cd8fdccb1dc20a53cacb184e1

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

module BowerRails
  module Generators
    class InitializeGenerator < Rails::Generators::Base
      desc 'Adds a boilerplate bower.json or Bowerfile to the root of Rails project and an empty initializer'
      source_root File.expand_path('../templates', __FILE__)
      argument :config_file, :type => :string, :default => 'bowerfile'

      def create_config_file
        config_file_name = config_file.underscore
        case config_file_name
        when 'bowerfile' then copy_file 'Bowerfile',  'Bowerfile'
        when 'json'      then copy_file 'bower.json', 'bower.json'
        else
          raise ArgumentError, 'You can setup bower-rails only using bower.json or Bowerfile. Please provide `json` or `bowerfile` as an argument instead'
        end
      end

      def copy_initializer_file
        copy_file 'bower_rails.rb', 'config/initializers/bower_rails.rb'
      end

      def require_initializer_in_application_rb
        if Rails.version < "4.0.0"
          environment { "require \"#{Rails.root}/config/initializers/bower_rails.rb\"" }
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bower-rails-0.10.0 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.9.2 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.9.1 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.9.0 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.8.3 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.8.2 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.8.1 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.8.0 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.7.3 lib/generators/bower_rails/initialize/initialize_generator.rb
bower-rails-0.7.2 lib/generators/bower_rails/initialize/initialize_generator.rb