ruby-macho-utils 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +2 -0
  3. data/bin/macho-info +31 -21
  4. metadata +3 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 83c93a0c18a6247a4d84f41401fd62e90d5c9aec
4
- data.tar.gz: 110dc3c83305853ed3c70dfafe8e4b9bbcd76bdd
2
+ SHA256:
3
+ metadata.gz: 6a9643eae4cd84a7ba0e1fa5a1c18d1d7291e4993d4457bc95eab08dd7c32072
4
+ data.tar.gz: cff16dc73f775e0c26b5f2b80445bc5ba18c2affe1e782f41a82b8ea22725029
5
5
  SHA512:
6
- metadata.gz: 9160f15cbc0f056dc664c98ce77e7649665ea347fd061f132ec31f70dcd437ed93e53ac5eada6a4dded577bf512287275366181eed5854cfa736261816565dca
7
- data.tar.gz: 298ae7d20596a209bc447894c974ee631c65916f0d655eec4d65d189240c86af698cc7c7404cece063900048e7318e8266cdfa8a67da9229efb47d48ec4524ee
6
+ metadata.gz: e3d160a0ca5a38f95828ec983ee70936e6eb44a9242454242fe9e77daf9f1b63768826fd16cd974c2561d6bbf4413c08360ce020725a804e1f844b24ad236773
7
+ data.tar.gz: 9903f5c9655a8877a503adf775d66a8d8dd7341d6573193905fb6376210b7a2dc6fd1012f45752eedb1d5778e5ad1ff7295d77de86288e9647a918751c1924a5
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ruby-macho-utils
2
2
  ================
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/ruby-macho-utils.svg)](https://badge.fury.io/rb/ruby-macho-utils)
5
+
4
6
  Command line utilities for use with
5
7
  [ruby-macho](https://github.com/Homebrew/ruby-macho/).
6
8
 
data/bin/macho-info CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "macho"
4
- require "slop"
5
+ require "optparse"
6
+ require "json"
5
7
 
6
8
  def macho_info(macho)
7
9
  puts "FILE INFORMATION:"
@@ -24,7 +26,7 @@ def macho_info(macho)
24
26
 
25
27
  puts "\nDYNAMIC LIBRARIES:"
26
28
  macho.dylib_load_commands.each do |lc|
27
- puts "\t#{lc.name.to_s} (#{lc.type})"
29
+ puts "\t#{lc.name} (#{lc.type})"
28
30
  end
29
31
 
30
32
  puts "\nSEGMENTS AND SECTIONS:"
@@ -40,34 +42,42 @@ def macho_info(macho)
40
42
  end
41
43
  end
42
44
 
43
- opts = Slop.parse do |o|
44
- o.banner = <<~EOS
45
+ options = {}
46
+ OptionParser.new do |parser|
47
+ parser.banner = <<~BANNER
45
48
  Dump metadata and information in the given Mach-O binary.
46
49
 
47
50
  Usage:
48
- macho-info [--first-only] <file>
49
- EOS
50
- o.bool "-f", "--first-only", "only dump the first slice in a fat binary"
51
- o.on "-h", "--help", "print this help message" do
52
- puts o
53
- exit
51
+ macho-info [options] <file>
52
+ BANNER
53
+
54
+ parser.on "-f", "--first-only", "dump only the first slice of a universal binary" do |f|
55
+ options[:first_only] = f
54
56
  end
55
- end
56
57
 
57
- filename = opts.args.shift || abort("I need a file to dump.")
58
+ parser.on "-j", "--json", "dump a JSON representation of the entire binary" do |j|
59
+ options[:json] = j
60
+ end
61
+ end.parse!
62
+
63
+ filename = ARGV.shift || abort("I need a file to dump.")
58
64
 
59
65
  macho_file = MachO.open(filename)
60
66
 
61
- if macho_file.is_a?(MachO::FatFile)
62
- macho_slices = macho_file.machos
67
+ if options[:json]
68
+ puts macho_file.to_h.to_json
63
69
  else
64
- macho_slices = [macho_file]
65
- end
70
+ macho_slices = if macho_file.is_a?(MachO::FatFile)
71
+ macho_file.machos
72
+ else
73
+ [macho_file]
74
+ end
66
75
 
67
- if opts.first_only?
68
- macho_info(macho_slices.first)
69
- else
70
- macho_slices.each do |macho|
71
- macho_info(macho)
76
+ if options[:first_only]
77
+ macho_info(macho_slices.first)
78
+ else
79
+ macho_slices.each do |macho|
80
+ macho_info(macho)
81
+ end
72
82
  end
73
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-macho-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-04 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-macho
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: slop
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '4.4'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '4.4'
41
27
  description: A collection of command line utilities for use with ruby-macho.
42
28
  email: william@tuffbizz.com
43
29
  executables:
@@ -67,8 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  requirements: []
70
- rubyforge_project:
71
- rubygems_version: 2.6.8
56
+ rubygems_version: 3.0.1
72
57
  signing_key:
73
58
  specification_version: 4
74
59
  summary: ruby-macho-utils - Command line utils for ruby-macho.