{"action":"created","comment":{"url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/comments/39555818","id":39555818,"diff_hunk":"@@ -0,0 +1,204 @@\n+require_relative 'dino_dex'\n+\n+class DinoDexShell\n+  attr_accessor :working_directory, :dex, :file_finder\n+\n+  VALID_OPTION = /[plsaeq]/\n+  PRINT_LINE_LENGTH = 40\n+  PRINT_LINE_PADDING = 2\n+\n+  def start_shell\n+    @dex = DinoDex.new\n+    @file_finder = FileFinder.new(\".\", \"*.csv\")\n+    @header_line_length   = 50\n+    @header_line_padding  = 2\n+    clear_screen\n+    print_header\n+    gets_option\n+  end\n+\n+  private\n+\n+  def print_main\n+    clear_screen\n+    print_header\n+  end\n+\n+  def state_info\n+    printf(\n+      \"Dinosaurs:\\t\\t(%s)\\nWorking Path:\\t\\t(%s)\\nCSV Files Found:\\t(%s)\\n\\n\",\n+      @dex.dinosaurs.length,\n+      @file_finder.directory_path,\n+      @file_finder.files.length\n+    )\n+  end\n+\n+  def state_options\n+    puts \"COMMANDS:\\t\\t(P): Set Path, (L): Load CSV, (S): Search, (A): List Dinosaurs\"\n+    puts \"\\t\\t\\t(E): Export JSON Dinosaurs, (Q): Quit DinoDex\\n\\n\"\n+  end\n+\n+  def print_header\n+    header_line\n+    header_line(\"Jurassic Park, DinoDex Interface\")\n+    header_line(\"Version 4.0.5, Alpha E\")\n+    header_line\n+  end\n+\n+  def header_line(line_str = \"\")\n+    return print_line if line_str == \"\"\n+    empty_space = PRINT_LINE_LENGTH - line_str.length - (PRINT_LINE_PADDING * 2)\n+    return puts \"#\" * PRINT_LINE_LENGTH if empty_space < 0\n+    line_str = \"##\" + (\" \" * (empty_space / 2)) + line_str + (\" \" * (empty_space / 2))\n+    return printf(line_str + \" ##\\n\") unless empty_space.even?\n+    printf(line_str + \"##\\n\")\n+  end\n+\n+  def print_line\n+    puts \"#\" * PRINT_LINE_LENGTH\n+  end\n+\n+  def clear_screen\n+    system(\"clear\") || system(\"cls\")\n+  end\n+\n+  def gets_option\n+    state_info\n+    state_options\n+    print \"> \"\n+    do_option(parse_option(gets))\n+    gets_option\n+  end\n+\n+  def do_option(input)\n+    case input\n+      when \"p\" then prompt_set_path\n+      when \"l\" then prompt_load_csv\n+      when \"s\" then prompt_search_dinodex\n+      when \"a\" then list_dinosaurs\n+      when \"q\" then stop_shell\n+      when \"e\" then export_dinosaurs\n+      else gets_option\n+    end\n+  end\n+\n+  def parse_option(input)\n+    input = input.strip.downcase\n+    return unless valid_option?(input)\n+    input\n+  end\n+\n+  def valid_option?(input)\n+    valid = VALID_OPTION =~ input\n+    return true if valid\n+    puts \"Not a valid option.\"\n+    false\n+  end\n+\n+  def prompt_set_path\n+    printf \"Please specify the CSV search path or (!Q)uit: \"\n+    input = gets.strip\n+    case input.downcase\n+      when \"!q\" then print_main\n+      else\n+        prompt_set_path unless set_working_dir(input)\n+        @file_finder.search\n+        print_main\n+    end\n+  end\n+\n+  def set_working_dir(dir = \"\")\n+    dir = \".\" if dir == \"\"\n+    unless Dir.exist?(dir)\n+      puts \"Directory specified does not exist.\"\n+      return false\n+    end\n+    @file_finder.directory_path = dir\n+  end\n+\n+  def search_dinodex(args)\n+    @dex.select_hash(args)\n+  end\n+\n+  def prompt_search_dinodex\n+    clear_screen\n+    print_header\n+    if @dex.dinosaurs.empty?\n+      return puts \"No dinosaurs loaded into DinoDex system... Please load from CSV files first.\\n\\n\"\n+    end\n+    puts \"\\nSEARCH OPTIONS: name, period, diet, weight, walking\"\n+    puts \"\\nEXAMPLE: 'diet: carnivore, walking: biped, weight: <2000'\"\n+    puts \"\\nPlease enter search parameters in new ruby hash form or (!Q)uit\"\n+    input = gets.strip\n+    case input.downcase\n+      when \"!q\" then print_main\n+      else\n+        clear_screen\n+        print_header\n+        puts \"\\nDinosaur Search Results:\\n-----\"\n+        search_hash = parse_search_options(input)\n+        @dex.select_hash(search_hash).print_data(search_hash.keys.unshift(\"name\"))","path":"dino_catalog/dino_dex_shell.rb","position":140,"original_position":140,"commit_id":"9710c6df89075b7c47e1213391138f50dd6f4383","original_commit_id":"9710c6df89075b7c47e1213391138f50dd6f4383","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. [82/80]","created_at":"2015-09-15T19:47:27Z","updated_at":"2015-09-15T19:47:27Z","html_url":"https://github.com/jmmastey/level_up_exercises/pull/987#discussion_r39555818","pull_request_url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987","_links":{"self":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/comments/39555818"},"html":{"href":"https://github.com/jmmastey/level_up_exercises/pull/987#discussion_r39555818"},"pull_request":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987"}}},"pull_request":{"url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987","id":45093523,"html_url":"https://github.com/jmmastey/level_up_exercises/pull/987","diff_url":"https://github.com/jmmastey/level_up_exercises/pull/987.diff","patch_url":"https://github.com/jmmastey/level_up_exercises/pull/987.patch","issue_url":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/987","number":987,"state":"open","locked":false,"title":"DinoCatalog v3","user":{"login":"Manbearpixel","id":6686750,"avatar_url":"https://avatars.githubusercontent.com/u/6686750?v=3","gravatar_id":"","url":"https://api.github.com/users/Manbearpixel","html_url":"https://github.com/Manbearpixel","followers_url":"https://api.github.com/users/Manbearpixel/followers","following_url":"https://api.github.com/users/Manbearpixel/following{/other_user}","gists_url":"https://api.github.com/users/Manbearpixel/gists{/gist_id}","starred_url":"https://api.github.com/users/Manbearpixel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manbearpixel/subscriptions","organizations_url":"https://api.github.com/users/Manbearpixel/orgs","repos_url":"https://api.github.com/users/Manbearpixel/repos","events_url":"https://api.github.com/users/Manbearpixel/events{/privacy}","received_events_url":"https://api.github.com/users/Manbearpixel/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-15T19:47:18Z","updated_at":"2015-09-15T19:47:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"392bdec77aecfe7f5d576e2a31c30ea80a1476e3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987/commits","review_comments_url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987/comments","review_comment_url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/987/comments","statuses_url":"https://api.github.com/repos/jmmastey/level_up_exercises/statuses/9710c6df89075b7c47e1213391138f50dd6f4383","head":{"label":"Manbearpixel:vbull/dino_catalog","ref":"vbull/dino_catalog","sha":"9710c6df89075b7c47e1213391138f50dd6f4383","user":{"login":"Manbearpixel","id":6686750,"avatar_url":"https://avatars.githubusercontent.com/u/6686750?v=3","gravatar_id":"","url":"https://api.github.com/users/Manbearpixel","html_url":"https://github.com/Manbearpixel","followers_url":"https://api.github.com/users/Manbearpixel/followers","following_url":"https://api.github.com/users/Manbearpixel/following{/other_user}","gists_url":"https://api.github.com/users/Manbearpixel/gists{/gist_id}","starred_url":"https://api.github.com/users/Manbearpixel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manbearpixel/subscriptions","organizations_url":"https://api.github.com/users/Manbearpixel/orgs","repos_url":"https://api.github.com/users/Manbearpixel/repos","events_url":"https://api.github.com/users/Manbearpixel/events{/privacy}","received_events_url":"https://api.github.com/users/Manbearpixel/received_events","type":"User","site_admin":false},"repo":{"id":40564070,"name":"level_up_exercises","full_name":"Manbearpixel/level_up_exercises","owner":{"login":"Manbearpixel","id":6686750,"avatar_url":"https://avatars.githubusercontent.com/u/6686750?v=3","gravatar_id":"","url":"https://api.github.com/users/Manbearpixel","html_url":"https://github.com/Manbearpixel","followers_url":"https://api.github.com/users/Manbearpixel/followers","following_url":"https://api.github.com/users/Manbearpixel/following{/other_user}","gists_url":"https://api.github.com/users/Manbearpixel/gists{/gist_id}","starred_url":"https://api.github.com/users/Manbearpixel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manbearpixel/subscriptions","organizations_url":"https://api.github.com/users/Manbearpixel/orgs","repos_url":"https://api.github.com/users/Manbearpixel/repos","events_url":"https://api.github.com/users/Manbearpixel/events{/privacy}","received_events_url":"https://api.github.com/users/Manbearpixel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Manbearpixel/level_up_exercises","description":"A series of code-related assignments to challenge starting engineers","fork":true,"url":"https://api.github.com/repos/Manbearpixel/level_up_exercises","forks_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/forks","keys_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/teams","hooks_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/hooks","issue_events_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/issues/events{/number}","events_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/events","assignees_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/assignees{/user}","branches_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/branches{/branch}","tags_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/tags","blobs_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/statuses/{sha}","languages_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/languages","stargazers_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/stargazers","contributors_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/contributors","subscribers_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/subscribers","subscription_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/subscription","commits_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/contents/{+path}","compare_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/merges","archive_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/downloads","issues_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/issues{/number}","pulls_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/pulls{/number}","milestones_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/milestones{/number}","notifications_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/labels{/name}","releases_url":"https://api.github.com/repos/Manbearpixel/level_up_exercises/releases{/id}","created_at":"2015-08-11T20:38:33Z","updated_at":"2015-08-11T20:38:34Z","pushed_at":"2015-09-15T19:46:03Z","git_url":"git://github.com/Manbearpixel/level_up_exercises.git","ssh_url":"git@github.com:Manbearpixel/level_up_exercises.git","clone_url":"https://github.com/Manbearpixel/level_up_exercises.git","svn_url":"https://github.com/Manbearpixel/level_up_exercises","homepage":"http://leveluprails.herokuapp.com","size":386,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jmmastey:master","ref":"master","sha":"573aed5af1dff6995e407c7c9c16cdaa9aa183ca","user":{"login":"jmmastey","id":302011,"avatar_url":"https://avatars.githubusercontent.com/u/302011?v=3","gravatar_id":"","url":"https://api.github.com/users/jmmastey","html_url":"https://github.com/jmmastey","followers_url":"https://api.github.com/users/jmmastey/followers","following_url":"https://api.github.com/users/jmmastey/following{/other_user}","gists_url":"https://api.github.com/users/jmmastey/gists{/gist_id}","starred_url":"https://api.github.com/users/jmmastey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmmastey/subscriptions","organizations_url":"https://api.github.com/users/jmmastey/orgs","repos_url":"https://api.github.com/users/jmmastey/repos","events_url":"https://api.github.com/users/jmmastey/events{/privacy}","received_events_url":"https://api.github.com/users/jmmastey/received_events","type":"User","site_admin":false},"repo":{"id":20705648,"name":"level_up_exercises","full_name":"jmmastey/level_up_exercises","owner":{"login":"jmmastey","id":302011,"avatar_url":"https://avatars.githubusercontent.com/u/302011?v=3","gravatar_id":"","url":"https://api.github.com/users/jmmastey","html_url":"https://github.com/jmmastey","followers_url":"https://api.github.com/users/jmmastey/followers","following_url":"https://api.github.com/users/jmmastey/following{/other_user}","gists_url":"https://api.github.com/users/jmmastey/gists{/gist_id}","starred_url":"https://api.github.com/users/jmmastey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmmastey/subscriptions","organizations_url":"https://api.github.com/users/jmmastey/orgs","repos_url":"https://api.github.com/users/jmmastey/repos","events_url":"https://api.github.com/users/jmmastey/events{/privacy}","received_events_url":"https://api.github.com/users/jmmastey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jmmastey/level_up_exercises","description":"A series of code-related assignments to challenge starting engineers","fork":false,"url":"https://api.github.com/repos/jmmastey/level_up_exercises","forks_url":"https://api.github.com/repos/jmmastey/level_up_exercises/forks","keys_url":"https://api.github.com/repos/jmmastey/level_up_exercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jmmastey/level_up_exercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jmmastey/level_up_exercises/teams","hooks_url":"https://api.github.com/repos/jmmastey/level_up_exercises/hooks","issue_events_url":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/events{/number}","events_url":"https://api.github.com/repos/jmmastey/level_up_exercises/events","assignees_url":"https://api.github.com/repos/jmmastey/level_up_exercises/assignees{/user}","branches_url":"https://api.github.com/repos/jmmastey/level_up_exercises/branches{/branch}","tags_url":"https://api.github.com/repos/jmmastey/level_up_exercises/tags","blobs_url":"https://api.github.com/repos/jmmastey/level_up_exercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jmmastey/level_up_exercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jmmastey/level_up_exercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/jmmastey/level_up_exercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jmmastey/level_up_exercises/statuses/{sha}","languages_url":"https://api.github.com/repos/jmmastey/level_up_exercises/languages","stargazers_url":"https://api.github.com/repos/jmmastey/level_up_exercises/stargazers","contributors_url":"https://api.github.com/repos/jmmastey/level_up_exercises/contributors","subscribers_url":"https://api.github.com/repos/jmmastey/level_up_exercises/subscribers","subscription_url":"https://api.github.com/repos/jmmastey/level_up_exercises/subscription","commits_url":"https://api.github.com/repos/jmmastey/level_up_exercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/jmmastey/level_up_exercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/jmmastey/level_up_exercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/jmmastey/level_up_exercises/contents/{+path}","compare_url":"https://api.github.com/repos/jmmastey/level_up_exercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jmmastey/level_up_exercises/merges","archive_url":"https://api.github.com/repos/jmmastey/level_up_exercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jmmastey/level_up_exercises/downloads","issues_url":"https://api.github.com/repos/jmmastey/level_up_exercises/issues{/number}","pulls_url":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls{/number}","milestones_url":"https://api.github.com/repos/jmmastey/level_up_exercises/milestones{/number}","notifications_url":"https://api.github.com/repos/jmmastey/level_up_exercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jmmastey/level_up_exercises/labels{/name}","releases_url":"https://api.github.com/repos/jmmastey/level_up_exercises/releases{/id}","created_at":"2014-06-10T23:42:24Z","updated_at":"2015-09-07T17:04:58Z","pushed_at":"2015-09-15T19:47:18Z","git_url":"git://github.com/jmmastey/level_up_exercises.git","ssh_url":"git@github.com:jmmastey/level_up_exercises.git","clone_url":"https://github.com/jmmastey/level_up_exercises.git","svn_url":"https://github.com/jmmastey/level_up_exercises","homepage":"https://leveluprails.com","size":222986,"stargazers_count":27,"watchers_count":27,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"open_issues_count":6,"forks":138,"open_issues":6,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987"},"html":{"href":"https://github.com/jmmastey/level_up_exercises/pull/987"},"issue":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/987"},"comments":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/issues/987/comments"},"review_comments":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987/comments"},"review_comment":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/pulls/987/commits"},"statuses":{"href":"https://api.github.com/repos/jmmastey/level_up_exercises/statuses/9710c6df89075b7c47e1213391138f50dd6f4383"}}}}