]> nos-oignons.net Git - gestion-adh.git/blob - features/support/fixtures.rb
Release the code under AGPLv3 and add missing copyright information
[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   address: |
39     ORANGE FRANCE
40     13, rue de Javel
41     75015 Paris
42   email: sylvain.dufier@orange-ftgroup.com
43   joined_on: 2013-05-20
44   membership_fee_paid_on: 2013-05-29
45     Il vient de `whois orange.fr`.
46 000003:
47   name: Salim Gasmi
48   address: |
49     SDV PLURIMEDIA
50     15, rue de la Nuee Bleue
51     67000 Strasbourg
52   email: domaines@sdv.fr
53   joined_on: 2010-01-21
54   membership_fee_paid_on: 2011-01-11
55     Il vient de `whois numericable.fr`.
56     Et il n'est pas à jour de cotisation.
57 END_OF_YAML
58
59 EXTRA_MEMBER = YAML.load(<<END_OF_YAML)
60 name: Franck Rohard
61 address: |
62   SOCIETE FRANCAISE DU RADIOTELEPHONE - SFR
63   42, avenue de Friedland
64   75008 Paris
65 email: domains@sfr.com
66 joined_on: 2013-04-04
67 membership_fee_paid_on: 2013-04-04
68 notes:
69   Il vient de `whois sfr.fr`.
70 END_OF_YAML
71
72 MEMBER_FILE_TEMPLATE = <<'END_OF_TEMPLATE'
73 ---
74 name: <%= name %>
75 address: |
76 <%= address.gsub(/^/, '  ').rstrip %>
77 email: <%= email %>
78 joined_on: <%= joined_on %>
79 membership_fee_paid_on: <%= membership_fee_paid_on %>
80 ---
81 [[!ftemplate id="membre"]]
82
83 <%= notes %>
84 END_OF_TEMPLATE
85
86 def member_filename_for_id(id)
87   "Membres/%06d.mdwn" % id
88 end
89
90 def render_member_file(locals)
91   ERB.new(MEMBER_FILE_TEMPLATE).result(OpenStruct.new(locals).instance_eval { binding })
92 end
93
94 def new_id
95   max_id = Dir.glob("#{current_dir}/Membres/*.mdwn").
96     collect { |f| File.basename(f).gsub(/\.mdwn$/, '').to_i }.max || 0
97   max_id + 1
98 end