Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
# Ignore the default SQLite database.
/var/*.sqlite3

# Ignore the config.
/var/config.yaml

# Ignore the currency-images.
/var/currency-images

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ before_install:
- sudo apt-get update
- sudo apt-get install gemnasium-toolbelt nodejs
script:
- cd var && ln -s default_config.yaml config.yaml && ln -s currency-images-default currency-images && cd ..
- bundle exec rake db:migrate RAILS_ENV=test
- bundle exec rake
after_success:
Expand Down
4 changes: 4 additions & 0 deletions Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ git clone https://github.com/chaosdorf/mete.git
cd mete
bundle
rake db:migrate
cd var
cp default_config.yaml config.yaml # you'll want to adjust this
ln -s currency-images-default currency-images # or cp
cd ..
```

## Run ##
Expand Down
1 change: 1 addition & 0 deletions app/assets/images/currency-images
12 changes: 11 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ module ApplicationHelper

def show_amount(price)
return 'n/a' if price.blank?
sprintf('%.2f EUR', price)
res = ""
if APP_CONFIG["currency"]["before_value"]
res += "#{APP_CONFIG["currency"]["symbol"]} "
end

res += sprintf('%.2f', price)

unless APP_CONFIG["currency"]["before_value"]
res += " #{APP_CONFIG["currency"]["symbol"]}"
end
return res
end

def link_to_drink_if_exists(drink)
Expand Down
8 changes: 4 additions & 4 deletions app/views/application/_bills.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- [0.5,1,2,5,10,20,50].each do |amount|
- path = deposit_user_path(@user, :amount => amount) if @user
- APP_CONFIG["currency"]["amounts"].each do |amount|
- path = deposit_user_path(@user, :amount => amount["amount"]) if @user
.col-xs-12.col-sm-6.col-md-3.col-lg-2
= link_to path || '#' do
.panel.panel-default.text-center
.panel-body
= image_tag "euro-#{amount}.png", alt: show_amount(amount)
= image_tag "currency-images/#{amount['image']}", alt: show_amount(amount["amount"])
.panel-footer
+
= show_amount amount
= show_amount amount["amount"]
4 changes: 4 additions & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

# load the config
require 'yaml'
APP_CONFIG = YAML.load_file(File.expand_path('../../var/config.yaml', __FILE__))
1 change: 1 addition & 0 deletions config/spring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
var/config.yaml
).each { |path| Spring.watch(path) }
File renamed without changes
File renamed without changes
File renamed without changes
17 changes: 17 additions & 0 deletions var/default_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
currency:
name: euro
symbol: €
before_value: false
amounts:
- amount: 0.5
image: euro-0.5.png
- amount: 1
image: euro-1.png
- amount: 2
image: euro-2.png
- amount: 5
image: euro-5.png
- amount: 10
image: euro-10.png
- amount: 20
image: euro-20.png