{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/comments/51024088","id":51024088,"diff_hunk":"@@ -0,0 +1,55 @@\n+require 'rototiller/utilities/color_text'\n+\n+class EnvVar\n+\n+  include ColorText\n+\n+  attr_accessor :var, :message, :default\n+\n+  def initialize(var, message, default = nil)\n+    # require 'pry'; binding.pry\n+    @var = var\n+    @message = message\n+    # TODO: maybe see if the value was passed in the args array or not as a default (so that nil may be passed)\n+    # should be something like argv or similar\n+    # @default_specified = ????\n+    @default = default\n+    #test = ENV[var]\n+    #binding.pry\n+    #if test\n+    #  @value = test\n+    #else\n+    #  @value = @default\n+    #end\n+    #binding.pry\n+  end\n+\n+  def value\n+    ENV[@var] || @default\n+  end\n+\n+  def message\n+\n+    if @default && check\n+      # ENV is present and it has a default value\n+      # binding.pry\n+      green_text(\"The ENV #{@var} is being used with the value #{value} from the environment\")\n+    elsif !@default && !check\n+      # ENV is not Present and it has no default value\n+      red_text(\"The ENV #{@var} is required, #{@message}\")\n+    elsif !@default && check\n+      # ENV is present and it has no default value\n+      green_text(\"The ENV #{@var} was found in the environment with the value #{value}\")\n+    elsif @default && !check\n+      # ENV is not present and it has default value\n+      yellow = yellow_text(\"WARNING: the ENV #{@var} is not set, proceeding with default value: \")\n+      green = green_text(value)\n+      yellow << green\n+    end\n+  end\n+\n+  private\n+  def check","path":"lib/rototiller/utilities/env_var.rb","position":52,"original_position":52,"commit_id":"2c3d646cacc5705a2efe570f4753856397f1e66c","original_commit_id":"2c3d646cacc5705a2efe570f4753856397f1e66c","user":{"login":"er0ck","id":7454093,"avatar_url":"https://avatars.githubusercontent.com/u/7454093?v=3","gravatar_id":"","url":"https://api.github.com/users/er0ck","html_url":"https://github.com/er0ck","followers_url":"https://api.github.com/users/er0ck/followers","following_url":"https://api.github.com/users/er0ck/following{/other_user}","gists_url":"https://api.github.com/users/er0ck/gists{/gist_id}","starred_url":"https://api.github.com/users/er0ck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/er0ck/subscriptions","organizations_url":"https://api.github.com/users/er0ck/orgs","repos_url":"https://api.github.com/users/er0ck/repos","events_url":"https://api.github.com/users/er0ck/events{/privacy}","received_events_url":"https://api.github.com/users/er0ck/received_events","type":"User","site_admin":false},"body":"should this set a status instance var, and should it check if there is default?\r\nmaybe check is just for existence of ENV and something like is_valid?() (public) would tell if the var is usable?  then the collector would know if to spew the warnings/errors.\r\ni'd be okay doing that when we implement the collector","created_at":"2016-01-27T18:11:08Z","updated_at":"2016-01-27T18:11:08Z","html_url":"https://github.com/puppetlabs/rototiller/pull/6#discussion_r51024088","pull_request_url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/comments/51024088"},"html":{"href":"https://github.com/puppetlabs/rototiller/pull/6#discussion_r51024088"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6","id":56118103,"html_url":"https://github.com/puppetlabs/rototiller/pull/6","diff_url":"https://github.com/puppetlabs/rototiller/pull/6.diff","patch_url":"https://github.com/puppetlabs/rototiller/pull/6.patch","issue_url":"https://api.github.com/repos/puppetlabs/rototiller/issues/6","number":6,"state":"open","locked":false,"title":"(QA-2329) refactor EnvVar class","user":{"login":"zreichert","id":2602509,"avatar_url":"https://avatars.githubusercontent.com/u/2602509?v=3","gravatar_id":"","url":"https://api.github.com/users/zreichert","html_url":"https://github.com/zreichert","followers_url":"https://api.github.com/users/zreichert/followers","following_url":"https://api.github.com/users/zreichert/following{/other_user}","gists_url":"https://api.github.com/users/zreichert/gists{/gist_id}","starred_url":"https://api.github.com/users/zreichert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreichert/subscriptions","organizations_url":"https://api.github.com/users/zreichert/orgs","repos_url":"https://api.github.com/users/zreichert/repos","events_url":"https://api.github.com/users/zreichert/events{/privacy}","received_events_url":"https://api.github.com/users/zreichert/received_events","type":"User","site_admin":false},"body":"I'll move this file to a more appropriate location before merge. ","created_at":"2016-01-15T01:04:49Z","updated_at":"2016-01-27T18:11:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31eaa22a0507347a11d4f19eb75f2065ccea7c33","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/rototiller/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/rototiller/issues/6/comments","statuses_url":"https://api.github.com/repos/puppetlabs/rototiller/statuses/2c3d646cacc5705a2efe570f4753856397f1e66c","head":{"label":"zreichert:refactor_EnvVar_class","ref":"refactor_EnvVar_class","sha":"2c3d646cacc5705a2efe570f4753856397f1e66c","user":{"login":"zreichert","id":2602509,"avatar_url":"https://avatars.githubusercontent.com/u/2602509?v=3","gravatar_id":"","url":"https://api.github.com/users/zreichert","html_url":"https://github.com/zreichert","followers_url":"https://api.github.com/users/zreichert/followers","following_url":"https://api.github.com/users/zreichert/following{/other_user}","gists_url":"https://api.github.com/users/zreichert/gists{/gist_id}","starred_url":"https://api.github.com/users/zreichert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreichert/subscriptions","organizations_url":"https://api.github.com/users/zreichert/orgs","repos_url":"https://api.github.com/users/zreichert/repos","events_url":"https://api.github.com/users/zreichert/events{/privacy}","received_events_url":"https://api.github.com/users/zreichert/received_events","type":"User","site_admin":false},"repo":{"id":44704695,"name":"rototiller","full_name":"zreichert/rototiller","owner":{"login":"zreichert","id":2602509,"avatar_url":"https://avatars.githubusercontent.com/u/2602509?v=3","gravatar_id":"","url":"https://api.github.com/users/zreichert","html_url":"https://github.com/zreichert","followers_url":"https://api.github.com/users/zreichert/followers","following_url":"https://api.github.com/users/zreichert/following{/other_user}","gists_url":"https://api.github.com/users/zreichert/gists{/gist_id}","starred_url":"https://api.github.com/users/zreichert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreichert/subscriptions","organizations_url":"https://api.github.com/users/zreichert/orgs","repos_url":"https://api.github.com/users/zreichert/repos","events_url":"https://api.github.com/users/zreichert/events{/privacy}","received_events_url":"https://api.github.com/users/zreichert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zreichert/rototiller","description":"","fork":true,"url":"https://api.github.com/repos/zreichert/rototiller","forks_url":"https://api.github.com/repos/zreichert/rototiller/forks","keys_url":"https://api.github.com/repos/zreichert/rototiller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zreichert/rototiller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zreichert/rototiller/teams","hooks_url":"https://api.github.com/repos/zreichert/rototiller/hooks","issue_events_url":"https://api.github.com/repos/zreichert/rototiller/issues/events{/number}","events_url":"https://api.github.com/repos/zreichert/rototiller/events","assignees_url":"https://api.github.com/repos/zreichert/rototiller/assignees{/user}","branches_url":"https://api.github.com/repos/zreichert/rototiller/branches{/branch}","tags_url":"https://api.github.com/repos/zreichert/rototiller/tags","blobs_url":"https://api.github.com/repos/zreichert/rototiller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zreichert/rototiller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zreichert/rototiller/git/refs{/sha}","trees_url":"https://api.github.com/repos/zreichert/rototiller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zreichert/rototiller/statuses/{sha}","languages_url":"https://api.github.com/repos/zreichert/rototiller/languages","stargazers_url":"https://api.github.com/repos/zreichert/rototiller/stargazers","contributors_url":"https://api.github.com/repos/zreichert/rototiller/contributors","subscribers_url":"https://api.github.com/repos/zreichert/rototiller/subscribers","subscription_url":"https://api.github.com/repos/zreichert/rototiller/subscription","commits_url":"https://api.github.com/repos/zreichert/rototiller/commits{/sha}","git_commits_url":"https://api.github.com/repos/zreichert/rototiller/git/commits{/sha}","comments_url":"https://api.github.com/repos/zreichert/rototiller/comments{/number}","issue_comment_url":"https://api.github.com/repos/zreichert/rototiller/issues/comments{/number}","contents_url":"https://api.github.com/repos/zreichert/rototiller/contents/{+path}","compare_url":"https://api.github.com/repos/zreichert/rototiller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zreichert/rototiller/merges","archive_url":"https://api.github.com/repos/zreichert/rototiller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zreichert/rototiller/downloads","issues_url":"https://api.github.com/repos/zreichert/rototiller/issues{/number}","pulls_url":"https://api.github.com/repos/zreichert/rototiller/pulls{/number}","milestones_url":"https://api.github.com/repos/zreichert/rototiller/milestones{/number}","notifications_url":"https://api.github.com/repos/zreichert/rototiller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zreichert/rototiller/labels{/name}","releases_url":"https://api.github.com/repos/zreichert/rototiller/releases{/id}","deployments_url":"https://api.github.com/repos/zreichert/rototiller/deployments","created_at":"2015-10-21T21:10:31Z","updated_at":"2015-10-21T20:47:39Z","pushed_at":"2016-01-27T01:04:22Z","git_url":"git://github.com/zreichert/rototiller.git","ssh_url":"git@github.com:zreichert/rototiller.git","clone_url":"https://github.com/zreichert/rototiller.git","svn_url":"https://github.com/zreichert/rototiller","homepage":null,"size":23,"stargazers_count":0,"watchers_count":0,"language":null,"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":"puppetlabs:master","ref":"master","sha":"f598e2a37b3759454eab916f8c84ada526f04642","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":44703280,"name":"rototiller","full_name":"puppetlabs/rototiller","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/rototiller","description":"","fork":false,"url":"https://api.github.com/repos/puppetlabs/rototiller","forks_url":"https://api.github.com/repos/puppetlabs/rototiller/forks","keys_url":"https://api.github.com/repos/puppetlabs/rototiller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/rototiller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/rototiller/teams","hooks_url":"https://api.github.com/repos/puppetlabs/rototiller/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/rototiller/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/rototiller/events","assignees_url":"https://api.github.com/repos/puppetlabs/rototiller/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/rototiller/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/rototiller/tags","blobs_url":"https://api.github.com/repos/puppetlabs/rototiller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/rototiller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/rototiller/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/rototiller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/rototiller/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/rototiller/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/rototiller/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/rototiller/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/rototiller/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/rototiller/subscription","commits_url":"https://api.github.com/repos/puppetlabs/rototiller/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/rototiller/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/rototiller/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/rototiller/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/rototiller/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/rototiller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/rototiller/merges","archive_url":"https://api.github.com/repos/puppetlabs/rototiller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/rototiller/downloads","issues_url":"https://api.github.com/repos/puppetlabs/rototiller/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/rototiller/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/rototiller/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/rototiller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/rototiller/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/rototiller/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/rototiller/deployments","created_at":"2015-10-21T20:47:39Z","updated_at":"2016-01-27T16:55:34Z","pushed_at":"2016-01-27T16:55:32Z","git_url":"git://github.com/puppetlabs/rototiller.git","ssh_url":"git@github.com:puppetlabs/rototiller.git","clone_url":"https://github.com/puppetlabs/rototiller.git","svn_url":"https://github.com/puppetlabs/rototiller","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6"},"html":{"href":"https://github.com/puppetlabs/rototiller/pull/6"},"issue":{"href":"https://api.github.com/repos/puppetlabs/rototiller/issues/6"},"comments":{"href":"https://api.github.com/repos/puppetlabs/rototiller/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/rototiller/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/rototiller/statuses/2c3d646cacc5705a2efe570f4753856397f1e66c"}}}}