lib/ubiquo/template.erb in ubiquo-0.6.3 vs lib/ubiquo/template.erb in ubiquo-0.9.0.b1
- old
+ new
@@ -25,58 +25,42 @@
when "custom"
selected_plugins = (minimal_plugins + <%= @opts[:plugins].inspect %>).uniq
else selected_plugins = minimal_plugins + rest_plugins
end
-# File railties/lib/rails_generator/generators/applications/app/template_runner.rb, line 69
-def plugin(name, options)
- log 'plugin', name
-
- if options[:git] && options[:submodule]
- in_root do
- branch = "-b #{options[:branch]}" if options[:branch]
- Git.run("submodule add #{branch} #{options[:git]} vendor/plugins/#{name}")
- end
- elsif options[:git] || options[:svn]
- in_root do
- run_ruby_script("script/plugin install #{options[:svn] || options[:git]}", false)
- end
- else
- log "! no git or svn provided for #{name}. skipping..."
- end
-end
-
def add_plugins(plugin_names, options={})
git_root = options[:devel] ? 'git@github.com:gnuine' : 'git://github.com/gnuine'
plugin_names.each { |name| plugin name, :git => "#{git_root}/#{name}.git", :branch => options[:branch], :submodule => true }
end
# To ask needed settings when boostraping the app
appname = "<%= @opts[:app_name] %>"
exception_recipient = "<%= @opts[:exception_recipient] %>"
sender_address = "<%= @opts[:sender_address] %>"
-# Remove rails temporary directories
-["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f|
- run("rmdir ./#{f}")
-end
-# Hold empty dirs by adding .gitignore to each (to avoid git missing needed empty dirs)
-run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;")
+# Hold empty dirs by adding .gitkeep to each (to avoid git missing needed empty dirs)
+run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitkeep \\;")
# git:rails:new_app
git :init
# Add default files to ignore (for Rails) to git
file '.gitignore', <<-CODE
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+
+# Ignore bundler config
+.bundle
+
log/\*.log
log/\*.pid
db/\*.db
db/\*.sqlite3
db/schema.rb
-tmp/\*\*/\*
+/tmp
+/nbproject
+.rvmrc
.DS_Store
doc/api
doc/app
-config/database.yml
CODE
initializer 'ubiquo_config.rb', <<-CODE
Ubiquo::Config.add do |config|
config.app_name = "#{appname}"
config.app_title = "#{appname.gsub(/_/, " ").capitalize}"
@@ -88,24 +72,10 @@
config.notifier_email_from = 'railsmail@gnuine.com'
end
end
CODE
-# Rakefile to avoid deprecation warnings for Rdoc
-file 'Rakefile', <<-CODE
-# Add your own tasks in files placed in lib/tasks ending in .rake,
-# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
-
-require 'rake'
-require 'rake/testtask'
-require 'rdoc/task'
-
-require 'tasks/rails'
-CODE
-
# Initializer for ubiquo crontab
initializer 'ubiquo_crontab.rb', <<-CODE
# -*- coding: utf-8 -*-
Ubiquo::Cron::Crontab.schedule do |cron|
# Who to mail on errors
@@ -155,19 +125,10 @@
#Exception notification
ExceptionNotifier.exception_recipients = %w( #{exception_recipient} )
ExceptionNotifier.sender_address = %("Application Error" <#{sender_address}>)
ExceptionNotifier.email_prefix = "[#{appname} \#\{RAILS_ENV\} ERROR]"
CODE
-# Initializer for session
-# Needs 1 param:
-# appname -> Application Name (Ex: test)
-initializer 'session_store.rb', <<-CODE
-ActionController::Base.session = {
- :key => "_ubiquo_#{appname}_session",
- :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}'
-}
-CODE
postgresql = <<-CODE
base_config: &base_config
encoding: unicode
adapter: postgresql
host: localhost
@@ -246,165 +207,100 @@
when "sqlite" then file 'config/database.yml', sqlite3
else file 'config/database.yml', postgresql
end
# gnuine routes.rb
ubiquo_routes = selected_plugins.map do |plugin|
- " map.from_plugin :#{plugin}"
+ " #map.from_plugin :#{plugin}"
end.join("\n")
file 'config/routes.rb', <<-CODE
-ActionController::Routing::Routes.draw do |map|
+Rails32::Application.routes.draw do
+end
+#ActionController::Routing::Routes.draw do |map|
- map.namespace :ubiquo do |ubiquo|
- end
+# map.namespace :ubiquo do |ubiquo|
+# end
- Translate::Routes.translation_ui(map) unless Rails.env.production?
+# Translate::Routes.translation_ui(map) unless Rails.env.production?
# Ubiquo plugins routes. See routes.rb from each plugin path.
#{ubiquo_routes}
############# default routes
#map.connect ':controller/:action/:id'
#map.connect ':controller/:action/:id.:format'
-end
+#end
CODE
# default rails environment.rb
-file 'config/environment.rb', <<-CODE
-# Be sure to restart your server when you modify this file
-
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '<%= @opts[:rails] %>' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-Rails::Initializer.run do |config|
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
-
- # Add additional load paths for your own custom dirs
-
- # Specify gems that this application depends on.
- # They can then be installed with "rake gems:install" on new installations.
- # config.gem "bj"
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
- # config.gem "aws-s3", :lib => "aws/s3"
- # config.gem "rmagick", :lib => 'RMagick'
-
- # Only load the plugins named here, in the order given (default is alphabetical).
- # :all can be used as a placeholder for all plugins not explicitly named
- config.plugins = [ :ubiquo_core, :all ]
-
- # Skip frameworks you're not going to use. To use Rails without a database
- # you must remove the Active Record framework.
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
- # Activate observers that should always be running
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names.
- config.time_zone = 'UTC'
-
-# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
- # config.i18n.default_locale = :de
- config.i18n.load_path.unshift(Dir.glob(File.join("config", "locales", "**","*.{rb,yml}"))).flatten!
- config.i18n.default_locale = :<%= @opts[:locale] %>
-end
-CODE
ubiquo_branch = <%= @opts[:template] == :edge ? 'nil' : "'0.8-stable'" %>
add_plugins(selected_plugins + external_plugins, :branch => ubiquo_branch, :devel => <%= @opts[:devel] ? true : false %>)
-rake("rails:update")
-rake("calendardateselect:install")
-rake("ubiquo:install OVERWRITE=yes")
-
-# Bundler setup
-gsub_file 'config/boot.rb', /Rails\.boot!/ do <<-CODE
-class Rails::Boot
- def run
- load_initializer
-
- Rails::Initializer.class_eval do
- def load_gems
- @bundler_loaded ||= Bundler.require :default, Rails.env
- end
- end
-
- Rails::Initializer.run(:set_load_path)
- end
-end
-
-Rails.boot!
-CODE
-end
-file 'config/preinitializer.rb', <<-CODE
-begin
- require "rubygems"
- require "bundler"
-rescue LoadError
- raise "Could not load the bundler gem. Install it with `gem install bundler`."
-end
-
-if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
- raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
- "Run `gem install bundler` to upgrade."
-end
-
-begin
- # Set up load paths for all bundled gems
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
- Bundler.setup
-rescue Bundler::GemNotFound
- raise RuntimeError, "Bundler couldn't find some gems." +
- "Did you run `bundle install`?"
-end
-CODE
adapter_gem = case choosen_adapter
when "mysql" then "mysql"
when "sqlite" then "sqlite3"
else "pg"
end
jruby_adapter_gem = adapter_gem == "pg" ? "postgres" : adapter_gem
file 'Gemfile', <<-CODE
-source "http://rubygems.org"
+source "https://rubygems.org"
-gem "rails", "= 2.3.14"
-gem "lockfile", ">= 1.4.3"
-gem "i18n", "< 0.5.0"
-gem "rdoc", ">= 2.4.2"
-<% if @opts[:profile] == :complete # used in i18n %>
-gem 'routing-filter', '~> 0.2.4', :require => false
-<% end %>
+gem "rails", "= 3.2.0.rc1"
platforms :mri_18 do
gem "#{adapter_gem}"
end
-platforms :jruby do
- gem "activerecord-jdbc-adapter", "~> 1.1.1"
- gem "jdbc-#{jruby_adapter_gem}"
- gem "jruby-openssl", "~> 0.7.3"
-end
+group :assets do
+ gem 'sass-rails', '~> 3.2.0'
+ gem 'coffee-rails', '~> 3.2.0'
-group :development do
- gem "ruby-debug"
- gem "ya2yaml", ">= 0.2.6"
- gem "highline", ">= 1.5.2"
- gem "ffi-ncurses", "~> 0.3.3", :platforms => :jruby
+ gem 'uglifier', '>= 1.0.3'
end
+gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
+gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
+gem 'ruby-debug19'
+
+gem 'jquery-rails'
+
group :test do
gem "mocha", ">= 0.9.8", :require => false
end
+<% if @opts[:profile] == :complete # used in i18n %>
+#gem 'routing-filter', '~> 0.2.4', :require => false
+<% end %>
+
+platforms :jruby do
+ #gem "activerecord-jdbc-adapter", "~> 1.1.1"
+ #gem "jdbc-#{jruby_adapter_gem}"
+ #gem "jruby-openssl", "~> 0.7.3"
+end
+
+group :development do
+ #gem "ya2yaml", ">= 0.2.6"
+ #gem "highline", ">= 1.5.2"
+ #gem "ffi-ncurses", "~> 0.3.3", :platforms => :jruby
+end
CODE
+
+<% if @opts[:rvm] %>
+run "rvm gemset create #{appname}"
+file '.rvmrc', <<-CODE
+rvm gemset use #{appname}
+CODE
+run "rvm @#{appname} do gem install bundler --no-ri --no-rdoc"
+<% end %>
+
# we need to take care of Jruby
+bundle_command = "<%= @opts[:rvm] ? 'rvm @#{appname} do ' : '' %> bundle install"
<% if RUBY_PLATFORM =~ /java/ %>
-run "jruby -S bundle install"
+run "jruby -S #{bundle_command}"
<% else %>
-run "bundle install"
+run" #{bundle_command}"
<% end %>
# End of bundler setup
+
+rake("rails:update")
+rake("calendardateselect:install")
+rake("ubiquo:install OVERWRITE=yes")
<% if RUBY_PLATFORM =~ /java/ %>
generate(:jdbc)
<% end %>