stympy/faker — pull request #227 by maartenvg (2014-07-16 14:29:49+00:00)
Title: Update commerce.department to return department based on random combinations of categories

First off, thanks for this gem. We use it quite intensively here at Shopify, and it is very useful!

For our use case the number of possible values for `Faker::Commerce.department` is a bit low, which means multiple calls generate duplicate results too often.

In this PR I'm suggesting to make the `department` method dynamic; randomly picking 1 to `n` (default 3) categories and using those to generate a string to represent the department. This will significantly increase the number of possible unique departments, making it a lot more useful to us.

* In the new situation, without any arguments, the method will still return things like:
```
Faker::Commerce.department := 'Food'
Faker::Commerce.department := 'Books & Food'
Faker::Commerce.department := 'Appliances, Toys & Tools'
```
* It is also possible to specify a max number of categories in the department string. So `Faker::Commerce.department(6)` will return a department containing anything between 1 and 6 (inclusive) items.
* If you always want a fixed number of items, you can specify that too with `Faker::Commerce.department(5, true)`. This will always return a department with 5 categories, such as `Groceries, Books, Health, Beauty & Tools`
* I've also made the last separator ` & ` translatable. So for example for Russian it would use ` и `.
* Finally, it is ensured that there are no duplicate categories in the resulting department. So `Books, Books & Books` is not possible.