Initial commit of foodsoft 2
This commit is contained in:
commit
5b9a7e05df
657 changed files with 70444 additions and 0 deletions
26
lib/tasks/foodsoft.rake
Normal file
26
lib/tasks/foodsoft.rake
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# put in here all foodsoft tasks
|
||||
# => :environment loads the environment an gives easy access to the application
|
||||
|
||||
namespace :foodsoft do
|
||||
|
||||
# "rake foodsoft:create_admin"
|
||||
desc "creates Administrators-group and admin-user"
|
||||
task :create_admin => :environment do
|
||||
puts "Create Group 'Administators'"
|
||||
administrators = Group.create(:name => "Administrators",
|
||||
:description => "System administrators.",
|
||||
:role_admin => true,
|
||||
:role_finance => true,
|
||||
:role_article_meta => true,
|
||||
:role_suppliers => true,
|
||||
:role_orders => true)
|
||||
|
||||
puts "Create User 'admin' with password 'secret'"
|
||||
admin = User.new(:nick => "admin", :first_name => "Anton", :last_name => "Administrator", :email => "admin@foo.test")
|
||||
admin.password = "secret"
|
||||
admin.save
|
||||
|
||||
puts "Joining 'admin' user to 'Administrators' group"
|
||||
Membership.create(:group => administrators, :user => admin)
|
||||
end
|
||||
end
|
||||
50
lib/tasks/gettext.rake
Normal file
50
lib/tasks/gettext.rake
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# these are the tasks to updates localization-data
|
||||
require 'gettext/utils'
|
||||
|
||||
# Reopen to make RubyGettext's ERB parser parse .html.erb files
|
||||
module GetText
|
||||
module ErbParser
|
||||
@config = {
|
||||
:extnames => ['.rhtml', '.erb']
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
require "#{RAILS_ROOT}/vendor/plugins/haml/lib/haml"
|
||||
rescue LoadError
|
||||
require 'haml' # From gem
|
||||
end
|
||||
|
||||
module HamlParser
|
||||
module_function
|
||||
|
||||
def target?(file)
|
||||
File.extname(file) == '.haml'
|
||||
end
|
||||
|
||||
def parse(file, ary = [])
|
||||
haml = Haml::Engine.new(IO.readlines(file).join)
|
||||
code = haml.precompiled.split(/$/)
|
||||
RubyParser.parse_lines(file, code, ary)
|
||||
end
|
||||
end
|
||||
GetText::RGetText.add_parser(HamlParser)
|
||||
|
||||
namespace :gettext do
|
||||
desc 'Create mo-files for L10n'
|
||||
task :makemo do
|
||||
GetText.create_mofiles(true, 'po', 'locale')
|
||||
end
|
||||
|
||||
desc 'Update pot/po files to match new version'
|
||||
task :updatepo do
|
||||
TEXT_DOMAIN = 'foodsoft'
|
||||
APP_VERSION = '2.0'
|
||||
files = Dir.glob('{app,vendor/plugins/mod_**}/**/*.rb')
|
||||
files.concat(Dir.glob('{app,vendor/plugins/mod_**}/**/*.rhtml'))
|
||||
files.concat(Dir.glob('{app,vendor/plugins/mod_**}/**/*.erb'))
|
||||
files.concat(Dir.glob('{app,vendor/plugins/mod_**}/**/*.haml'))
|
||||
GetText.update_pofiles(TEXT_DOMAIN, files, APP_VERSION)
|
||||
end
|
||||
end
|
||||
31
lib/tasks/rails.rake
Normal file
31
lib/tasks/rails.rake
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
desc "Checks your app and gently warns you if you are using deprecated code."
|
||||
task :deprecated => :environment do
|
||||
deprecated = {
|
||||
'@params' => 'Use params[] instead',
|
||||
'@session' => 'Use session[] instead',
|
||||
'@flash' => 'Use flash[] instead',
|
||||
'@request' => 'Use request[] instead',
|
||||
'@env' => 'Use env[] instead',
|
||||
'find_all\([^_]\|$\)' => 'Use find(:all) instead',
|
||||
'find_first' => 'Use find(:first) instead',
|
||||
'render_partial' => 'Use render :partial instead',
|
||||
'component' => 'Use of components are frowned upon',
|
||||
'paginate' => 'The default paginator is slow. Writing your own may be faster',
|
||||
'start_form_tag' => 'Use form_for instead',
|
||||
'end_form_tag' => 'Use form_for instead',
|
||||
':post => true' => 'Use :method => :post instead'
|
||||
}
|
||||
|
||||
deprecated.each do |key, warning|
|
||||
puts '--> ' + key
|
||||
output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* --exclude=.#* -r '#{key}' *`
|
||||
unless output =~ /^$/
|
||||
puts " !! " + warning + " !!"
|
||||
puts ' ' + '.' * (warning.length + 6)
|
||||
puts output
|
||||
else
|
||||
puts " Clean! Cheers for you!"
|
||||
end
|
||||
puts
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue