Sha256: 6ac6903702b0743d0f944cd0e82d4c8ddc60f842c267013e9bd2dc3734802f5b

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

module WorldFlags
  module Generators
    class PublicizeGenerator < ::Rails::Generators::Base
      desc "Publicizes world flags assets (if not using Rails asset pipeline)"

      class_option :stylesheets_dir,  :type => :string, 
                                      :desc => 'The stylesheets folder of your app'

      class_option :images_dir,       :type => :string, 
                                      :desc => 'The images folder of your app'

      class_option :javascripts_dir,  :type => :string, 
                                      :desc => 'The javascripts folder of your app'

      class_option :public_dir,       :type => :string, 
                                      :desc => 'The public root folder of your app'

      def main_flow
        copy_dir asset_src_dir('stylesheets'), stylesheets_dir
        copy_dir asset_src_dir('images'), images_dir
        copy_dir asset_src_dir('javascripts'), images_dir
      end    

      protected

      def copy_dir src, target
        say "Copying: #{src} -> #{target}"        
        copy src, target
      end

      def asset_src_dir folder
        File.expand_path "../../../vendor/assets/#{folder}"
      end

      def javascripts_dir
        options[:stylesheets_dir] || asset_folder('javascripts')
      end

      def stylesheets_dir
        options[:stylesheets_dir] || asset_folder('stylesheets')
      end

      def images_dir
        options[:images_dir] || asset_folder('images')
      end

      def asset_folder folder = nil
        File.join(public_dir, folder)
      end


      def public_dir
        Rails.root.join(options[:public_dir] || 'public')
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
world-flags-0.6.6 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.5 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.4 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.3.1 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.3 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.2.1 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.2 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.1.1 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.1 lib/generators/world_flags/publicize_generator.rb
world-flags-0.6.0 lib/generators/world_flags/publicize_generator.rb
world-flags-0.5.1 lib/generators/world_flags/publicize_generator.rb