X-Git-Url: https://nos-oignons.net/gitweb/gestion-adh.git/blobdiff_plain/8bbb07a1bc5db944ba95fa5951ed40c3c1b968aa..76f86b5fd3f52363a3ce219310062270ee4eb52a:/features/support/fixtures.rb diff --git a/features/support/fixtures.rb b/features/support/fixtures.rb index 47290c7..0d01e20 100644 --- a/features/support/fixtures.rb +++ b/features/support/fixtures.rb @@ -1,10 +1,26 @@ #-*- coding: utf-8 -*- +# +# Système de gestion des adhésions de Nos oignons +# Copyright © 2013-2014 Nos oignons +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . require 'erb' require 'ostruct' require 'yaml' -BASE_SUBSCRIPTIONS = YAML.load(< +<% unless address.nil? %> address: | <%= address.gsub(/^/, ' ').rstrip %> +<% end %> email: <%= email %> -mumbership_fee_paid_on: <%= membership_fee_paid_on %> +joined_on: <%= joined_on %> +membership_fee_paid_on: <%= membership_fee_paid_on %> --- +[[!ftemplate id="membre"]] <%= notes %> END_OF_TEMPLATE -def subscription_filename_for_id(id) - "Membres/%06d.mdwn" % id +def member_filename_for_id(id) + expand_path("Membres/%06d.mdwn" % id) end -def render_subscription_file(locals) - ERB.new(SUBSCRIPTION_FILE_TEMPLATE).result(OpenStruct.new(locals).instance_eval { binding }) +def render_member_file(locals) + ERB.new(MEMBER_FILE_TEMPLATE).result(OpenStruct.new(locals).instance_eval { binding }) end def new_id - new_id = Dir.glob("#{current_dir}/Membres/*.mdwn"). - collect { |f| File.basename(f).gsub(/\.mdwn$/, '').to_i }.max + 1 + max_id = Dir.glob("#{expand_path('Membres')}/*.mdwn"). + collect { |f| File.basename(f).gsub(/\.mdwn$/, '').to_i }.max || 0 + max_id + 1 end