Plugin

Ruby On Rails – Part Four – Rake

I have always been interested in automating common development tasks. I have used Ant, Maven, and Nant pretty extensively and now I’m learning the details of Rake. There’s something special about seeing messages fly by in a command shell, and know that the computer is doing all these repetitive tasks — not you!

What is different about Rake then any of the others build tools mentioned is that you create a Rakefile by writing Ruby code, instead of using xml. There is a

I would recommend you read this excellent article on defmacro.org (take your time and read through it — it’s really worth it) that does a good job of explaining the benefits of Lisp. A cool thing, since we’re talking about build automation, is one section, titled “Ant Reloaded”, talks about how Java could have been used instead of XML. In our case it’s Ruby being used in a Rakefile.

This tutorial is written by the developer of Rake, and is a good tour through the main features of Rake. I would suggest you read it first, followed by this article by Martin Fowler which reviews some examples of interesting things you can do with a Rakefile.

I created a simple example Rakefile. I’m sure no one would actually need a script like this, but the simple scenario was good for an example of how to use Rake.

I’ve included the code below, the formatting is off because I pasted it in my blog editor, but I hope it will be a good example to someone just getting started with Rake. If you have any suggestions on how to improve this simple Rakefile example, please add a comment to this post.

# ———————————————————-

# This is just an example to illustrate how to use Rake

# By Rob Herbst

# ———————————————————-

# Require rake/clean to get the built in clean task

require ‘rake/clean’

# Require ftools to get File.copy

require ‘ftools’

# Define constants we’ll use later

HTML_SRC_DIR = “html”

WEB_DEST_DIR = “website”

IMAGES_DIR = “images”

SITE_MAP = “sitemap.html”

HTML_SRC_FILES = FileList[“#{HTML_SRC_DIR}/*.html”]

IMAGE_SRC_FILES = FileList[“#{HTML_SRC_DIR}/*.jpg”]

# Add the WEB_DEST_DIR to the list to get cleaned

CLEAN.include(WEB_DEST_DIR)

# The default task depends upon the package task

task :default => [:package]

# The package task depends upon clean, create structure, and the task to create the site map file.

task :package => [:clean, :create_structure, :sitemap] do

     puts “The package task was called.”

             # Copy over the html files

     HTML_SRC_FILES.each do |f|

          File.copy(“#{f}”, “#{WEB_DEST_DIR}”)

     end

             # Copy over the image files

             IMAGE_SRC_FILES.each do |f|

          File.copy(“#{f}”, “#{WEB_DEST_DIR}/images”)

     end

end

# Utility task to create the structure of the website

task :create_structure do

     puts “The create_structure task was called.”

     Dir.mkdir(WEB_DEST_DIR)

     Dir.chdir(WEB_DEST_DIR)

     Dir.mkdir(IMAGES_DIR)

     Dir.chdir(“..”)

end

# Task to create the sitemap.html file

task: :sitemap do

     open(“#{WEB_DEST_DIR}/#{SITE_MAP}”, “w”) do |outs|

          outs.puts “<html><head>Site Map</head><body><ul>”

          HTML_SRC_FILES.each do |f|

               file_name = f.sub(HTML_SRC_DIR + “/”, “”)

               outs.puts “<li><a href=\”#{file_name}\”>#{file_name}</></li>”

          end

          outs.puts “</ul></body>”

     end

end

 ——————————————————-

Why you need SEO services in Calgary

SEO plays a significant role for your brand’s online success. It does not only produce top rankings in the search outcomes. Several people are utilizing search engine optimization to market their brands well. Below are some of the reasons why you require SEO services in Calgary.

 

  1. Delivers High ROI

SEO is the only type of online marketing that delivers a fast return. For you to get the best returns with SEO you should sign up with the best SEO Company. If you use an inexperienced SEO Company you will not succeed in marketing your brands hence your business will be lowered by these inexperienced companies. When search engine optimization is done well it offers nonstop traffic hence promoting your business.

 

  1. SEO Works best for you

If SEO is done appropriately it will deliver continuous as well as consistent traffic to your brand. If you work with an experience SEO Company your website or brand will have endless as well as consistent traffic. Several people fall because they use inexperienced SEO providers which are cheap. For you to succeed you should invest in the best SEO service provider who does it excellent.

  1. SEO Will never Disappear

SEO will never disappear. It continues to develop with time as well as those who understand SEO are constantly adapting with the new changes. The concept of search engine optimization will never end, however the methods to maintain the rankings constantly changes. SEO will always be available provided that the internet is. Therefore it is a perfect idea for you to be involved now.

 

  1. The struggle does it

Several people assume that SEO requires to be done until high rankings are attained; however this isn’t the case at all. When a website or a brand attains the high rank it will need extra work so as to maintain as well as continue to enhance the top rankings. Your struggle will be attaining those top rankings. SEO ensures that your website attains those top rankings and has got the required traffic all the time.

 

  1. Everybody looks For Businesses Online

When a SEO strategy is in place you will be able to enhance the odds of your target customers’ base. Think on how significant the internet is for your potential customers. Customers can make purchases, review the business or products as well as search for a business. A customer can do this from a desktop, mobile or tablet device. If you want your brand to be found online then you require SEO. You require a SEO strategy so as to draw more organic traffic to your brand or website. It offers an incredible ROI if done perfectly.

 

The above are the top five reasons why you require SEO Services in Calgary. SEO helps to draw more organic traffic to your website and gives it top ranking.

Rails Plugin For VIM

I found a plugin for VIM that was designed just for Rails coding by Tim Pope. I thought the first line of the documentation was great

“TextMate may be the latest craze for developing Ruby on Rails applications,
but Vim is forever.”

It provides:

  • quick navigation commands from model to view and controller
  • rake integration
  • extends ‘gf’ command to understand Rails
  • CTRL+X, CTRL+U autocompletion
  • interface to the script commands
  • convenient log file viewing