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

  • SEARCH
  • Home
  • 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 6729447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:17:30+00:00 2026-05-26T10:17:30+00:00

I have a Buildr extension that I’m packaging as a gem. I have a

  • 0

I have a Buildr extension that I’m packaging as a gem. I have a collection of scripts that I want to add to a package. Currently, I have these scripts stored as a big text block that I’m writing to file. I would prefer to have individual files that I can either copy directly or read/write back out. I would like these files to be packaged into the gem. I don’t have a problem packaging them in (just stick them in the file system before rake install) but I can’t figure out how to access them. Is there a Gem Resources bundle type thing?

  • 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-05-26T10:17:30+00:00Added an answer on May 26, 2026 at 10:17 am

    There are basically two ways,

    1) You can load resources relative to a Ruby file in your gem using __FILE__:

    def path_to_resources
      File.join(File.dirname(File.expand_path(__FILE__)), '../path/to/resources')
    end
    

    2) You can add arbitrary paths from your Gem to the $LOAD_PATH variable and then walk the $LOAD_PATH to find resources, e.g.,

    Gem::Specification.new do |spec|
      spec.name = 'the-name-of-your-gem'
      spec.version ='0.0.1'
    
      # this is important - it specifies which files to include in the gem.
      spec.files  = Dir.glob("lib/**/*") + %w{History.txt Manifest.txt} +
                    Dir.glob("path/to/resources/**/*")
    
      # If you have resources in other directories than 'lib'
      spec.require_paths << 'path/to/resources'
    
      # optional, but useful to your users
      spec.summary = "A more longwinded description of your gem"
      spec.author = 'Your Name'
      spec.email = 'you@yourdomain.com'
      spec.homepage = 'http://www.yourpage.com'
    
      # you did document with RDoc, right?
      spec.has_rdoc = true
    
      # if you have any dependencies on other gems, list them thusly
      spec.add_dependency('hpricot')
      spec.add_dependency('log4r', '>= 1.0.5')
    end
    

    and then,

    $LOAD_PATH.each { |dir|  ... look for resources relative to dir ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HtmlHelper extension that currently returns a string using a string builder
I have a series of DropDowns that I want the user to add to
I have to build a firefox extension and I want to be able to
I have a gem that uses a binary (htmldoc) that is not bundled into
I have created an extension for mediawiki that works in all major browsers other
I'm trying to build a Chrome extension that will have a heavy use of
I currently looking to build a Google Chrome Extension that fetches bookmarks from the
I have an extension method that looks like the following: //[MethodImpl(MethodImplOptions.NoOptimization)] public static IEnumerable<char>
I have an extension method that needs to return an HtmlString. The method has
I have a string extension that was defined exactly like this: public static string

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.