Sha256: f1588f3d83226a1d54244281d22aed239d8c9d3d59970f2b7dc0aac8c1d108bf

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'core_ext/string/camelize'

module GemRelease
  module Helpers
    def quiet?
      options[:quiet]
    end

    def user_name
      `git config --get user.name`.strip
    end

    def user_email
      `git config --get user.email`.strip
    end

    def github_user
      `git config --get github.user`.strip
    end

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

    def 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_name.gsub('-', '_')
    end

    def 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
      Gem::Specification.load(gemspec_filename)
    rescue LoadError, RuntimeError
      nil
    end

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

    def in_gemspec_dirs
      gemspec_dirs.each do |dir|
        @version = nil # UGH.
        Dir.chdir(dir) { yield }
      end
    end

    def gemspec_dirs
      Dir.glob('**/*.gemspec').map { |spec| File.dirname(spec) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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