ruby-macho 0.2.6 → 1.0.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.
@@ -55,42 +55,42 @@ module MachO
55
55
  # @param num [Fixnum] the number being checked
56
56
  # @return [Boolean] true if `num` is a valid Mach-O magic number, false otherwise
57
57
  def self.magic?(num)
58
- MH_MAGICS.key?(num)
58
+ Headers::MH_MAGICS.key?(num)
59
59
  end
60
60
 
61
61
  # Compares the given number to valid Fat magic numbers.
62
62
  # @param num [Fixnum] the number being checked
63
63
  # @return [Boolean] true if `num` is a valid Fat magic number, false otherwise
64
64
  def self.fat_magic?(num)
65
- num == FAT_MAGIC
65
+ num == Headers::FAT_MAGIC
66
66
  end
67
67
 
68
68
  # Compares the given number to valid 32-bit Mach-O magic numbers.
69
69
  # @param num [Fixnum] the number being checked
70
70
  # @return [Boolean] true if `num` is a valid 32-bit magic number, false otherwise
71
71
  def self.magic32?(num)
72
- num == MH_MAGIC || num == MH_CIGAM
72
+ num == Headers::MH_MAGIC || num == Headers::MH_CIGAM
73
73
  end
74
74
 
75
75
  # Compares the given number to valid 64-bit Mach-O magic numbers.
76
76
  # @param num [Fixnum] the number being checked
77
77
  # @return [Boolean] true if `num` is a valid 64-bit magic number, false otherwise
78
78
  def self.magic64?(num)
79
- num == MH_MAGIC_64 || num == MH_CIGAM_64
79
+ num == Headers::MH_MAGIC_64 || num == Headers::MH_CIGAM_64
80
80
  end
81
81
 
82
82
  # Compares the given number to valid little-endian magic numbers.
83
83
  # @param num [Fixnum] the number being checked
84
84
  # @return [Boolean] true if `num` is a valid little-endian magic number, false otherwise
85
85
  def self.little_magic?(num)
86
- num == MH_CIGAM || num == MH_CIGAM_64
86
+ num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
87
87
  end
88
88
 
89
89
  # Compares the given number to valid big-endian magic numbers.
90
90
  # @param num [Fixnum] the number being checked
91
91
  # @return [Boolean] true if `num` is a valid big-endian magic number, false otherwise
92
92
  def self.big_magic?(num)
93
- num == MH_CIGAM || num == MH_CIGAM_64
93
+ num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
94
94
  end
95
95
  end
96
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-macho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 1.0.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: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for viewing and manipulating Mach-O files in Ruby.
14
14
  email: william@tuffbizz.com
@@ -25,7 +25,6 @@ files:
25
25
  - lib/macho/headers.rb
26
26
  - lib/macho/load_commands.rb
27
27
  - lib/macho/macho_file.rb
28
- - lib/macho/open.rb
29
28
  - lib/macho/sections.rb
30
29
  - lib/macho/structure.rb
31
30
  - lib/macho/tools.rb
@@ -43,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
42
  requirements:
44
43
  - - ">="
45
44
  - !ruby/object:Gem::Version
46
- version: '0'
45
+ version: 2.0.0
47
46
  required_rubygems_version: !ruby/object:Gem::Requirement
48
47
  requirements:
49
48
  - - ">="
@@ -1,25 +0,0 @@
1
- module MachO
2
- # Opens the given filename as a MachOFile or FatFile, depending on its magic.
3
- # @param filename [String] the file being opened
4
- # @return [MachO::MachOFile] if the file is a Mach-O
5
- # @return [MachO::FatFile] if the file is a Fat file
6
- # @raise [ArgumentError] if the given file does not exist
7
- # @raise [MachO::TruncatedFileError] if the file is too small to have a valid header
8
- # @raise [MachO::MagicError] if the file's magic is not valid Mach-O magic
9
- def self.open(filename)
10
- raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)
11
- raise TruncatedFileError unless File.stat(filename).size >= 4
12
-
13
- magic = File.open(filename, "rb") { |f| f.read(4) }.unpack("N").first
14
-
15
- if Utils.fat_magic?(magic)
16
- file = FatFile.new(filename)
17
- elsif Utils.magic?(magic)
18
- file = MachOFile.new(filename)
19
- else
20
- raise MagicError, magic
21
- end
22
-
23
- file
24
- end
25
- end