{"action":"created","comment":{"url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/comments/24320627","id":24320627,"diff_hunk":"@@ -0,0 +1,99 @@\n+module IpWrangler\n+  class DB\n+    def initialize(db_name, logger)\n+      @db = Sequel.connect('sqlite://' + db_name)\n+      @logger = logger\n+    end\n+\n+    def select_nat_port(private_ip = nil, private_port = nil, protocol = nil)\n+      params = { private_ip: private_ip, private_port: private_port,\n+                 protocol: protocol }.select do |_, value|\n+        !value.nil?\n+      end\n+      nat_ports = []\n+      @db[:nat_ports].where(params).each do |nat_port|\n+        if nat_port[:private_port] && nat_port[:private_port]\n+          nat_ports.push(nat_port)\n+        end\n+      end\n+      nat_ports\n+    end\n+\n+    def select_nat_ip(private_ip = nil, public_ip = nil)\n+      params = { private_ip: private_ip, public_ip: public_ip }.select do |_, value|\n+        !value.nil?\n+      end\n+      nat_ips = []\n+      @db[:nat_ips].where(params).each do |nat_ip|\n+        if nat_ip[:private_ip]\n+          nat_ips.push(nat_ip)\n+        end\n+      end\n+      nat_ips\n+    end\n+\n+    def insert_nat_port(public_ip, public_port, private_ip, private_port, protocol)","path":"lib/ip_wrangler/db.rb","position":35,"original_position":35,"commit_id":"6dabb822907cf69e238e98cf62f461265bbb9634","original_commit_id":"6dabb822907cf69e238e98cf62f461265bbb9634","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [83/80]","created_at":"2015-02-09T10:55:22Z","updated_at":"2015-02-09T10:55:22Z","html_url":"https://github.com/dice-cyfronet/ip-wrangler/pull/4#discussion_r24320627","pull_request_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/comments/24320627"},"html":{"href":"https://github.com/dice-cyfronet/ip-wrangler/pull/4#discussion_r24320627"},"pull_request":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4","id":27834569,"html_url":"https://github.com/dice-cyfronet/ip-wrangler/pull/4","diff_url":"https://github.com/dice-cyfronet/ip-wrangler/pull/4.diff","patch_url":"https://github.com/dice-cyfronet/ip-wrangler/pull/4.patch","issue_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/4","number":4,"state":"open","locked":false,"title":"Migrate to gem","user":{"login":"paoolo","id":3436085,"avatar_url":"https://avatars.githubusercontent.com/u/3436085?v=3","gravatar_id":"","url":"https://api.github.com/users/paoolo","html_url":"https://github.com/paoolo","followers_url":"https://api.github.com/users/paoolo/followers","following_url":"https://api.github.com/users/paoolo/following{/other_user}","gists_url":"https://api.github.com/users/paoolo/gists{/gist_id}","starred_url":"https://api.github.com/users/paoolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paoolo/subscriptions","organizations_url":"https://api.github.com/users/paoolo/orgs","repos_url":"https://api.github.com/users/paoolo/repos","events_url":"https://api.github.com/users/paoolo/events{/privacy}","received_events_url":"https://api.github.com/users/paoolo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-22T11:13:53Z","updated_at":"2015-02-09T10:55:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5eb6febfe7ab3be2edbb5cf1d55304bccc9eb6f1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4/commits","review_comments_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4/comments","review_comment_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/4/comments","statuses_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/statuses/6dabb822907cf69e238e98cf62f461265bbb9634","head":{"label":"dice-cyfronet:task_create_gem","ref":"task_create_gem","sha":"6dabb822907cf69e238e98cf62f461265bbb9634","user":{"login":"dice-cyfronet","id":1628782,"avatar_url":"https://avatars.githubusercontent.com/u/1628782?v=3","gravatar_id":"","url":"https://api.github.com/users/dice-cyfronet","html_url":"https://github.com/dice-cyfronet","followers_url":"https://api.github.com/users/dice-cyfronet/followers","following_url":"https://api.github.com/users/dice-cyfronet/following{/other_user}","gists_url":"https://api.github.com/users/dice-cyfronet/gists{/gist_id}","starred_url":"https://api.github.com/users/dice-cyfronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dice-cyfronet/subscriptions","organizations_url":"https://api.github.com/users/dice-cyfronet/orgs","repos_url":"https://api.github.com/users/dice-cyfronet/repos","events_url":"https://api.github.com/users/dice-cyfronet/events{/privacy}","received_events_url":"https://api.github.com/users/dice-cyfronet/received_events","type":"Organization","site_admin":false},"repo":{"id":27371146,"name":"ip-wrangler","full_name":"dice-cyfronet/ip-wrangler","owner":{"login":"dice-cyfronet","id":1628782,"avatar_url":"https://avatars.githubusercontent.com/u/1628782?v=3","gravatar_id":"","url":"https://api.github.com/users/dice-cyfronet","html_url":"https://github.com/dice-cyfronet","followers_url":"https://api.github.com/users/dice-cyfronet/followers","following_url":"https://api.github.com/users/dice-cyfronet/following{/other_user}","gists_url":"https://api.github.com/users/dice-cyfronet/gists{/gist_id}","starred_url":"https://api.github.com/users/dice-cyfronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dice-cyfronet/subscriptions","organizations_url":"https://api.github.com/users/dice-cyfronet/orgs","repos_url":"https://api.github.com/users/dice-cyfronet/repos","events_url":"https://api.github.com/users/dice-cyfronet/events{/privacy}","received_events_url":"https://api.github.com/users/dice-cyfronet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dice-cyfronet/ip-wrangler","description":"IP NAT and port mapping management Web service","fork":false,"url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler","forks_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/forks","keys_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/teams","hooks_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/hooks","issue_events_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/events{/number}","events_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/events","assignees_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/assignees{/user}","branches_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/branches{/branch}","tags_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/tags","blobs_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/refs{/sha}","trees_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/statuses/{sha}","languages_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/languages","stargazers_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/stargazers","contributors_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/contributors","subscribers_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/subscribers","subscription_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/subscription","commits_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/commits{/sha}","git_commits_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/commits{/sha}","comments_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/comments{/number}","issue_comment_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/comments/{number}","contents_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/contents/{+path}","compare_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/merges","archive_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/downloads","issues_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues{/number}","pulls_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls{/number}","milestones_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/milestones{/number}","notifications_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/labels{/name}","releases_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/releases{/id}","created_at":"2014-12-01T09:04:34Z","updated_at":"2015-02-06T23:14:57Z","pushed_at":"2015-02-09T10:55:15Z","git_url":"git://github.com/dice-cyfronet/ip-wrangler.git","ssh_url":"git@github.com:dice-cyfronet/ip-wrangler.git","clone_url":"https://github.com/dice-cyfronet/ip-wrangler.git","svn_url":"https://github.com/dice-cyfronet/ip-wrangler","homepage":"","size":808,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"dice-cyfronet:master","ref":"master","sha":"d8554504995dfe4899313e6b2e5f05fa2b97d523","user":{"login":"dice-cyfronet","id":1628782,"avatar_url":"https://avatars.githubusercontent.com/u/1628782?v=3","gravatar_id":"","url":"https://api.github.com/users/dice-cyfronet","html_url":"https://github.com/dice-cyfronet","followers_url":"https://api.github.com/users/dice-cyfronet/followers","following_url":"https://api.github.com/users/dice-cyfronet/following{/other_user}","gists_url":"https://api.github.com/users/dice-cyfronet/gists{/gist_id}","starred_url":"https://api.github.com/users/dice-cyfronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dice-cyfronet/subscriptions","organizations_url":"https://api.github.com/users/dice-cyfronet/orgs","repos_url":"https://api.github.com/users/dice-cyfronet/repos","events_url":"https://api.github.com/users/dice-cyfronet/events{/privacy}","received_events_url":"https://api.github.com/users/dice-cyfronet/received_events","type":"Organization","site_admin":false},"repo":{"id":27371146,"name":"ip-wrangler","full_name":"dice-cyfronet/ip-wrangler","owner":{"login":"dice-cyfronet","id":1628782,"avatar_url":"https://avatars.githubusercontent.com/u/1628782?v=3","gravatar_id":"","url":"https://api.github.com/users/dice-cyfronet","html_url":"https://github.com/dice-cyfronet","followers_url":"https://api.github.com/users/dice-cyfronet/followers","following_url":"https://api.github.com/users/dice-cyfronet/following{/other_user}","gists_url":"https://api.github.com/users/dice-cyfronet/gists{/gist_id}","starred_url":"https://api.github.com/users/dice-cyfronet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dice-cyfronet/subscriptions","organizations_url":"https://api.github.com/users/dice-cyfronet/orgs","repos_url":"https://api.github.com/users/dice-cyfronet/repos","events_url":"https://api.github.com/users/dice-cyfronet/events{/privacy}","received_events_url":"https://api.github.com/users/dice-cyfronet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dice-cyfronet/ip-wrangler","description":"IP NAT and port mapping management Web service","fork":false,"url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler","forks_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/forks","keys_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/teams","hooks_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/hooks","issue_events_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/events{/number}","events_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/events","assignees_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/assignees{/user}","branches_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/branches{/branch}","tags_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/tags","blobs_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/refs{/sha}","trees_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/statuses/{sha}","languages_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/languages","stargazers_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/stargazers","contributors_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/contributors","subscribers_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/subscribers","subscription_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/subscription","commits_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/commits{/sha}","git_commits_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/git/commits{/sha}","comments_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/comments{/number}","issue_comment_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/comments/{number}","contents_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/contents/{+path}","compare_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/merges","archive_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/downloads","issues_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues{/number}","pulls_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls{/number}","milestones_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/milestones{/number}","notifications_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/labels{/name}","releases_url":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/releases{/id}","created_at":"2014-12-01T09:04:34Z","updated_at":"2015-02-06T23:14:57Z","pushed_at":"2015-02-09T10:55:15Z","git_url":"git://github.com/dice-cyfronet/ip-wrangler.git","ssh_url":"git@github.com:dice-cyfronet/ip-wrangler.git","clone_url":"https://github.com/dice-cyfronet/ip-wrangler.git","svn_url":"https://github.com/dice-cyfronet/ip-wrangler","homepage":"","size":808,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4"},"html":{"href":"https://github.com/dice-cyfronet/ip-wrangler/pull/4"},"issue":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/4"},"comments":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/dice-cyfronet/ip-wrangler/statuses/6dabb822907cf69e238e98cf62f461265bbb9634"}}}}