GitHub PullRequestReviewCommentEvent at 2014-04-15 19:40:45
Repository: nacre
Actor: houndci
Payload: {"comment":{"url":"https://api.github.com/repos/allolex/nacre/pulls/comments/11653523","id":11653523,"diff_hunk":"@@ -0,0 +1,124 @@\n+require 'uri'\n+require 'json'\n+require 'nacre/concerns/matchable'\n+require 'nacre/concerns/parametrizable'\n+require 'nacre/concerns/inflectible'\n+\n+module Nacre\n+  class AbstractResource\n+\n+    include Matchable\n+    include Parametrizable\n+    extend Inflectible\n+\n+    def self.fields\n+      @fields ||= []\n+    end\n+\n+    def self.attribute(name)\n+      self.fields << name\n+      attr_accessor name\n+    end\n+\n+    def initialize(options = {})\n+      self.attributes = options\n+    end\n+\n+    def attributes=(attributes_hash)\n+      self.class.fields.each do |field|\n+        if attributes_hash.has_key?(field.to_sym)\n+          public_send(\"#{field}=\", attributes_hash[field.to_sym])\n+        end\n+      end\n+    end\n+\n+    def self.from_json(json)\n+      params = params_from_json(json)\n+      new(params)\n+    end\n+\n+    # TODO: Shouldn't this be using Nacre::Response instead of Faraday::Response?\n+    def self.get(range)\n+      request_url = build_request_url(url,range,resource_options)\n+      response = self.link.get(request_url)\n+      self.from_json(response.body)\n+    end\n+\n+    def self.find(id_list = [])\n+      id_list = [id_list] unless id_list.kind_of?(Array)\n+      request_url = build_search_url(search_url,\"#{service_name}Id=#{id_list.join(',')}\")\n+      response = link.get(request_url)\n+      SearchResults.from_json(response.body)\n+    end\n+\n+    private\n+\n+    def self.service_name\n+      format_service_name(self.name)\n+    end\n+\n+    def self.format_service_name(name)\n+      name.gsub(/\\ANacre::/,'').downcase\n+    end\n+\n+    def self.build_request_url(url, query, options)\n+      \"#{url}/#{query.to_s}?#{options}\"\n+    end\n+\n+    def self.build_search_url(url, query)\n+      \"#{url}?#{query.to_s}\"\n+    end\n+\n+    def self.resource_options\n+      'includeOptional=customFields,nullCustomFields'\n+    end\n+\n+    def self.params_from_json(json)\n+      resource = JSON.parse(json)['response'].first\n+      format_hash_keys(resource)\n+    end\n+\n+    def self.format_hash_keys(value)\n+      case value\n+      when Hash\n+        Hash[ value.map { |k,v| [ fix_key(k), format_hash_keys(v) ] } ]","path":"lib/nacre/abstract_resource.rb","position":84,"original_position":84,"commit_id":"476169023705fa38f75328cfa6e9f118647166d2","original_commit_id":"476169023705fa38f75328cfa6e9f118647166d2","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","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":"Space inside square brackets detected.<br>Space missing after comma.","created_at":"2014-04-15T19:40:45Z","updated_at":"2014-04-15T19:40:45Z","html_url":"https://github.com/allolex/nacre/pull/5#discussion_r11653523","pull_request_url":"https://api.github.com/repos/allolex/nacre/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/allolex/nacre/pulls/comments/11653523"},"html":{"href":"https://github.com/allolex/nacre/pull/5#discussion_r11653523"},"pull_request":{"href":"https://api.github.com/repos/allolex/nacre/pulls/5"}}}}