Sha256: 3d601c37693eea6d390cf959ccdddb3f448149e62ad532ee7d4fe1e9fff085a3

Contents?: true

Size: 1006 Bytes

Versions: 11

Compression:

Stored size: 1006 Bytes

Contents

module Visage
  class Config 

    class << self
      def use
        @configuration ||= {}
        yield @configuration
        nil
      end

      def method_missing(method, *args)
        if method.to_s[-1,1] == '='
          @configuration[method.to_s.tr('=','')] = *args
        else
          @configuration[method.to_s]
        end
      end

      def to_hash
        @configuration
      end
    end

    class Profiles
      class << self
        require 'ostruct'

        attr_accessor :profiles

        def get(id)
          id.gsub!(/\s+/, '+')
          if found = @profiles.find {|p| p[1]["splat"] == id }
            OpenStruct.new(found[1])
          else
            nil
          end
        end

        def all
          # here be ugliness
          profiles = @profiles.to_a.sort_by { |profile| 
            profile[1]["order"] 
          }.map { |profile| 
            OpenStruct.new(profile[1].merge({'name' => profile[0]}))
          }
        end
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
visage-app-0.2.5 lib/visage/config.rb
visage-app-0.2.4 lib/visage/config.rb
visage-app-0.2.3 lib/visage/config.rb
visage-app-0.2.2 lib/visage/config.rb
visage-app-0.2.1 lib/visage/config.rb
visage-app-0.2.0 lib/visage/config.rb
visage-app-0.1.8 lib/visage/config.rb
visage-app-0.1.7 lib/visage/config.rb
visage-app-0.1.6 lib/visage/config.rb
visage-app-0.1.5 lib/visage/config.rb
visage-app-0.1.0 lib/visage/config.rb