Sha256: 919a7ea06b05d8ffca73991cbcd8291844b343eb191cf1d2c1a32261536e7288

Contents?: true

Size: 791 Bytes

Versions: 16

Compression:

Stored size: 791 Bytes

Contents

module Github
  module Blob
    ENDPOINT = URI.join(Github::ROOT_ENDPOINT, 'repos/', "#{Github::OWNER}/", "#{Github::REPO}/", 'git/', 'blobs').to_s
    
    def self.get(sha)
      raise 'invalid sha #{sha} when retrieving github blob' unless Github.valid_sha?(sha)
      resp = Github.get("#{ENDPOINT}/#{sha}")
      raise "Github blob retrieve failed with http code: #{resp.code}" if resp.code != '200'
      ActiveSupport::JSON.decode(resp.body)
    end

    def self.create(content, encoding='utf-8')
      input = {
        'content' => content,
        'encoding' => encoding
      }

      resp = Github.post(ENDPOINT, input)
      raise "Github blob POST failed with http code: #{resp.code}" if resp.code != '201'
      ActiveSupport::JSON.decode(resp.body)['sha']
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev lib/github/blob.rb
aleph_analytics-0.4.8 lib/github/blob.rb
aleph_analytics-0.4.7 lib/github/blob.rb
aleph_analytics-0.4.4 lib/github/blob.rb
aleph_analytics-0.4.2 lib/github/blob.rb
aleph_analytics-0.4.1 lib/github/blob.rb
aleph_analytics-0.3.0 lib/github/blob.rb
aleph_analytics-0.2.0 lib/github/blob.rb
aleph_analytics-0.1.0 lib/github/blob.rb
aleph_analytics-0.0.6 lib/github/blob.rb
aleph_analytics-0.0.5 lib/github/blob.rb
aleph_analytics-0.0.4 lib/github/blob.rb
aleph_analytics-0.0.3 lib/github/blob.rb
aleph_analytics-0.0.2 lib/github/blob.rb
aleph_analytics-0.0.1.alpha lib/github/blob.rb
aleph_analytics-0.0.0.alpha lib/github/blob.rb