]> nos-oignons.net Git - gestion-adh.git/blob - features/support/fixtures.rb
Modification du traitement des adresses postales pour les rendre optionnelles
[gestion-adh.git] / features / support / fixtures.rb
1 #-*- coding: utf-8 -*-
2 #
3 # Système de gestion des adhésions de Nos oignons
4 # Copyright © 2013-2014 Nos oignons <contact@nos-oignons.net>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 require 'erb'
20 require 'ostruct'
21 require 'yaml'
22
23 BASE_MEMBERS = YAML.load(<<END_OF_YAML)
24 000001:
25   name: Matthieu Simon-Blavier
26   address: |
27     Domain Network Sas
28     17, square Edouard VII
29     75009 Paris
30     FR
31   email: registry@domainnetwork.fr
32   joined_on: 2013-02-21
33   membership_fee_paid_on: 2013-02-21
34   notes:
35     Il vient de `whois cogent.fr`.
36 000002:
37   name: Sylvain Dufier
38   email: sylvain.dufier@orange-ftgroup.com
39   joined_on: 2013-05-20
40   membership_fee_paid_on: 2013-05-29
41     Il vient de `whois orange.fr`.
42 000003:
43   name: Salim Gasmi
44   address: |
45     SDV PLURIMEDIA
46     15, rue de la Nuee Bleue
47     67000 Strasbourg
48   email: domaines@sdv.fr
49   joined_on: 2010-01-21
50   membership_fee_paid_on: 2011-01-11
51     Il vient de `whois numericable.fr`.
52     Et il n'est pas à jour de cotisation.
53 END_OF_YAML
54
55 EXTRA_MEMBER = YAML.load(<<END_OF_YAML)
56 name: Franck Rohard
57 address: |
58   SOCIETE FRANCAISE DU RADIOTELEPHONE - SFR
59   42, avenue de Friedland
60   75008 Paris
61 email: domains@sfr.com
62 joined_on: 2013-04-04
63 membership_fee_paid_on: 2013-04-04
64 notes:
65   Il vient de `whois sfr.fr`.
66 END_OF_YAML
67
68 MEMBER_FILE_TEMPLATE = <<'END_OF_TEMPLATE'
69 ---
70 name: <%= name %>
71 <% unless address.nil? %>
72 address: |
73 <%= address.gsub(/^/, '  ').rstrip %>
74 <% end %>
75 email: <%= email %>
76 joined_on: <%= joined_on %>
77 membership_fee_paid_on: <%= membership_fee_paid_on %>
78 ---
79 [[!ftemplate id="membre"]]
80
81 <%= notes %>
82 END_OF_TEMPLATE
83
84 def member_filename_for_id(id)
85   expand_path("Membres/%06d.mdwn" % id)
86 end
87
88 def render_member_file(locals)
89   ERB.new(MEMBER_FILE_TEMPLATE).result(OpenStruct.new(locals).instance_eval { binding })
90 end
91
92 def new_id
93   max_id = Dir.glob("#{expand_path('Membres')}/*.mdwn").
94     collect { |f| File.basename(f).gsub(/\.mdwn$/, '').to_i }.max || 0
95   max_id + 1
96 end