Sha256: 55bc2f9655cbcf18a1ba30d82d28c7856801dfd6c11ddc4175a35c4138d25cd9

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Dopstick
  module Generator
    class Options
      using Refinements

      def initialize(options)
        @options = options
      end

      def [](key)
        @options[key]
      end

      def merge(other)
        @options.merge(other)
      end

      def respond_to_missing?(name, _include_all)
        options.key?(name) || super
      end

      def method_missing(name, *args)
        @options.key?(name) ? @options[name] : super
      end

      def skip_install?
        @options[:skip_install]
      end

      def bin?
        !@options[:bin].empty?
      end

      def user_name
        @user_name ||= @options[:author_name].presence ||
                       `git config user.name`.chomp.presence ||
                       "Your Name"
      end

      def user_email
        @user_email ||= @options[:author_email].presence ||
                        `git config user.email`.chomp.presence ||
                        "your@email.com"
      end

      def github_user
        @github_user ||= @options[:author_github].presence ||
                         `git config user.github`.chomp.presence ||
                         "[USER]"
      end

      def paypal_user
        @paypal_user ||= @options[:author_paypal].presence ||
                         `git config user.paypal`.chomp.presence ||
                         "[USER]"
      end

      def github_url
        "https://github.com/#{github_user}/#{package_name}"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dopstick-0.0.12 lib/dopstick/generator/options.rb
dopstick-0.0.11 lib/dopstick/generator/options.rb
dopstick-0.0.10 lib/dopstick/generator/options.rb
dopstick-0.0.9 lib/dopstick/generator/options.rb
dopstick-0.0.8 lib/dopstick/generator/options.rb
dopstick-0.0.7 lib/dopstick/generator/options.rb
dopstick-0.0.6 lib/dopstick/generator/options.rb
dopstick-0.0.5 lib/dopstick/generator/options.rb
dopstick-0.0.4 lib/dopstick/generator/options.rb