Sha256: 371724a65a1e38b9e9434fcd6d4153758aec22f926d108964140d96118e682db

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'core_ext/kernel/silence'

module GemRelease
  module Helpers
    def github_user
      @github_user ||= `git config --get github.user`.strip
    end

    def github_token
      @github_token ||= `git config --get github.token`.strip
    end

    def gem_name
      @gem_name ||= gemspec ? gemspec.name : gem_name_from_directory
    end

    def gem_name_from_directory
      File.basename(Dir.pwd)
    end

    def gem_module_path
      @gem_module_path ||= gem_name.gsub('-', '_')
    end

    def gem_module_name
      @gem_module_name ||= gem_module_path.camelize
    end

    def gem_filename
      gemspec.file_name
    end

    def gem_version
      gemspec.version.to_s
    end

    def gemspec
      @gemspec ||= Gem::Specification.load(gemspec_filename) # silence {  }
    rescue LoadError, RuntimeError
      nil
    end

    def gemspec_filename
      @gemspec_filename ||= begin
        name = Array(options[:args]).first rescue nil
        name ||= Dir['*.gemspec'].first
        name || raise("No gemspec found or given.")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gem-release-0.0.13 lib/gem_release/helpers.rb