Rubygems
From Rory.wiki
Contents |
General
Setup
Worth setting up a .gemrc file to store preferences for rubygems. Personally I never really use the docs that are locally generated as part of gem installs, and they can take an age to setup. Here's a sample .gemrc file which sets that and a couple of other common settings
If you need the local docs at a later date, you can always run rdoc then.
- update_sources: true
- bulk_threshold: 1000
- sources:
gem: --no-ri --no-rdoc
- verbose: true
- benchmark: false
- backtrace: false
Use specific gem versions
If for some reason you need to use a specific gem version then installing and using can be done like this
installing
gem install <gem_name> -v '<version_number>'
Using
require 'rubygems' gem 'gem_name','=<version_number>' require '<gem_name>'
Specific Gem Notes
Nokogiri
From a default installation of ubuntu, you need a couple of additional libraries for it to work. This command should work
- sudo apt-get install libxslt-dev libxml2 libxml2-dev
ActiveLdap
Interesting library for querying LDAP directories and parsing LDIF files. A quick example of parsing an LDIF file for some basic information.
#!/usr/bin/env ruby require 'rubygems' require 'active_ldap' input_file = File.open(ARGV[0],'r').read output_file = File.new(ARGV[0] + 'parsed.txt','w+') things = ActiveLdap::Ldif.parse(input_file) things.records.each do |rec| output_file.puts '--------------' output_file.puts 'Distinguished name: ' + rec.dn output_file.puts 'Object Description: ' + rec.attributes['description'].join(',') if rec.attributes['description'] output_file.puts 'Object Category: ' + rec.attributes['objectCategory'].join(',') if rec.attributes['objectCategory'] output_file.puts 'Logon Count: ' + rec.attributes['logonCount'].join(',') if rec.attributes['logonCount'] output_file.puts 'Incorrect Logon Count: ' + rec.attributes['badPwdCount'].join(',') if rec.attributes['badPwdCount'] end
