{"action":"created","comment":{"url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/comments/73802168","id":73802168,"diff_hunk":"@@ -400,6 +400,32 @@ def initialize(view, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,\n       @flags = flags\n     end\n \n+\n+    # All sections referenced within this segment.\n+    # @return [Array<MachO::Section>] if the Mach-O is 32-bit\n+    # @return [Array<MachO::Section64>] if the Mach-O is 64-bit\n+    def sections\n+      section_klass = case self\n+      when MachO::SegmentCommand64\n+        MachO::Section64\n+      when MachO::SegmentCommand\n+        MachO::Section\n+      end\n+\n+      sections = []\n+      return sections if nsects.zero?\n+\n+      offset = view.offset + self.class.bytesize\n+\n+      nsects.times do\n+        section_bin = view.raw_data[offset, section_klass.bytesize]\n+        sections << section_klass.new_from_bin(view.endianness, section_bin)\n+        offset += section_klass.bytesize\n+      end","path":"lib/macho/load_commands.rb","position":null,"original_position":25,"commit_id":"7f2dd3133bba94b1f7feefaf90634d232f4169b7","original_commit_id":"6e16241f23e220a36b5d44372338d38c8b295b24","user":{"login":"UniqMartin","id":11892150,"avatar_url":"https://avatars.githubusercontent.com/u/11892150?v=3","gravatar_id":"","url":"https://api.github.com/users/UniqMartin","html_url":"https://github.com/UniqMartin","followers_url":"https://api.github.com/users/UniqMartin/followers","following_url":"https://api.github.com/users/UniqMartin/following{/other_user}","gists_url":"https://api.github.com/users/UniqMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/UniqMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UniqMartin/subscriptions","organizations_url":"https://api.github.com/users/UniqMartin/orgs","repos_url":"https://api.github.com/users/UniqMartin/repos","events_url":"https://api.github.com/users/UniqMartin/events{/privacy}","received_events_url":"https://api.github.com/users/UniqMartin/received_events","type":"User","site_admin":false},"body":"How silly of me to not realize we're dealing with a `String` here! Sorry! Not sure how you feel about it, but my suggestion can be rescued with `String#unpack`:\r\n\r\n```ruby\r\nsections_bin = view.raw_data[offset, nsects * section_klass.bytesize]\r\nsections_bin.unpack(\"a#{section_klass.bytesize}\" * nsects).map do |section_bin|\r\n  section_klass.new_from_bin(view.endianness, section_bin)\r\nend\r\n```\r\n\r\n(I guess I'm equally fine with this version and what we currently have in the PR.)","created_at":"2016-08-07T13:45:51Z","updated_at":"2016-08-07T13:45:51Z","html_url":"https://github.com/Homebrew/ruby-macho/pull/57#discussion_r73802168","pull_request_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/comments/73802168"},"html":{"href":"https://github.com/Homebrew/ruby-macho/pull/57#discussion_r73802168"},"pull_request":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57","id":80356190,"html_url":"https://github.com/Homebrew/ruby-macho/pull/57","diff_url":"https://github.com/Homebrew/ruby-macho/pull/57.diff","patch_url":"https://github.com/Homebrew/ruby-macho/pull/57.patch","issue_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/57","number":57,"state":"open","locked":false,"title":"Deprecate MachOFile#sections in favor of SegmentCommand#sections.","user":{"login":"woodruffw","id":3059210,"avatar_url":"https://avatars.githubusercontent.com/u/3059210?v=3","gravatar_id":"","url":"https://api.github.com/users/woodruffw","html_url":"https://github.com/woodruffw","followers_url":"https://api.github.com/users/woodruffw/followers","following_url":"https://api.github.com/users/woodruffw/following{/other_user}","gists_url":"https://api.github.com/users/woodruffw/gists{/gist_id}","starred_url":"https://api.github.com/users/woodruffw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woodruffw/subscriptions","organizations_url":"https://api.github.com/users/woodruffw/orgs","repos_url":"https://api.github.com/users/woodruffw/repos","events_url":"https://api.github.com/users/woodruffw/events{/privacy}","received_events_url":"https://api.github.com/users/woodruffw/received_events","type":"User","site_admin":false},"body":"New code should always prefer `SegmentCommand#sections` over `MachOFile#sections`, as this better expresses the relationship between segments and their sections (and the parent Mach-O).\r\n\r\nI'm leaving `MachOFile#sections` in for the time being (with a `@deprecated` warning), although all internal references to it have been removed. It might make sense to remove it before 1.0, though.\r\n\r\ncc @UniqMartin ","created_at":"2016-08-07T02:19:06Z","updated_at":"2016-08-07T13:45:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bac9b4566ce9f2d78fff37726d252bdec7f8ca5","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Homebrew/ruby-macho/milestones/1","html_url":"https://github.com/Homebrew/ruby-macho/milestones/Release%201.0.0","labels_url":"https://api.github.com/repos/Homebrew/ruby-macho/milestones/1/labels","id":1905016,"number":1,"title":"Release 1.0.0","description":"","creator":{"login":"UniqMartin","id":11892150,"avatar_url":"https://avatars.githubusercontent.com/u/11892150?v=3","gravatar_id":"","url":"https://api.github.com/users/UniqMartin","html_url":"https://github.com/UniqMartin","followers_url":"https://api.github.com/users/UniqMartin/followers","following_url":"https://api.github.com/users/UniqMartin/following{/other_user}","gists_url":"https://api.github.com/users/UniqMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/UniqMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UniqMartin/subscriptions","organizations_url":"https://api.github.com/users/UniqMartin/orgs","repos_url":"https://api.github.com/users/UniqMartin/repos","events_url":"https://api.github.com/users/UniqMartin/events{/privacy}","received_events_url":"https://api.github.com/users/UniqMartin/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":7,"state":"open","created_at":"2016-07-26T14:04:29Z","updated_at":"2016-08-07T02:19:06Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57/commits","review_comments_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57/comments","review_comment_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/57/comments","statuses_url":"https://api.github.com/repos/Homebrew/ruby-macho/statuses/7f2dd3133bba94b1f7feefaf90634d232f4169b7","head":{"label":"Homebrew:segment-refactor","ref":"segment-refactor","sha":"7f2dd3133bba94b1f7feefaf90634d232f4169b7","user":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"repo":{"id":39162633,"name":"ruby-macho","full_name":"Homebrew/ruby-macho","owner":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Homebrew/ruby-macho","description":":nut_and_bolt: A pure-Ruby library for parsing Mach-O files.","fork":false,"url":"https://api.github.com/repos/Homebrew/ruby-macho","forks_url":"https://api.github.com/repos/Homebrew/ruby-macho/forks","keys_url":"https://api.github.com/repos/Homebrew/ruby-macho/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Homebrew/ruby-macho/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Homebrew/ruby-macho/teams","hooks_url":"https://api.github.com/repos/Homebrew/ruby-macho/hooks","issue_events_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/events{/number}","events_url":"https://api.github.com/repos/Homebrew/ruby-macho/events","assignees_url":"https://api.github.com/repos/Homebrew/ruby-macho/assignees{/user}","branches_url":"https://api.github.com/repos/Homebrew/ruby-macho/branches{/branch}","tags_url":"https://api.github.com/repos/Homebrew/ruby-macho/tags","blobs_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/refs{/sha}","trees_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Homebrew/ruby-macho/statuses/{sha}","languages_url":"https://api.github.com/repos/Homebrew/ruby-macho/languages","stargazers_url":"https://api.github.com/repos/Homebrew/ruby-macho/stargazers","contributors_url":"https://api.github.com/repos/Homebrew/ruby-macho/contributors","subscribers_url":"https://api.github.com/repos/Homebrew/ruby-macho/subscribers","subscription_url":"https://api.github.com/repos/Homebrew/ruby-macho/subscription","commits_url":"https://api.github.com/repos/Homebrew/ruby-macho/commits{/sha}","git_commits_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/commits{/sha}","comments_url":"https://api.github.com/repos/Homebrew/ruby-macho/comments{/number}","issue_comment_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/comments{/number}","contents_url":"https://api.github.com/repos/Homebrew/ruby-macho/contents/{+path}","compare_url":"https://api.github.com/repos/Homebrew/ruby-macho/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Homebrew/ruby-macho/merges","archive_url":"https://api.github.com/repos/Homebrew/ruby-macho/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Homebrew/ruby-macho/downloads","issues_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues{/number}","pulls_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls{/number}","milestones_url":"https://api.github.com/repos/Homebrew/ruby-macho/milestones{/number}","notifications_url":"https://api.github.com/repos/Homebrew/ruby-macho/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Homebrew/ruby-macho/labels{/name}","releases_url":"https://api.github.com/repos/Homebrew/ruby-macho/releases{/id}","deployments_url":"https://api.github.com/repos/Homebrew/ruby-macho/deployments","created_at":"2015-07-15T21:40:05Z","updated_at":"2016-08-07T00:39:40Z","pushed_at":"2016-08-07T13:41:30Z","git_url":"git://github.com/Homebrew/ruby-macho.git","ssh_url":"git@github.com:Homebrew/ruby-macho.git","clone_url":"https://github.com/Homebrew/ruby-macho.git","svn_url":"https://github.com/Homebrew/ruby-macho","homepage":"https://rubygems.org/gems/ruby-macho","size":626,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":14,"default_branch":"master"}},"base":{"label":"Homebrew:master","ref":"master","sha":"962715679361bdbb12ad1811d84022f3e2eace45","user":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"repo":{"id":39162633,"name":"ruby-macho","full_name":"Homebrew/ruby-macho","owner":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Homebrew/ruby-macho","description":":nut_and_bolt: A pure-Ruby library for parsing Mach-O files.","fork":false,"url":"https://api.github.com/repos/Homebrew/ruby-macho","forks_url":"https://api.github.com/repos/Homebrew/ruby-macho/forks","keys_url":"https://api.github.com/repos/Homebrew/ruby-macho/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Homebrew/ruby-macho/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Homebrew/ruby-macho/teams","hooks_url":"https://api.github.com/repos/Homebrew/ruby-macho/hooks","issue_events_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/events{/number}","events_url":"https://api.github.com/repos/Homebrew/ruby-macho/events","assignees_url":"https://api.github.com/repos/Homebrew/ruby-macho/assignees{/user}","branches_url":"https://api.github.com/repos/Homebrew/ruby-macho/branches{/branch}","tags_url":"https://api.github.com/repos/Homebrew/ruby-macho/tags","blobs_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/refs{/sha}","trees_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Homebrew/ruby-macho/statuses/{sha}","languages_url":"https://api.github.com/repos/Homebrew/ruby-macho/languages","stargazers_url":"https://api.github.com/repos/Homebrew/ruby-macho/stargazers","contributors_url":"https://api.github.com/repos/Homebrew/ruby-macho/contributors","subscribers_url":"https://api.github.com/repos/Homebrew/ruby-macho/subscribers","subscription_url":"https://api.github.com/repos/Homebrew/ruby-macho/subscription","commits_url":"https://api.github.com/repos/Homebrew/ruby-macho/commits{/sha}","git_commits_url":"https://api.github.com/repos/Homebrew/ruby-macho/git/commits{/sha}","comments_url":"https://api.github.com/repos/Homebrew/ruby-macho/comments{/number}","issue_comment_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues/comments{/number}","contents_url":"https://api.github.com/repos/Homebrew/ruby-macho/contents/{+path}","compare_url":"https://api.github.com/repos/Homebrew/ruby-macho/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Homebrew/ruby-macho/merges","archive_url":"https://api.github.com/repos/Homebrew/ruby-macho/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Homebrew/ruby-macho/downloads","issues_url":"https://api.github.com/repos/Homebrew/ruby-macho/issues{/number}","pulls_url":"https://api.github.com/repos/Homebrew/ruby-macho/pulls{/number}","milestones_url":"https://api.github.com/repos/Homebrew/ruby-macho/milestones{/number}","notifications_url":"https://api.github.com/repos/Homebrew/ruby-macho/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Homebrew/ruby-macho/labels{/name}","releases_url":"https://api.github.com/repos/Homebrew/ruby-macho/releases{/id}","deployments_url":"https://api.github.com/repos/Homebrew/ruby-macho/deployments","created_at":"2015-07-15T21:40:05Z","updated_at":"2016-08-07T00:39:40Z","pushed_at":"2016-08-07T13:41:30Z","git_url":"git://github.com/Homebrew/ruby-macho.git","ssh_url":"git@github.com:Homebrew/ruby-macho.git","clone_url":"https://github.com/Homebrew/ruby-macho.git","svn_url":"https://github.com/Homebrew/ruby-macho","homepage":"https://rubygems.org/gems/ruby-macho","size":626,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57"},"html":{"href":"https://github.com/Homebrew/ruby-macho/pull/57"},"issue":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/issues/57"},"comments":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/Homebrew/ruby-macho/statuses/7f2dd3133bba94b1f7feefaf90634d232f4169b7"}}}}
{"actor":{"display_login":"UniqMartin"}}