how to implement same functions in different languages? - auto-generate

I have a REST interface.
Now I want to have a client for ruby, javascript, python and java (and maybe more in the future)
Currently I am maintaining 4 different projects and their tests.
How can I improve this and what tools can I use?
currently I am starting to describe the API in a file (e.g. yaml/json) and then generate sources for each language by some logic specific to language, but that is a lot of work, and I am certain I am not the first to run into this issue.
I searched the web for generate source from yaml and such but couldn't find anything
edit: someone suggested I'd use yeoman. so currently I am investigating that.

I believe Postman as a tool is good for that. You can specify an API endpoint and generate clients for multiple languages.

Related

Information about jClouds

I have installed jclouds and I am trying to learn how it works internally.
I read all the documentation on the site and on the github but still I have lot of questions about the architecture and implementation of the jClouds.
Do you know where I can find documentation about the deep technical implementation of the framework? I am also looking information on how to add a new provider( for blobstore service)
Currently I am looking into the code but it s not always straightforward what the code does.
The best thing to do is send an email to our dev list. You can subscribe by emailing jclouds-dev-subscribe#apache.org. You can also find us on IRC at #jclouds on freenode.
Adding a new provider is quite an important change for jclouds. The first thing you'll want to do is review How To Contribute. We need to make sure it will work properly and we'll be able to properly test it so don't be discouraged by the reviews.
Having said this, a number of general considerations to take into account when starting a new provider:
New providers are added in labs first, until they are stable.
To follow the jclouds style, use a 3 space indent and a 120 character line length.
We use Guava as our core library. Try to use its utilities before adding new dependencies. In general, do not add dependencies before consulting our dev# list.
We require both live and mock tests. "mock" tests verify that the api generates the expected request according to the method annotations, and that the response is properly parsed. We use MockWebServer to do that, and you can take a look at the MockTests classes in the openstack-swift api to see an example of how these tests work.
Often the best thing to do is to copy the entire directory structure of one of the existing apis or providers and delete everything that you don't need but keep some of the files around in each directory to server as an example of how to do things. You can rename those classes and start your work from there.
Which api or provider should you choose to use as an example for your work? It depends! Please email us on our dev# list to describe the work your doing and we will recommend one. The earlier you get engaged with the jclouds community, the easier the whole process will be.
Good luck!

blog without any server side scripting, is it a good idea?

I am planning to build a website. I can build the front end with html,css and javascript with the help of twitter bootstrap and jquery ui. Actually i have done a bit of work and it looks good to me.
But I am short of knowledge in case of server side language, (just learning python and django in fact).
So is it advised to build by blog without the database things and all? or should i delay it by 3-4 months until i learn server side programming?
Can I do thing like searching posts, sorting them , comment on post with out the use of databases?
Is it easy to transform my blog to a database based one in later stage easily without taking it off the web?
ps: i dont want to use blogging platforms like wordpress.
you can make a website using static web pages. But that wont be really good enough for your users or readers. Besides that you really have to put a lot of time in manually writing the code for each page.
But if you choose to build a dynamic blog that will be better for the readers. You deploy functions like search , comment more easily.
Using a free and open source blogging platform like wordpress will cut down your task. It has ready made themes, plug ins available to get your tasks done and customize your site the way you want.Again it will be far more secure and attractive.
So my suggestion will be to go with wordpress.
And as far as the learning par is concerned you will learn more stuff while working with wordpress than building a static site

What's the best way to integrate a Django and Rails app sharing the same MySQL datastore?

