Sha256: 1d7c75d19efb5f5edc490b4e5ee050a66989bbd7ecdbd9a2fbd9faf7fda3b756

Contents?: true

Size: 627 Bytes

Versions: 7

Compression:

Stored size: 627 Bytes

Contents

module Stoor
  class GitConfig
    attr_reader :repo_path

    def initialize(app, repo_path = nil)
      @app, @repo_path = app, repo_path
    end

    def call(env)
      @request = Rack::Request.new(env)
      unless @request.session['gollum.author']
        if repo_path && (name = git_option_value('user.name')) && (email = git_option_value('user.email'))
          @request.session['gollum.author'] = { :name => name, :email => email }
        end
      end
      @app.call(env)
    end

    private

    def git_option_value(option)
      @repo ||= Grit::Repo.new(repo_path)
      @repo.config[option]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stoor-0.1.12 lib/stoor/git_config.rb
stoor-0.1.11 lib/stoor/git_config.rb
stoor-0.1.9 lib/stoor/git_config.rb
stoor-0.1.8 lib/stoor/git_config.rb
stoor-0.1.7 lib/stoor/git_config.rb
stoor-0.1.6 lib/stoor/git_config.rb
stoor-0.1.5 lib/stoor/git_config.rb