I just recently started shifting attention towards deploying Ruby apps atop TorqueBox
which of course is built atop Jruby. Hitherto I have been basically performing a bundle install
and then tackling each gem along the way to jrubydom, but I've hit a couple gems that have taken me some considerable time to resolve due to needing to reimplement large portions of them.
Is there a way to invoke bundler or rubygems to run through all gems and their deps to test if they require native c extensions and then return such a list? It sure would be nice to tackle some of the more minor items or even to know if it is worthwhile to tackle a project in terms of moving it to jruby.
In this example you'll reach https://rubygems.org/gems/nokogiri. On the right column, you'll see "homepage" link. Clicking that navigates us to the (yes) homepage of the gem. It might be a dedicated page of the project or a GitHub README, but it should explains what the gem is for.
run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.
The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.
A gem file is just a tar archive containing (at least) a gemspec file. There will also usually be ruby source files and possibly native code or supporting assets (for example a gem designed to be used with rails might also package some javascript).
Must be inside a folder with a Gemfile. Displays a list of outdated gems in the current project. Can use the --groups option to group them. Runs an irb session with the gems from the current project's Gemfile. You've learned about RubyGems, the package system for Ruby.
Every gem should start with a Rakefile which contains the tasks needed by developers to work on the gem. The files for the extension should go in the ext/ directory in a directory matching the extension’s name. For this example we’ll use “my_malloc” for the name. Some extensions will be partially written in C and partially written in ruby.
A list of gems required for a given (non-gem) project can be listed on a special file called “Gemfile” so they can be automatically installed by Bundler. Both covered later in this guide. What are some examples of gems? Rails, and all of its components (ActiveRecord, ActiveSupport, etc.) are distributed as Ruby gems Most gems are pure Ruby code.
A few gems include a Ruby C extension for improved performance. This extension is built automatically for you when you install the gem. In some cases, you may need to manually install additional software that is not managed by RubyGems. Let’s learn more about gems by building your own & looking at the files that make a gem.
Based on the fact that gems with native extensions usually have an /ext directory, I made a simple oneliner that finds these gems:
puts `bundle show --paths`.split("\n").select{|dep| File.directory?("#{dep}/ext") }.map{|dep| dep.split('/').last }.join(', ')
You can do this on the command line with this command:
$ bundle show --paths | ruby -e "STDIN.each_line {|dep| puts dep.split('/').last if File.directory?(File.join(dep.chomp, 'ext')) }"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With