Learn More
What is Lucie?
Lucie is a console application framework like Rails for Ruby programmers or Symfony for PHP developers. While these tools help the web developers in create beautiful websites rapidly, there's no easy way to create complex console applications like do this in Ruby on Rails. Lucie wants to bridge this gap.
Why is it good for me?
Why do you want to write your terminal scripts from scratch every time? If !#/bin/bash is in your hand and you like writing this down hundreds of times, then it's not your framework. If you like bash syntax or parse the options from command line, this is not your tool. If you want to put your mind to your tasks contrary to your tool then it's made for you!
What is this MVC?
MVC is an abbrevation for Model View Controller design pattern. Controllers manage workflows, models store data persistently, views are templates. Console app with MVC? Who said a console app can't have models or views?
How does it work?
The best way is to show you an example! Imagine you're hosting web pages. You have a script to create and launch a new page every time when a new customer comes. This command gets the domain of the site, name and email of the customer, and finally generates a web server configuration file somewhere in your /etc. Domain, name, emails are persistent data, since you may want to use them later. You will need a new configuration file, this is one representation of your data. What's your way now?
I show you what's my way with Lucie! I have an application in the company to administer services on my servers. I call this tool to magic_tool. First I extend my magic_tool application with a controller that will manage the webserver.
$ cd ~/magic_tool $ lucie generate controller webserver
Controller does the business logic and live in app/controllers folder of my magic_tool. I can reach this controller with the magic_tool webserver command. Now add the business logic:
$ vim app/controllers/webserver_controller.rb
class WebserverController < Controller::Base
mandatory "-d", "--domain", "Requested domain name."
def create
# requirements for this action
mandatory "-n", "--name", "Name of the owner."
mandatory "-e", "--email", "Email of the owner."
optional "-c", "--comment", "Additional comment"
# Create a website persistent object
@website = Website.new
@website.domain = params[:domain]
@website.owner_name = params[:name]
@website.owner_email = params[:email]
@website.comment = params[:comment]
@website.root = "/home/domains/#{@website.domain}"
if @website.save
mkdir @website.root
chown "www-data", "www-data", @website.root
template "webserver/nginx_config", target: "/etc/nginx/sites/# {@website.domain}.conf"
reload
end
exit 0
end
def reload
Service.find("nginx").reload
end
end
Domain is mandatory parameter for all actions in webserver module, but name and email are only for create action. My model here in the example is the Website class that can be stored in Xml, Nosql database, relational database or simple csv file. Now I will use MongoDB. Models live in the app/models directory.
$ vim app/models/website.rb
class Website
include MongoMapper::Document
key :domain, String
key :owner_name, String
key :owner_email, String
key :comment, String
timestamps!
end
webserver/nginx_config is the representation of website model element, it is a template for an nginx configuration file.
$ vim app/views/webserver/nginx_config.erb
server {
listen 80;
server_name <%= @website.domain %>;
access_log logs/nginx/<%= @webserver.domain %>.log;
root <%= @website.root %>;
}
Now we are ready, check this out! Here is the command for our create action:
$ magic_tool webserver create -d luc.ie -n nucc -e info@luc.ie
where webserver is the name of the controller and create is the action.
I guess it's a better way to generate or regenerate configurations than an AUTOMAKE solutions.
What about the social stuff?
Do you mean how you can extend your app with community written tools? Lucie is a framework and we want to keep it as simple as we can. We would like to extract many features to plugins and encourage the community to share their plugins back. Somebody writes an SSH connection manager and extracts it to a plugin, then other people can use it when they want to connect to a server through ssh. Why do you want to implement this again? Now people do this!
Where does the code live?
The code lives on Github. If you want to join just write a mail toinfo at luc.ie email address!
How can I install it?
Currently Lucie has no released version. If you're interested, keep calm and subscribe to our newsletter or follow us on Twitter and we will send you information about the first releases.
Now you come! Share your ideas!
We are very curious about your ideas, what feature you would like to see in Lucie! Don't be shy! ;) Cheers!