Permalink
Browse files

Merge pull request #11 from romanvbabenko/master

readme file & new configuration generator improved
  • Loading branch information...
2 parents decddca + de68b64 commit a333f4e6b9104336279cf8cf6520a6b40865f76b @radar radar committed Jan 19, 2012
Showing with 16 additions and 10 deletions.
  1. 0 README → README.rdoc
  2. +16 −10 lib/new_configuration_generator.rb
View
File renamed without changes.
@@ -10,44 +10,50 @@ def generate_new_configurations
raise FileNotFoundError, "Can't find environment.rb [config/environment.rb]!"
end
end
-
+
def has_environment?
File.exists?("config/environment.rb")
end
-
+
def environment_code
File.open("config/environment.rb").read
end
-
+
def generate_new_application_rb
environment_file = environment_code
-
+
initializer_code = ""
if matches = environment_file.match(/Rails\:\:Initializer\.run do \|config\|\n(.*)\nend/m)
initializer_code = matches[1]
else
raise "There doesn't seem to be a real environment.rb in your app. Are you sure config/environment.rb has the right contents?"
end
-
+
frame = "# Put this in config/application.rb
require File.expand_path('../boot', __FILE__)
+require 'rails/all'
+
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
module #{app_name.classify}
class Application < Rails::Application
+ config.autoload_paths += [config.root.join('lib')]
+ config.encoding = 'utf-8'
%s
end
end"
-
- frame % [indent(initializer_code)]
+
+ frame % [indent(initializer_code)]
end
-
+
def indent(text)
text.split("\n").map {|l| " #{l}"}.join("\n")
end
-
+
def app_name
File.basename(Dir.pwd)
end
end
end
-end
+end

0 comments on commit a333f4e

Please sign in to comment.