Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:08:58+00:00 2026-06-13T08:08:58+00:00

I am using Grit (Ruby gem) to load a git repo, extract a given

  • 0

I am using Grit (Ruby gem) to load a git repo, extract a given commit to a folder, then ‘do stuff’ with it. Grit supports git archive with archive_tar which retuns a ‘string containing tar archive’. I would like to extract this to the filesystem using Ruby libs / gems if possible (not direct system calls) and avoid things like saving the data to an archive first and then extracting it (really looking for an efficient one-liner here).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:08:59+00:00Added an answer on June 13, 2026 at 8:08 am

    Under the assumption that ‘string containing tar archive’ is equivalent to

    File.open("Downloads.tar", "rb") {|a| a.read }

    I am able to accomplish this using fileutils, stringio, and the minitar gem.
    First you will need to install minitar, which should be as simple as

    gem install minitar
    

    Since minitar does not support it’s regular unpack to use a stream, we’ll create our own rudimentary unpacking method.

    require 'archive/tar/minitar'
    require 'stringio'
    require 'fileutils'
    
    def unpack_tar(directory, string)
      FileUtils.mkdir_p(directory) if !File.exist?(directory)
      stringio = StringIO.new(string)
      input = Archive::Tar::Minitar::Input.new(stringio)
      input.each {|entry|
        input.extract_entry(directory, entry)
      }
    end
    
    unpack_tar("./test", File.open("Downloads.tar", "rb") {|a| a.read })
    

    Of course replacing the whole File.open part with the archive_tar function of the Grit gem. This is all assuming that first assumption of course, though i’m sure ths method can easily be adapted to suit whatever archive_tar actually returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to create a branch in a repo using Grit? I
I'm trying to wrap my head around using Grit to write to a Git
I am using 'git' to checkout chromium code by following this document: http://code.google.com/p/chromium/wiki/UsingGit And
Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files.
Is there a way to find out what branch a commit comes from given
Using Git Bash or MinGW Shell , if I put in a command with
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using SQL Server 2008 R2 we are looking for a way to select the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.