Permalink
Browse files

Merged pull request #5 from xlymian/namespacing_constants.

Add constants to RailRoad namespace to eliminate clashing
  • Loading branch information...
2 parents 6c47d49 + dfb3e75 commit 61ef96bc17711ddda1d0b4de62f5cdbe736cff58 Peter Hoeg committed Apr 29, 2011
Showing with 14 additions and 12 deletions.
  1. +9 −7 bin/railroad
  2. +1 −1 lib/app_diagram.rb
  3. +1 −1 lib/diagram_graph.rb
  4. +3 −3 lib/options_struct.rb
View
@@ -16,13 +16,15 @@
require File.dirname(__FILE__) + '/../lib/version'
-APP_NAME = "railroad"
-APP_HUMAN_NAME = "RailRoad"
-APP_VERSION = [RailRoad::VERSION::MAJOR, RailRoad::VERSION::MINOR, RailRoad::VERSION::PATCH]
-COPYRIGHT = "Copyright (C) 2007-2008 Javier Smaldone, 2009 Peter Hoeg"
+module RailRoad
+ APP_NAME = "railroad"
+ APP_HUMAN_NAME = "RailRoad"
+ APP_VERSION = [RailRoad::VERSION::MAJOR, RailRoad::VERSION::MINOR, RailRoad::VERSION::PATCH]
+ COPYRIGHT = "Copyright (C) 2007-2008 Javier Smaldone, 2009 Peter Hoeg"
+end
if ARGV.first == '--version'
- puts "#{APP_HUMAN_NAME} v#{RailRoad::VERSION::STRING}"
+ puts "#{RailRoad::APP_HUMAN_NAME} v#{RailRoad::VERSION::STRING}"
exit(0)
end
@@ -46,9 +48,9 @@ elsif options.command == 'controllers'
elsif options.command == 'aasm'
diagram = AasmDiagram.new options
else
- STDERR.print "#{APP_HUMAN_NAME} v#{RailRoad::VERSION::STRING}\n" +
+ STDERR.print "#{RailRoad::APP_HUMAN_NAME} v#{RailRoad::VERSION::STRING}\n" +
"Error: You must supply a command\n" +
- " (try #{APP_NAME} -h)\n\n"
+ " (try #{RailRoad::APP_NAME} -h)\n\n"
exit 1
end
View
@@ -63,7 +63,7 @@ def enable_stdout
# Print error when loading Rails application
def print_error(type)
STDERR.print "Error loading #{type}.\n (Are you running " +
- "#{APP_NAME} on the aplication's root directory?)\n\n"
+ "#{RailRoad::APP_NAME} on the aplication's root directory?)\n\n"
end
# Load Rails application's environment
View
@@ -68,7 +68,7 @@ def dot_label
"Date: #{Time.now.strftime "%b %d %Y - %H:%M"}\\l" +
"Migration version: " +
"#{ActiveRecord::Migrator.current_version}\\l" +
- "Generated by #{APP_HUMAN_NAME} #{APP_VERSION.join('.')}"+
+ "Generated by #{RailRoad::APP_HUMAN_NAME} #{RailRoad::APP_VERSION.join('.')}"+
"\\l\", fontsize=14]\n"
end
View
@@ -36,7 +36,7 @@ def initialize
def parse(args)
@opt_parser = OptionParser.new do |opts|
- opts.banner = "Usage: #{APP_NAME} [options] command"
+ opts.banner = "Usage: #{RailRoad::APP_NAME} [options] command"
opts.separator ""
opts.separator "Common options:"
opts.on("-b", "--brief", "Generate compact diagram",
@@ -113,8 +113,8 @@ def parse(args)
exit
end
opts.on("--version", "Show version and copyright") do
- STDOUT.print "#{APP_HUMAN_NAME} version #{APP_VERSION.join('.')}\n\n" +
- "#{COPYRIGHT}\nThis is free software; see the source " +
+ STDOUT.print "#{RailRoad::APP_HUMAN_NAME} version #{RailRoad::APP_VERSION.join('.')}\n\n" +
+ "#{RailRoad::COPYRIGHT}\nThis is free software; see the source " +
"for copying conditions.\n\n"
exit
end

0 comments on commit 61ef96b

Please sign in to comment.