Sha256: 335f7d27bff68b68a152b32027d798f4ca5b175a197cfa50008ed8cb6ed3682d

Contents?: true

Size: 872 Bytes

Versions: 6

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

require 'modern/descriptor/info'

require 'docile'

module Modern
  module DSL
    class Info
      attr_reader :value

      def initialize(title, version)
        @value = Modern::Descriptor::Info.new(title: title, version: version)
      end

      def description(v)
        @value = @value.copy(description: v)
      end

      def terms_of_service(v)
        @value = @value.copy(terms_of_service: v)
      end

      def contact(name: nil, url: nil, email: nil)
        @value = @value.copy(contact: { name: name, url: url, email: email }.compact)
      end

      def license(name, url: nil)
        @value = @value.copy(license: { name: name, url: url }.compact)
      end

      def self.build(title, version, &block)
        i = Info.new(title, version)
        i.instance_exec(&block)
        i.value
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
modern-0.5.0 lib/modern/dsl/info.rb
modern-0.4.6 lib/modern/dsl/info.rb
modern-0.4.5 lib/modern/dsl/info.rb
modern-0.4.4 lib/modern/dsl/info.rb
modern-0.4.3 lib/modern/dsl/info.rb
modern-0.4.2 lib/modern/dsl/info.rb