I'm about to begin a reasonable pure ruby project becoming from a Java and C background, and with some experience with Rails.
I'm looking for some advices with what's the best packaging/arrangement practice for a distributed ruby application that basically consists in Client app and the Server app.
The client only talks with the server to receive/send objects (json, and others) and to upload and download files, all from network. The server will deal with the local or remote storing of all files and store simple information (db).
I already read a lot about these and I found and know the best practices for a simple gem, like:
- appname/
- bin/
- lib/
- appname.rb
- appname/
- (appname::classes)
- test/
- readme, etc
But what about a reasonable big client-server app like these (2 app's in the same project)?
It's best/common to suit that in two gems? Or make them in same gem in different modules?
Do you know some ruby open source project/gem with a structure like these (client and server app) that I can go and see it's choices?
Sorry for the question size, i'm looking for this so I can define a good structure right now and avoid problems when the code begins to grow.
The best example that comes to my mind at this moment is picky. It's a very well-done project. It's worth taking a look at it for inspiration.
Related
I have a ruby project written purely in ruby. Now I want to include a java archive (jar) file which has some functionality my users want. It is good to just place the file in one of the directories and bundle as a gem? Are there any security issues related to this? Any advice would be greatly appreciated.
The answer is that it depends on the use case.
If this is a gem that users will be using purely for their own purposes, and it's not broadcasting over a network, then security issues are fairly minimal - they would relate more to system security.
If part of your program involves binding to a port and accepting TCP/UDP connections then you've got to really start thinking about network security. Another possible problem is if you're giving file system access to non-privileged users (e.g. if this is a rails gem, and the JAR gives functionality to manipulate the file system and for some reason you're passing this on to the site users - bit of a stupid example but I hope you see what I'm getting at).
However, as for running a java JAR file, there's nothing innately insecure about that unless there are known security flaws with that particular JAR.
In the end, it's up to the end-user of the gem. Make it clear what the gem does and they can make the decision about whether they want to use it.
I am trying to see if I can create a simple website, like a blog, using only Ruby. No Rails or a database or outside web servers. I plan to store the data in a file for persistence.
I wanted to use TCPServer, CGI, and Net::HTTP.
Is there an easier way I can use?
There are a lot of moving parts when designing a website.
Depending on the purpose of the exercise, you might want to consider using a very simple web framework like Camping, Sinatra, or Ramaze. This is probably the best solution if you're trying to get a top level understanding of web programming because it only has exactly what you need (Camping is less than 4k!) and handles stuff like routing.
Building a web server is more an exercise in HTTP parsing. You might want to omit the framework and try to build something on top of Rake (an API for lots of popular web servers) and a simple web server like Webrick or Thin.
You could also try Espresso
It is easy to learn and fast to run.
And offers all the liberty you need for creation process.
Also it has no hidden "fees", everything is transparent.
I'm planning to develop a standalone restful Image Server with the following functionality, but first would like to know if something similar already exists in the open source world (language not important):
restful (crud) on master image, e.g: /GET/asd983249as
possibly bulk-gets / LIST
support for metadata (Creative commons info, dimensions, etc.) that directly relates to the image (references from the domain to these images is NOT included)
restful lazy-get of different 'renditions' of an image. i.e if a rendition doesn't exist, it is created upon request. Obviously the original image needs to exist. Different operations are allowed (resize and crop to begin with)
e.g: /GET/asd983249as/100x100 (simple resize)
allowed dimensions are configurable, so not to get DoS'ed (not as quickly anyway)
Non functional:
Reasonable performant / Scalable / HA (yeah I know this doesn't say anything really)
Possibly in-mem caching
Thinking about going the Mongo GridFS route, getting MongoDb sharding and replication almost for free. Putting Nginx in front, perhaps (in part) directly using nginx-gridfs (see below) should allow for the rest-stuff and, with some config, some simple caching if gridfs can't handle that for itself (don't know)
Sources:
nginx-gridfs
http://www.coffeepowered.net/2010/02/17/serving-files-out-of-gridfs/
Idea of lazy-gets (and a simple implementation of what I'm looking for, although it seemed more hobbyish than an actively maintained project)
http://sumitbirla.com/2011/11/how-to-build-a-scalable-caching-resizing-image-server/
other stuff that comes close, but isn't an end solution
https://github.com/adamdbradley/foresight.js/wiki/Server-Resizing-Images
Anything that already does this?
I would recommend you this project:
https://github.com/imbo/imbo
Its easy to use, stable and used in big projects.
But I am still curious about alternatives.
I was looking for options for a project, and I found those two below. They are not a perfect match to your requirements but seem quite mature. I have no experience with them yet, though.
https://imageresizing.net/ Essential edition is open source. The more advanced solutions are not.
http://thumborize.me/ (with associated github) has many interesting features like face detection, new codecs, smart cropping.
I am working on a task that needs to checkout source from a github repositroy, and then modify some files from the checked out repository based on some existing configuration data that's coming from a separate call to a different web service as JSON. The changes to the checked out code are temporary and will not be pushed back to github.
Once the checked out source is processed and modified based upon the configuration data, I will create a compressed archive of the resulting source.
I just discovered Capistrano and it seems great for this entire process, although it has nothing to do with deployment. On the other hand, I could simply use plain Ruby to do the same stuff. Currently, I am weighing more on the side of using Capistrano with custom tasks.
So you can say that it's an app based on Capistrano itself, with local deployment. Does it sound like a sane approach? Should I write it in plain Ruby instead? Or maybe write parts of the application in pure Ruby, and connect the pieces with Capistrano. Any suggestion is welcome.
Sincerely recommend Thor (see Github) it's pure-ruby syntax tax framework like Rake (but like Capistrano has a lot of cruft for server cluster grouping and connection handling… Rake has a lot to do with more classical "Make" or build tasks)
Recommendation from me is a set of Thor tasks, using raw-net-ssh (cap is based on Net::SSH) where appropriate.
For the checking out I recommend you watch the "Amp" project… they're coming up with a consistent cross-scm way to do checkouts (but thats the least of your problems) - You can take a look here, but it's early days for them yet - http://github.com/michaeledgar/amp
Sources: (as the Capistrano maintainer, i'm planning on throwing out our own DSL to replace it with Thor since it makes a lot more sense )
As for me, I write things like these in a Rakefile, and then use a rake command to call them.
You can find that Rakefiles are similar to Capfiles, so rake is usually used to perform some local tasks, and cap for remote.
I can't find this on Google (so maybe it doesn't exist), but I basically'd like to install something on a web server such that I can run a site on Scheme, PHP is starting to annoy me, I want to get rid off it, what I want is:
Run Scheme sources towards UTF-8 output (duh)
Support for SXML, SXLT et cetera, I plan to compose the damned thing in SXML and -> to normal representation on at the end.
Ability to read other files from the server, write them, set permissions et cetera
Also some things to for instance determine the filesize of files, height of images, mime-types and all that mumbo-jumbo
(optionally) connect to a database, but for what I want to do storing the entire database in S-expressions itself is feasible enough
I don't need any fancy libraries and other things that come with it like CMS'es and what-not, except the support for SXML but I'm sure I can just find a lib for that anyway that I can load.
Spark-Scheme has a full web server. If you don't need that, it also has a FastCGI interface so that you can serve Scheme scripts from a web servers like Apache, Lighttpd etc. Spark-Scheme also seem to meet your requirements for database support, UTF-8, file handling and SXML. See the Spark-Scheme Programming Guide (pdf) for more information.
mod_lisp and FastCGI are the only two Apache modules I'm aware of that might work at this time. mod_lisp provides Scheme support because it's architecture is similar to FastCGI, where CGI like parameters are sent over a socket to a second process which remains running as the Scheme backend to the web server. Basically you use one or the other to send CGI like parameters across a socket to a running Scheme backend.
You can find some information about these solutions here. There was another FastCGI like effort called SCGI which demoed a simple SCGI receiver in Scheme called gambit. That code is probably not maintained anymore, but the scheme receiver might be useful.
Back in the Apache 2.0 days, there were more projects playing with scheme and clisp bindings. I don't believe that mod_scheme ever released anything, but if they did, odds are it is not compatible with the modern releases of Apache.
Did you come across Fermion (http://vijaymathew.wordpress.com/2009/08/19/fermion-the-scheme-web-server/)?
If you're looking for a lispy language to develop web applications in, I'd recommend looking into Clojure. Clojure is a lisp variant that's fairly close to scheme; here is a list of some of the differences.
Clojure runs on the Java virtual machine and integrates well with Java libraries, and there's a great webapp framework available called Compojure.
Check out Chicken Scheme's Eggs Unlimited. I think what you want is a combination of the sxml- packages coupled with the fastcgi package.
PLT Scheme has a web application server here: http://docs.plt-scheme.org/web-server/index.html