module GitFeats::API

Constants

URL

Public Instance Methods

upload_feats() click to toggle source
# File lib/git-feats/api.rb, line 11
def upload_feats
  # Post json to git-feats
  begin
    puts "Updating feats on gitfeats.com..."
    # Attempt to update feats
    conn.post do |req|
      req.url '/api/post_feats'
      req.headers['Content-Type'] = 'application/json'
      req.body = upload_feats_body.to_json
    end
    puts
  rescue
    puts "Connection failed!\n\n"
  end
end

Private Instance Methods

conn() click to toggle source

Return the faraday connection or create one

# File lib/git-feats/api.rb, line 30
def conn
  @conn ||= new_connection
end
new_connection() click to toggle source
# File lib/git-feats/api.rb, line 34
def new_connection
  # Create git-feats connection
  Faraday.new(:url => URL) do |faraday|
    faraday.request  :url_encoded
    faraday.adapter  Faraday.default_adapter
  end
end
upload_feats_body() click to toggle source

Construct the body for the upload feats post

# File lib/git-feats/api.rb, line 43
def upload_feats_body
  {
    :username  => Config.name,
    :key       => Config.key,
    :history   => History.data
  }
end