I'm going to be collaborating with a Python developer on a web
application. I'm going to be building a part of it in Ruby and he is
going to build another part of it using Django. I don't know much about
Django.
My plan for integrating the two parts is to simply map a certain URL
path prefix (say, any request that begins with /services) to the Python
code, while leaving Rails to process other requests.
The Python and Ruby parts of the app will share and make updates to the
same MySQL datastore.
My questions:
What do people think generally of this sort of integration strategy?
Is there a better alternative (short of writing it all in one language)?
What's the best way to share sensitive session data (i.e. a logged in
user's id) across the two parts of the app?
As I see it you can't use Django's auth, you can't use Django's ORM, you can't use Django's admin, you can't use Django's sessions - all you are left with is URL mapping to views and the template system. I'd not use Django, but a simpler Python framework. Time your Python programmer expanded his world...
One possible way that should be pretty clean is to decide which one of the apps is the "main" one and have the other one communicate with it over a well-defined API, rather than directly interacting with the underlying database.
If you're doing it right, you're already building your Rails application with a RESTful API. The Django app could act as a REST client to it.
I'm sure it could work the other way around too (with the rest-client gem, for instance).
That way, things like validations and other core business logic are enforced in one place, rather than two.
A project, product, whatever you call it, needs a leader.
This is the first proof that you don't have one. Someone should decide either you're doing ruby or python. I prefer ruby myself, but I understand those who prefer python.
I think starting a product asking yourself those kind of questions is a BAD start.
If your colleague only knows prototype, and you only know JQuery, are you going to mix the technologies too? Same for DB? And for testing frameworks?
This is a never ending arguing subject. One should decide, IMHO, if you want so;ething good to happen. I work with a lot of teams, as a consultant, Agile teams, very mature teams for some of them, and that's the kind of stuff they avoid at all cost.
Except if one of you is going to work on some specific part of the project, which REALLY needs one or other of the technologies, but still think the other one is best for the rest of the application.
I think, for example, at a batch computing. You have ALL your web app in ror or django, and you have a script, called by CRON or whatever, computing huge amounts of data outside the web app, filling a DB or whatever.
My2Cts.

What is curl and what are its uses for rails developers?

Ive seen mentions of curl here and there on rails blogs and ive scanned some posts here on stackoverflow but im still a bit in the dark as to its use especially when it comes to rails development.
Is it useful for testing? Im currently learning the ins and outs of testing and one of the things i need to do is test a before filter that only allows an action to be called if the user came from a certain external site. Is this an occasion where curl would be used?
curl is a command line program which can retrieve urls, it's quite flexible, for example it can use limited regexes to download a range of files.
You might want to use it for testing, by seeing what happens to your application under certain circumstances, if you want to test what happens if your user comes from a certain site then use the -e option on curl.
The man page is online Here
No, I don't think you'd use cURL for TDD. Using cURL would imply communicating with a remote service, which would be an integration test.
Are you talking about this? http://www.viget.com/extend/curl-and-your-rails-2-app/
In that post, cURL isn't being used in the rails app at all. It's being used on the terminal to test/demo the app's REST service, not in a TDD fashion.
cURL is good for this purpose because its many options allow you to simulate different headers from user agents, such as language acceptance, characterset acceptance, cache usage, etc...
Have a look at hurl—which is written in Rails—and then imagine a more powerful command-line version. That's pretty much cURL.
Ruby (Rail?) hackers might also be interested in one of the many Ruby bindings for libcurl, the library that powers the curl tool. Like them mentioned here: http://curl.haxx.se/libcurl/ruby/

'WebControls' for Ruby on Rails

I've recently started working with RoR for some projects and I quite like the framework - however coming from an ASP.NET background I'm quite fond of the idea of being able to purchase & drop in reusable components/control such as those from telerik, without having to 'reinvent'.
I suppose it would be possible to maybe create my own using partials or plugins or similar, but I'm wondering if there is anything out there already, or perhaps alternatives which could be massaged into place, like javascript widgets etc?
I don't know of any commercial components or "controls", but there's thousands (probably, I haven't counted them) of plugins out there freely available, to do a great many things for you, some of which would probably count as "controls". Unfortunately, there's no one place to go and find them, and the quality is depressingly variable, but there are a number of plugin indexes like http://agilewebdevelopment.com/plugins/ that might help in finding what you want while weeding out the dross.
Ext JS is a great GUI toolkit. I can't say that it entirely fits in with the RoR way of doing things, but if you write your controllers to return JSON it isn't too bad.
One of the big differences between Ruby/Rails and the .Net world is the fact that most of the available plugins are open-source and integrate at the code level. There is an incredible array of plugins for Rails, and it is very straight forward to write your own. Due to the nature of Ruby you can hook into any just about any part of the language and framework, giving you impressive extensibility.
I am not sure how Web Controls work, but it sounds like they are a "black-box" that provides an end-to-end solution for both UI and data-level operations ... ?
Many of the Rails plugins do provide both UI and data aspects. An example would be "restful_authentication" which provides you with both some basic forms for login and user registration as well as an authentication module and a Active-Record model. Again, this operates at a code-level, so will actually push the relevant code into your codebase when you install and "generate" the authentication modules.
As for "widgets", there is no equivalent in Rails, per-se, but there are a number of JavaScript libraries that provide similar functionality. I use and recommend jQuery UI, myself.
Dojo has a widget library which might meet your needs.

Resources