-
Notifications
You must be signed in to change notification settings - Fork 0
/
coding_style
79 lines (57 loc) · 3.01 KB
/
coding_style
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
General
==============================================================================
Files must be encoded in UTF-8
No more than 77 characters including white space per line.
File must contain only one class definition, filename must be the class name
in lowercase.
Header
==============================================================================
Files shall begin by specifing the encoding (utf-8).
This example shows a way to specify the encoding compatible with ruby 1.9 and
emacs
------------------------------------------------------------------------------
# -*- encoding: utf-8 -*-
------------------------------------------------------------------------------
It must be followed the RDOC (http://rdoc.sourceforge.net/) meta information
of the document (authors, copyright and license). Example :
------------------------------------------------------------------------------
# Author:: Jonathan Marchand (mailto:[email protected])
# Copyright:: Copyright (c) 2006 Jérémy Marchand & Jonathan Marchand
# License:: GNU General Public License (GPL) version 2
------------------------------------------------------------------------------
It shall be followed by a copy of the license (comments must be escaped from
RDoc, use #-- and #++)
Finally, specify the encoding to make it compatible with ruby 1.8
------------------------------------------------------------------------------
$KCODE = "UTF-8"
------------------------------------------------------------------------------
Requires
==============================================================================
First requires must load ruby standard ruby libraries and extensions. They
should be adressed within simple quotes and without their extensions.
Then requires shall load local files from the project. They should be adressed
within double quotes with their extensions.
Identifier naming convention
==============================================================================
Multi-word identifiers shall use the underscore to delimit boundaries between
words.
Identifiers shall not use capitalized letters except :
- class (first letter is capitalized)
- constants are fully capitalized
Syntax
==============================================================================
One statement per line.
Don't use the semi-colon as a statement separator, use the carriage return.
Indent your code with two spaces per logical level. Furthermore, never use
tabs, which includes the practice of mixing tabs with spaces.
Put a single blank line between each method definition.
Document your libraries using RDoc (http://rdoc.sourceforge.net/).
Strings should be within double quotes.
Never omit the parentheses between a method name and its parameter list even
if it's empty. Exceptions are Kernel#require, Module#include, Kernel#p and
the attr_* methods.
All blocks must be constructed with braces ({})
Control structures shall use their long denotations :
- if ... then ... elsif ... then ... else ... end
- while ... do ... end
- for ... in ... do ... end