diff --git a/README b/README index e69de29..eda2454 100644 --- a/README +++ b/README @@ -0,0 +1,18 @@ +# Common Style + +This is a working repository for our style guides. The styleguide for each language/environment will be stored in its own markdown file. + +[CSS](https://github.com/commonmedia/styleguide/blob/master/css.md) +[HTML](https://github.com/commonmedia/styleguide/blob/master/html.md) +[JavaScript](https://github.com/commonmedia/styleguide/blob/master/javascript.md) +[PHP](https://github.com/commonmedia/styleguide/blob/master/php.md) +[Ruby](https://github.com/commonmedia/styleguide/blob/master/ruby.md) + +# Common Inspiration +* [https://github.com/styleguide/ruby](https://github.com/styleguide/ruby) +* [https://github.com/bbatsov/rails-style-guide](https://github.com/bbatsov/rails-style-guide) +* [https://github.com/lumoslabs/rails-style-guide](https://github.com/lumoslabs/rails-style-guide) + +# Common Contribution + +Nothing written in this guide is set in stone. Feel free to send pull requests with improvements, or request/suggest changes by submitting [Issues](https://github.com/commonmedia/styleguide/issues). Thanks in advance for your help! \ No newline at end of file diff --git a/ruby.md b/ruby.md new file mode 100644 index 0000000..1d47115 --- /dev/null +++ b/ruby.md @@ -0,0 +1,32 @@ +# Developing Rails applications + +## Coding Style +* Use soft-tabs with a two space indent. +* Never leave trailing whitespace. +* Use spaces around operators, after commas, colons and semicolons, around { and before }. + ``` + sum = 1 + 2 + a, b = 1, 2 + 1 > 2 ? true : false; puts 'Hi' + [1, 2, 3].each { |e| puts e } + ``` + +* No spaces after (, [ or before ], ). + ``` + some(arg).other + [1, 2, 3].length + ``` + +* Use empty lines between defs and to break up a method into logical paragraphs. + + ``` + def some_method + data = initialize(options) + data.manipulate! + data.result + end + + def some_method + result + end + ```