Sha256: f5e9d74eb302f10b512068d74add4565c11f5c0f8fa3cd64796c1e3e41edd3e3

Contents?: true

Size: 1.49 KB

Versions: 16

Compression:

Stored size: 1.49 KB

Contents

require 'itamae'
require 'itamae/resource/base'
require 'itamae/resource/file'
require 'itamae/resource/package'
require 'itamae/resource/remote_directory'
require 'itamae/resource/remote_file'
require 'itamae/resource/directory'
require 'itamae/resource/template'
require 'itamae/resource/execute'
require 'itamae/resource/service'
require 'itamae/resource/link'
require 'itamae/resource/local_ruby_block'
require 'itamae/resource/git'
require 'itamae/resource/user'
require 'itamae/resource/group'
require 'itamae/resource/gem_package'

module Itamae
  module Resource
    Error = Class.new(StandardError)
    AttributeMissingError = Class.new(StandardError)
    InvalidTypeError = Class.new(StandardError)
    ParseError = Class.new(StandardError)

    class << self
      def get_resource_class_name(method)
        to_camel_case(method.to_s)
      end

      def get_resource_plugin_class_name(method)
        '::Itamae::Plugin::Resource::' + to_camel_case(method.to_s)
      end

      def to_camel_case(str)
        str.split('_').map {|part| part.capitalize}.join
      end

      def get_resource_class(method)
        begin
          const_get(get_resource_class_name(method))
        rescue NameError => e
          const_get(get_resource_plugin_class_name(method))
        end
      end

      def parse_description(desc)
        if /\A([^\[]+)\[([^\]]+)\]\z/ =~ desc
          [$1, $2]
        else
          raise ParseError, "'#{desc}' doesn't represent a resource."
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
itamae-1.2.4 lib/itamae/resource.rb
itamae-1.2.3 lib/itamae/resource.rb
itamae-1.2.2 lib/itamae/resource.rb
itamae-1.2.0 lib/itamae/resource.rb
itamae-1.1.26 lib/itamae/resource.rb
itamae-1.1.25 lib/itamae/resource.rb
itamae-1.1.24 lib/itamae/resource.rb
itamae-1.1.23 lib/itamae/resource.rb
itamae-1.1.22 lib/itamae/resource.rb
itamae-1.1.21 lib/itamae/resource.rb
itamae-1.1.20 lib/itamae/resource.rb
itamae-1.1.19 lib/itamae/resource.rb
itamae-1.1.18 lib/itamae/resource.rb
itamae-1.1.17 lib/itamae/resource.rb
itamae-1.1.16 lib/itamae/resource.rb
itamae-1.1.15 lib/itamae/resource.rb