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

[![Gem Version](https://badge.fury.io/rb/ruby-macho.svg)](http://badge.fury.io/rb/ruby-macho)
[![Build Status](https://drone.io/github.com/woodruffw/ruby-macho/status.png)](https://drone.io/github.com/woodruffw/ruby-macho/latest)

A Ruby library for manipulating 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

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

### What works?

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

### What might work?

* Reading *some* data from PPC Mach-O files.
* Reading data from "Fat" files.
<commit_msg>add short example to README<commit_after>ruby-macho
================

[![Gem Version](https://badge.fury.io/rb/ruby-macho.svg)](http://badge.fury.io/rb/ruby-macho)
[![Build Status](https://drone.io/github.com/woodruffw/ruby-macho/status.png)](https://drone.io/github.com/woodruffw/ruby-macho/latest)

A Ruby library for manipulating 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 dylibs
* Changing install names in Mach-O files

### What might work?

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

{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.00730554361839278, 'mean_word_length': 4.413953488372093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5336040', 'n_tokens_mistral': 869, 'n_tokens_neox': 801, 'n_words': 231}