Sha256: 16a04b2f3c1d365918ec443d35ca3fbe12d17e7cc8dde5d993155d68eba373d9

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

require 'rails/generators'

module Bootswatch
  module Generators
    class ImportGenerator < ::Rails::Generators::NamedBase

      def theme_name
        file_name
      end

      def theme_directory
        if class_path.empty?
          theme_name
        else
          class_path.first
        end
      end

      def theme_repo_url
       "https://raw.github.com/thomaspark/bootswatch/gh-pages/#{theme_name}"
      end

      def import_less

        stylesheets_dest_path = "app/assets/stylesheets/#{theme_directory}"
        empty_directory stylesheets_dest_path

        get File.join(theme_repo_url,'variables.less'), File.join(stylesheets_dest_path,'variables.less')


        get File.join(theme_repo_url,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.css.less')

        prepend_to_file File.join(stylesheets_dest_path,'bootswatch.css.less') do
          "@import \"#{theme_directory}/base\";\n\n"
        end

        gsub_file File.join(stylesheets_dest_path,'variables.less'),
                  '"../img/glyphicons-halflings.png"',
                  '"twitter/bootstrap/glyphicons-halflings.png"'

        gsub_file File.join(stylesheets_dest_path, 'variables.less'),
                  '"../fonts/"',
                  '"twitter/bootstrap/"'

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
twitter-bootswatch-rails-3.2.0.0 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.1.1.1 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.1.1.0 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.1.0.4 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.1.0.3 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.1.0.1 lib/generators/bootswatch/import/import_generator.rb
twitter-bootswatch-rails-3.0.3.0 lib/generators/bootswatch/import/import_generator.rb