Commit d603d8ba88ea1ad691f8cb1158e8fc311e750153
Committed by
David Silva
1 parent
bba87aa9
Exists in
master
and in
5 other branches
Create rake tast to populate the database with licences
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
1 changed file
with
36 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +namespace :software do | |
| 2 | + desc "Create software licences" | |
| 3 | + | |
| 4 | + task :create_licences => :environment do | |
| 5 | + Environment.all.each do |env| | |
| 6 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | |
| 7 | + list_file = File.open "plugins/mpog_software/public/static/licences.txt", "r" | |
| 8 | + | |
| 9 | + name_or_link = 'version' | |
| 10 | + licence = nil | |
| 11 | + | |
| 12 | + print 'Creating Licenses: ' | |
| 13 | + list_file.each_line do |line| | |
| 14 | + data = line.strip | |
| 15 | + | |
| 16 | + if data.length != 0 | |
| 17 | + if version_or_link == 'version' | |
| 18 | + licence = LicenseInfo::new :version => data | |
| 19 | + | |
| 20 | + version_or_link = 'link' | |
| 21 | + elsif version_or_link == 'link' | |
| 22 | + licence.link = data | |
| 23 | + licence.save! | |
| 24 | + print '.' | |
| 25 | + | |
| 26 | + version_or_link = 'version' | |
| 27 | + end | |
| 28 | + end | |
| 29 | + end | |
| 30 | + puts '' | |
| 31 | + | |
| 32 | + list_file.close | |
| 33 | + end | |
| 34 | + end | |
| 35 | + end | |
| 36 | +end | |
| 0 | 37 | \ No newline at end of file | ... | ... |