Sha256: 73e4ed6b4159731b1299d12eaa5481b34842495979673ed714585089d532bd43

Contents?: true

Size: 902 Bytes

Versions: 10

Compression:

Stored size: 902 Bytes

Contents

module Railsthemes
  class Switcher
    include Railsthemes::Logging

    def list
      themes = installed_themes
      if themes.empty?
        logger.warn 'There are currently no RailsThemes themes installed.'
      else
        logger.warn 'RailsThemes themes currently installed:'
        themes.each do |theme|
          logger.warn " - #{theme}"
        end
      end
    end

    def switch_to theme_name
      themes = installed_themes
      if themes.include? theme_name
        Utils.set_layout_in_application_controller theme_name
      else
        logger.warn "'#{theme_name}' is not a locally installed RailsThemes theme."
      end
    end

    def installed_themes
      Dir['app/assets/stylesheets/railsthemes_*'].inject([]) do |accum, filepath|
        accum << File.basename(filepath).gsub(/^railsthemes_/, '') if File.directory?(filepath)
        accum
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
railsthemes-2.1.3 lib/railsthemes/switcher.rb
railsthemes-2.1.2 lib/railsthemes/switcher.rb
railsthemes-2.1.1 lib/railsthemes/switcher.rb
railsthemes-2.1.0 lib/railsthemes/switcher.rb
railsthemes-2.0.3 lib/railsthemes/switcher.rb
railsthemes-2.0.2 lib/railsthemes/switcher.rb
railsthemes-2.0.1 lib/railsthemes/switcher.rb
railsthemes-2.0.0 lib/railsthemes/switcher.rb
railsthemes-2.0.0.pre.2 lib/railsthemes/switcher.rb
railsthemes-2.0.0.pre lib/railsthemes/switcher.rb