Sha256: 3d3b3a0434c1f63f6d495ae85327250839102443ace12292005f1ec4153329e6

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 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_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|
        Dir.chdir(dir) { yield }
      end
    end

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

    def in_bootstrapped_dir
      dir = Array(options[:args]).first rescue nil
      if dir
        Dir.mkdir dir
        Dir.chdir(dir) { yield }
      else
        yield
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gem-release-0.2.1 lib/gem_release/helpers.rb
gem-release-0.2.0 lib/gem_release/helpers.rb
gem-release-0.1.3 lib/gem_release/helpers.rb
gem-release-0.1.2 lib/gem_release/helpers.rb
gem-release-0.1.1 lib/gem_release/helpers.rb
gem-release-0.1.0 lib/gem_release/helpers.rb