Octokit GitHub API: restrict who can push to a branch - ruby

I'm using the octokit gem to communicate with the GitHub API and am trying to find a way to restrict who can push to a protected branch. I've attached a screenshot of where this is done in the web console:
My problem is that at the moment I can't find a way to do this with octokit. Anyone know if I've missed something or if this is something that isn't possible through the API yet?

You're not missing anything -- it's not available via the API yet, but it is something we'd like to provide. Follow the blog for updates: https://developer.github.com/changes/

It looks like the API call to add a user restriction was recently added. You should be able to add this to the octokit gem.

Related

How do I retrieve the response.URL using Faraday gem?

I'm using Faraday to check for broken links, and I want to retrieve the response.URL of the links I'm querying, however, I am not able to find any documentation and examples to do so.
I was able to do this on the front-end using Javascript's Fetch API (Response.url: https://developer.mozilla.org/en-US/docs/Web/API/Response/url) but that is not an option now as I am required to do this on the backend using Faraday only.
Is this even possible with Faraday? If so, how do I implement it? Or kindly point me to the right documentation.
There are lots of class variables instantiated in the response object: response.env
You might be looking at:
response.env.url.to_s

Moodle with Ruby On Rails

Currently, I am working on a rails application which requires the user to be registered automatically in the moodle. I searched for it and found these gems,
moodle-api: https://github.com/getsmarter/moodle-api
moodle_rb: https://github.com/jobready/moodle-rb/
moodle: https://github.com/robertboloc/moodle
But, nothing seems to work for me. I even searched on youtube but found nothing with the rails.
However, using the moodle_rb gem I was able to create an object which returned me the sites info using the sites_info function. Other than that I am unable to use any of the web services of the moodle. I have created an external service and added some functions like auth_email_get_signup_settings and auth_email_signup_user which accepts none parameters.
May anyone guides me through this? or even a minor help would also be great.
I am using a token to create the object.
Thanks in advance.
Can you show us how you tried to configure your gems? For example, according to the docs the moddle-api gem requires a configuration like:
Moodle::Api.configure do|c|
c.host = 'http://my_moodle_instance.com'
c.token = 'mytoken'
end
If you did configure the gem like the above, can you show some of the code that you tried to call once the gem was installed and configured?

Api for google-api-client gem

How do I get the api of this gem? I could currently get the name and email of the user with
google_client.execute!(:api_method => GoogleLogic.get_google_oauth2.userinfo.get).data.name
google_client.execute!(:api_method => GoogleLogic.get_google_oauth2.userinfo.get).data.email
but no where are these methods written in the official page of this gem
http://code.google.com/p/google-api-ruby-client/
Since the ruby client is generated dynamically, it may not have API docs. You can see the API definition here:
https://www.googleapis.com/discovery/v1/apis/oauth2/v1/rest
It might be useful to you to see what methods/attributes are generated in the library.
Not sure if this is relevant anymore, but I found the documentation on the github page quite useful:
https://github.com/google/google-api-ruby-client
And also the samples:
https://github.com/google/google-api-ruby-client-samples
Lastly, the developers console in google is very useful.
http://console.developers.google.com/

How do I ignore requests to a certain route in Sinatra when using NewRelic?

We're using NewRelic to monitor a Sinatra app. We don't want the probe URL varnish uses to check if the app is online to be instrumented by NewRelic. How do we tell NewRelic to ignore a certain Sinatra route? (The documentation only seems to refer to how to do this in Rails: https://newrelic.com/docs/ruby/blocking-controller-instrumentation)
You could try calling NewRelic::Agent.abort_transaction! within the code path for the probe request. See the API docs for details.
Have you tried what their docs suggest https://newrelic.com/docs/ruby/sinatra-support-in-the-ruby-agent
newrelic_ignore '/ping'
As of version 3.6.3 of the NewRelic gem, you can should be able to use the 'newrelic_ignore' method to ignore endpoints. If you are using Sinatra, you may need to call this class method explicitly, like so:
NewRelic::Agent::Instrumentation::Sinatra::newrelic_ignore('/route/to/ignore')
But, it doesn't work as expected. I am filing a bug report with NewRelic.

Is there a way to retrieve Heroku logs over HTTP?

I'd like to access Heroku logs for an app without using the command line. Is this possible?
Yes, you can. It's a simple REST API. There aren't any JavaScript wrappers for the API, but you can use these as reference implementations, or use them directly:
https://github.com/heroku/heroku.jar
https://github.com/heroku/heroku.rb
https://github.com/heroku/heroku.py
Currently No. If you're looking to use this from within a Ruby based app you can embed the heroku gem and use it programatically which might help.

Resources