diff --git a/lib/tasks/create_categories.rake b/lib/tasks/create_categories.rake index d86aa72..e08b721 100644 --- a/lib/tasks/create_categories.rake +++ b/lib/tasks/create_categories.rake @@ -2,12 +2,15 @@ namespace :software do desc "Create software categories" task :create_categories => :environment do Environment.all.each do |env| - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunities") + print 'Creating categories: ' software = Category.create(:name => _("Software"), :environment => env) Category::SOFTWARE_CATEGORIES.each do |category_name| + print '.' Category.create(:name => category_name, :environment => env, :parent => software) end + puts '' end end end -end \ No newline at end of file +end diff --git a/lib/tasks/create_licenses.rake b/lib/tasks/create_licenses.rake new file mode 100644 index 0000000..a1908d3 --- /dev/null +++ b/lib/tasks/create_licenses.rake @@ -0,0 +1,42 @@ +namespace :software do + desc "Create software licences" + + task :create_licenses => :environment do + Environment.all.each do |env| + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunities") + list_file = File.open "plugins/software_communities/public/static/licences.txt", "r" + + version_or_link = 'version' + can_save = true + licence = nil + + print 'Creating Licenses: ' + list_file.each_line do |line| + data = line.strip + + if data.length != 0 + if version_or_link == 'version' + can_save = LicenseInfo.find_by_version(data) ? false : true + licence = LicenseInfo::new :version => data + version_or_link = 'link' + elsif version_or_link == 'link' + licence.link = data + + if can_save + licence.save! + print '.' + else + print 'F' + end + + version_or_link = 'version' + end + end + end + puts '' + + list_file.close + end + end + end +end diff --git a/lib/tasks/create_lincences.rake b/lib/tasks/create_lincences.rake deleted file mode 100644 index 41373ce..0000000 --- a/lib/tasks/create_lincences.rake +++ /dev/null @@ -1,42 +0,0 @@ -namespace :software do - desc "Create software licences" - - task :create_licenses => :environment do - Environment.all.each do |env| - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") - list_file = File.open "plugins/software_communities/public/static/licences.txt", "r" - - version_or_link = 'version' - can_save = true - licence = nil - - print 'Creating Licenses: ' - list_file.each_line do |line| - data = line.strip - - if data.length != 0 - if version_or_link == 'version' - can_save = LicenseInfo.find_by_version(data) ? false : true - licence = LicenseInfo::new :version => data - version_or_link = 'link' - elsif version_or_link == 'link' - licence.link = data - - if can_save - licence.save! - print '.' - else - print 'F' - end - - version_or_link = 'version' - end - end - end - puts '' - - list_file.close - end - end - end -end \ No newline at end of file -- libgit2 0.21.2