# Clone the repository
git clone git@github.com:Carolis/ruby-tax.git
cd ruby-tax
# Install ruby dependencies
bundle install
# Finally run it
./bin/sales_tax{quantity} {product name} at {price}
Cents are separated by a dot using US convention
Input example:
1 book at 12.492 imported boxes of chocolates at 11.251 imported bottle of perfume at 27.99
Keywords config:
importedanywhere in name will mark the item as subject to import duty- category keywords (book, chocolate, pills, etc.) may be tax exempt if not imported
Important
You may need to give the program some permissions first if an error like Permission denied appears in the terminal.
# To change program permissions
chmod +x bin/sales_tax./bin/sales_taxafter inserting yours items you can either type done, press Command+D (or Ctrl+Z depending on your OS) to finish the input insertion
1 book at 12.49
1 music CD at 14.99
1 chocolate bar at 0.85
done
-
Paste multiple items at once and press Ctrl+D (Unix/Mac) or Ctrl+Z (Windows):
-
Insert a txt file as input
./bin/sales_tax < input.txtTip
You can use the original challenge input examples located in the examples folder
- Use it as a pipe command with arguments
echo "1 book at 12.49
1 music CD at 14.99
1 chocolate bar at 0.85" | ./bin/sales_tax# run all tests
bundle exec rspec
# run with coverage
bundle exec rspec --format documentation
# run specific test
bundle exec rspec spec/models/money_spec.rbTax exempt categories are configured in config/categories.yml:
exempt_categories:
book:
keywords:
- book
- books
food:
keywords:
- chocolate
- chocolates
- candy
medical:
keywords:
- pill
- pills
- tablet
- tablets