lib/bebox/wizards/role_wizard.rb in bebox-0.1.3 vs lib/bebox/wizards/role_wizard.rb in bebox-0.1.4

- old
+ new

@@ -5,71 +5,65 @@ include Bebox::WizardsHelper # Create a new role def create_new_role(project_root, role_name) # Check if the role name is valid - return error "The role name can only contain:\n - \n* Lowercase letters - \n* Numbers - \n* Underscores - \n* Must begin with an Lowercase letter - \n* Can not be any of: #{Bebox::RESERVED_WORDS.join(', ')} - \n\nNo changes were made." unless valid_puppet_class_name?(role_name) + return error _('wizard.role.invalid_name')%{words: Bebox::RESERVED_WORDS.join(', ')} unless valid_puppet_class_name?(role_name) # Check if the role exist - return error("The '#{role_name}' role already exist. No changes were made.") if role_exists?(project_root, role_name) + return error(_('wizard.role.name_exist')%{role: role_name}) if role_exists?(project_root, role_name) # Role creation role = Bebox::Role.new(role_name, project_root) output = role.create - ok 'Role created!.' + ok _('wizard.role.creation_success') return output end # Removes an existing role def remove_role(project_root) # Choose a role from the availables roles = Bebox::Role.list(project_root) # Get a role if exist. if roles.count > 0 - role_name = choose_option(roles, 'Choose the role to remove:') + role_name = choose_option(roles, _('wizard.role.choose_deletion_role')) else - return error "There are no roles to remove. No changes were made." + return error _('wizard.role.no_deletion_roles') end # Ask for deletion confirmation - return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the role?') + return warn(_('wizard.no_changes')) unless confirm_action?(_('wizard.role.confirm_deletion')) # Role deletion role = Bebox::Role.new(role_name, project_root) output = role.remove - ok 'Role removed!.' + ok _('wizard.role.deletion_success') return output end # Add a profile to a role def add_profile(project_root) roles = Bebox::Role.list(project_root) profiles = Bebox::Profile.list(project_root) - role = choose_option(roles, 'Choose an existing role:') - profile = choose_option(profiles, 'Choose the profile to add:') + role = choose_option(roles, _('wizard.choose_role')) + profile = choose_option(profiles, _('wizard.role.choose_add_profile')) if Bebox::Role.profile_in_role?(project_root, role, profile) - warn "Profile '#{profile}' already in the Role '#{role}'. No changes were made." + warn _('wizard.role.profile_exist')%{profile: profile, role: role} output = false else output = Bebox::Role.add_profile(project_root, role, profile) - ok "Profile '#{profile}' added to Role '#{role}'." + ok _('wizard.role.add_profile_success')%{profile: profile, role: role} end return output end # Remove a profile in a role def remove_profile(project_root) roles = Bebox::Role.list(project_root) profiles = Bebox::Profile.list(project_root) - role = choose_option(roles, 'Choose an existing role:') - profile = choose_option(profiles, 'Choose the profile to remove:') + role = choose_option(roles, _('wizard.choose_role')) + profile = choose_option(profiles, _('wizard.choose_remove_profile')) if Bebox::Role.profile_in_role?(project_root, role, profile) output = Bebox::Role.remove_profile(project_root, role, profile) - ok "Profile '#{profile}' removed from Role '#{role}'." + ok _('wizard.role.remove_profile_success')%{profile: profile, role: role} else - warn "Profile '#{profile}' is not in the Role '#{role}'. No changes were made." + warn _('wizard.role.profile_not_exist')%{profile: profile, role: role} output = false end return output end \ No newline at end of file