Sha256: 56006343dec7a2038cce914f18f026fdbcd45659d851eedb96f7d261c17630d4

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

require 'yaml'

module Scaffoldhub
  class Specification

    @@files  = []
    @@base_url = nil

    class << self
      def files
        @@files
      end

      def files=(files)
        @@files = files
      end

      def add_file(type, src, dest)
        @@files << { :type => type, :src => src, :dest => dest }
      end

      def base_url
        @@base_url
      end

      def base_url=(url)
        @@base_url = url
      end

      def to_yaml
        { :base_url => base_url, :files => files }.to_yaml
      end
    end

    def initialize
      yield self
    end

    def method_missing(name, *args, &blk)
      if name.to_s =~ /(.*)_file/ && args[0].is_a?(Hash)
        self.class.add_file($1, args[0][:src], args[0][:dest])
      elsif name == :base_url
        self.class.base_url = args[0]
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scaffoldhub-0.0.4 lib/scaffoldhub/specification.rb
scaffoldhub-0.0.3 lib/scaffoldhub/specification.rb
scaffoldhub-0.0.2 lib/scaffoldhub/specification.rb