Moodle with Ruby On Rails - ruby

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?

Related

How to use ckan gem Comprehensive Knowledge Archive Network

Does anyone have a link to a tutorial on how to use the Ruby 'ckan' gem (Comprehensive Knowledge Archive Network). I want to access gov.uk data , I downloaded the gem but how do I get to the data ? The documentation seems a bit sparse in this area
Many thanks for any help. My googling has turned up nothing so far so any help is much appreciated.
The CKAN gem's documentation is in their repository at https://github.com/apohllo/ckan. Note that it's not OKFN's CKAN repository.
Looking at their code, it seems that they hardcoded http://datahub.io API endpoint at https://github.com/apohllo/CKAN/blob/master/lib/ckan.rb#L2. So you won't be able to access data.gov.uk without changing their code.
But, thanks to Ruby being such a dynamic language, you could override that constant, as
CKAN::API_BASE = 'http://data.gov.uk/api/1'
Now you could follow their documentation in GitHub, and it should work.
Cheers!

What methods exist to auto-generate ruby client stubs from WSDL files?

I'm using Ruby and the Savon gem to interact with SOAP/WS and would like to auto-generate the client request methods from the WSDL in Ruby.
Before I do this, I'd like to know if there's any other Ruby/SOAP library that does this?
Edit: Please note, I already know this isn't available in Savon out the box, in fact my intention is to add in the feature, I'm in the process checking if this exists somewhere else written in Ruby.
Since it's only few days since you asked this question, and I've run into same problem I've decided to create small script to do that.
Download - save as objects.rb for example and run with _bunde exec objects.rb path_to.wsdl_
https://gist.github.com/4622792
Let me know if it works ^^
Take a look at Savon's spec, it has pretty rich testing environment
I think ads_common by Google is relevant to you.
google-api-ads-ruby/ads_common at master ยท googleads/google-api-ads-ruby
rake generate can create the client libraries automatically from WSDL.
It is specialized for Google Ads, but this notion would be helpful to create a versatile client library automatically from WSDL in Ruby.

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.

Ruby on Rails with chargify

I want to integrate chargify to my rails app. I have user object and I want the user to be able to subscribe for one month and update the boolean column on user object. I prefer to use the API not hosted pages. How can I do that?
Is there any example for chargify on ruby on rails for handling subscriptions but with details about mvc for newbies?
Based on this thread and the Googles it looks like there is not a whole lot out there.
You could try looking at the Rails 2 example here and converting it or use the gem here (gem "chargify", "~> 0.3.0").
I know none of this is aimed at newbies but the info seems to sparse.
This might get you going. It seems that Chartify itself is written in Rails, and therfore their API is ruby code, which you can use...

File uploads using the selenium-client gem

I am using the selenium-client gem with Webrat and Cucumber to test a rails project. I have Cucumber set up pretty much as described here: https://github.com/cucumber/cucumber/wiki/Setting-up-Selenium
My problem is that Selenium is prevented from performing file uploads. Ideally I'd like to be able to replicate webrat's 'attach_file' method. I tried dodging the issue by using selenium-client's 'type' method to type the path to the required file, but this seems to fail.
Does anyone have a sugestion for a workaround using selenium-client (i.e. not the regular Selenium gem)?
The normal selenium can't do this because browser security prevents javascript from writing to input=file elements. This is a security feature so that your password file doesnt get uploaded to hackers if you go to a site thats been hacked.
http://jira.openqa.org/browse/SEL-63 has the details
I finally figured this out.
You need to be using firefox with the chrome backend, and you need to specifiy an absolute filepath.
I ended up creating a helper module to specify the filepath, and a "fixtures" folder containing test content. Here is a gist of the solution I came up with: http://gist.github.com/214185
Therefore it is totally possible to replicate Webrat's attach_file method!

Resources