<commit_before>ruby-macho
================

[![Gem Version](https://badge.fury.io/rb/ruby-macho.svg)](http://badge.fury.io/rb/ruby-macho)
[![Build Status](https://travis-ci.org/Homebrew/ruby-macho.svg?branch=master)](https://travis-ci.org/Homebrew/ruby-macho)

A Ruby library for examining and modifying Mach-O files.

### What is a Mach-O file?

The [Mach-O file format](https://en.wikipedia.org/wiki/Mach-O) is used by OS X
and iOS (among others) as a general purpose binary format for object files,
executables, dynamic libraries, and so forth.

### Documentation

Full documentation is available on [RubyDoc](http://www.rubydoc.info/gems/ruby-macho/).

A quick example of what ruby-macho can do:

```ruby
require 'macho'

file = MachO::MachOFile.open("/path/to/my/binary")

# get the file's type (MH_OBJECT, MH_DYLIB, MH_EXECUTE, etc)
file.filetype # => "MH_EXECUTE"

# get all load commands in the file and print their offsets:
file.load_commands.each do |lc|
  puts "#{lc}: offset #{lc.offset}, size: #{lc.cmdsize}"
end

# access a specific load command
lc_vers = file['LC_VERSION_MIN_MACOSX'].first
puts lc_vers.version_string # => "10.10.0"
```

### What works?

* Reading data from x86/x86_64 Mach-O files
* Changing the IDs of Mach-O and Fat dylibs
* Changing install names in Mach-O and Fat files

### What might work?

* Reading *some* data from PPC Mach-O files.

### What doesn't work yet?

* Reading data from any other architecure's Mach-O files (probably).
* Adding, deleting, or modifying rpaths.

### What needs to be done?
<commit_msg>README: Correct example (should be new, not open).<commit_after>ruby-macho
================

[![Gem Version](https://badge.fury.io/rb/ruby-macho.svg)](http://badge.fury.io/rb/ruby-macho)
[![Build Status](https://travis-ci.org/Homebrew/ruby-macho.svg?branch=master)](https://travis-ci.org/Homebrew/ruby-macho)

A Ruby library for examining and modifying Mach-O files.

### What is a Mach-O file?

The [Mach-O file format](https://en.wikipedia.org/wiki/Mach-O) is used by OS X
and iOS (among others) as a general purpose binary format for object files,
executables, dynamic libraries, and so forth.

### Documentation

Full documentation is available on [RubyDoc](http://www.rubydoc.info/gems/ruby-macho/).

A quick example of what ruby-macho can do:

```ruby
require 'macho'

file = MachO::MachOFile.new("/path/to/my/binary")

# get the file's type (MH_OBJECT, MH_DYLIB, MH_EXECUTE, etc)
file.filetype # => "MH_EXECUTE"

# get all load commands in the file and print their offsets:
file.load_commands.each do |lc|
  puts "#{lc}: offset #{lc.offset}, size: #{lc.cmdsize}"
end

# access a specific load command
lc_vers = file['LC_VERSION_MIN_MACOSX'].first
puts lc_vers.version_string # => "10.10.0"
```

### What works?

* Reading data from x86/x86_64 Mach-O files
* Changing the IDs of Mach-O and Fat dylibs
* Changing install names in Mach-O and Fat files

### What might work?

* Reading *some* data from PPC Mach-O files.

### What doesn't work yet?

* Reading data from any other architecure's Mach-O files (probably).
* Adding, deleting, or modifying rpaths.

### What needs to be done?

{'fraction_non_alphanumeric': 0.14653528289891926, 'fraction_numerical': 0.006993006993006993, 'mean_word_length': 4.435233160621761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '847847', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1074, 'n_words': 337}