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!
Related
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?
Summarize the problem:
Being relatively new to Ruby/Gems and developing in general, some concepts evade me
I'm learning about the google-api-client Gem, and am attempting to understand the Basic Usage, and want to know how a developer knows which class to use, when instantiating an ojbect, during the "aliasing of the module" portion:
To use an API, include the corresponding generated file and instantiate the service. For example to use the Drive API:
require 'google/apis/drive_v2'
Drive = Google::Apis::DriveV2 # Alias the module
drive = Drive::DriveService.new # why is ::DriveService used here?
#etc
Describe what I've tried:
I've searched through the reference documentation for the google-api-client for a clue about the "decision" to instantiate drive with ::DriveService.new
The best reason I've come up with is: DriveService is instantiated because it is the "BaseService" of the "DriveV2" Class.... but I'm reaching for straws with this logic.
My specific question is:
How does a developer using APIs and this Google-API-client Gem know which object to instantiate?
I have to imagine there's a more elegant "way" to determine which object to instantiate at this point of accessing an API than digging through the documentation of the Gem....I mean...the "BaseService" information is coming from the documentation for this specific Gem.....
Maybe this is a matter of me losing "scope" per say by the Google API and the ambiguously named Gem maintained by Google...
But then again...if I'm using this Gem...then this documentation would always apply, because I wouldn't be able to use this Gem if it wasn't a Google-API....
from the documentation
The link above is the necessary detail regarding Authorization for an API key.
If you're like me, and this subject is new to you, there are three topics that you need to understand:
Authentication
Authorization
Accounting
The documentation for the google-api-client gem is robust enough to answer a lot of questions, however, my answer here is hopefully enough to get you pointed in the right direction.
I'm leaving the question up, in case anyone else needs some guidance regarding this same subject.
I am trying to create a simple reply from my twitter timeline but ran into some problems and as a ruby newbie I had problems in understanding the doc.
Twitter.mentions_timeline.each do |tweet|
reply_to = tweet.from_user_name()
#Twitter.update("##{reply_to} Not today.")
end
This is what've written so far, which is not much. Unfortunately the tweet doesn't have any from_user_name when using the mentions_timeline it seems. I am using this gem and does not find any good examples of this: https://github.com/sferik/twitter
Would be very nice to have some nice example of how to grab ones tweets from the timeline and replying to those. Also does twitter have anything that distinguish "new tweets" or do I need to create some kind of storage myself to seperate new from old?
Thanks in advance :)
EDIT: to clarify, I want to get all tweets sent to me directly and reply to them. I don't really want to continue in any conversation.
A little late, but in the lastest version of twitter gem you can reply to a tweet with:
#client.update("##{reply_to.user.username} Not today.", in_reply_to_status_id: reply_to.id)
Hope this helps someone.
Here are a few examples that might be helpful for anyone using sferik's twitter gem for something like this. Note, I'm using version 5.0.0 currently, so your mileage may vary.
Assuming you've configured the REST client and assigned it to a variable named client, you can get an array of your last 20 mentions (or however many you've received in the past 2 months, if fewer) with this line:
client.mentions_timeline.map(&:full_text)
The respective mentioners of those tweets can be acquired similarly with this:
client.mentions_timeline.map(&:user).map(&:username)
You could then use client.update as suggested to reply as you see fit.
One tool I find incredibly useful when I'm exploring API's in Ruby is pry. Just require it, drop a binding.pry, and run your code in Terminal. Then you can explore to your heart's — or API's limit's — extent.
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.
Is there any gem for the Picasa API? I've tried to use github.com/morgoth/picasa, but this gem does not support authorized requests.
These are my findings about Gems for Picasa in ruby on rails.
https://github.com/pangloss/ruby_picasa
https://github.com/morgoth/picasa
The second one is new and will help you, best of luck.
If still interested, you can use http://picasaonrails.googlecode.com/ It allows uploading and album creation
check http://picasaonrails.googlecode.com/svn/trunk/picasa_on_rails/README for use samples
To use it you can install as a plugin or just download http://picasaonrails.googlecode.com/svn/trunk/picasa_on_rails/lib/picasa.rb and http://picasaonrails.googlecode.com/svn/trunk/picasa_on_rails/lib/multipartpost.rb for any ruby (not rails) project
I'm a contributor. I don't know if it's the best, but I use it in production: https://github.com/mkraft/PicasaWebAlbums