Version 0.1.1
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 10 Mar 2008 13:39:19 +0000 (13:39 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 10 Mar 2008 13:39:19 +0000 (13:39 +0000)
* Added legacy currencies from old Europe
* Added man pages
* Added test script "curcy"

Makefile
README [deleted file]
curcy [new file with mode: 0755]
curcy-update
currencies
debian/changelog
debian/control
debian/rules
man/curcy-update.1 [new file with mode: 0644]
man/curcy.1 [new file with mode: 0644]
man/currencies.5 [new file with mode: 0644]

index 8c01f4bc04a7d173eb3fbdd12192b80e18602bee..e6be8144f506bfe98af07cd30e72136a847be58a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,9 @@ all:
 clean:
 
 install: all
+       mkdir -p $(DESTDIR)/usr/bin
        mkdir -p $(DESTDIR)/usr/sbin
        mkdir -p $(DESTDIR)/usr/share
-       cp curcy-update $(DESTDIR)/usr/sbin
+       cp -p curcy $(DESTDIR)/usr/bin
+       cp -p curcy-update $(DESTDIR)/usr/sbin
        cp -p currencies $(DESTDIR)/usr/share
diff --git a/README b/README
deleted file mode 100644 (file)
index 0b0e125..0000000
--- a/README
+++ /dev/null
@@ -1,19 +0,0 @@
-== Why a currency rate database on the system?
-
-Whenever you work at a multi locale project, currencies become a topic of
-concern sooner or later. Sometimes you can have a some rates for a few
-currencies, that you lazilly updates. What you need is a simple way to get
-curency rate.
-
-== Why that format?
-
-The encoding is compataible with most charsets, including ascii7. It does not contain any locale specific data.
-
-It's really basic. Each line has the syntax:
-<3 letter international currency code>=<decimal value>
-
-All the lines do have the same value
-Exemple:
-GBP=1.4758
-USD=0.7469
-means than $ 0.7469 = £ 1.4758
diff --git a/curcy b/curcy
new file mode 100755 (executable)
index 0000000..41c4582
--- /dev/null
+++ b/curcy
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ -z "$1" ]; then
+    echo "You must give a international currency code as a parameter, such as USD"
+    exit 1
+fi
+
+local_currency=`locale int_curr_symbol`
+if [ -z "$local_currency" ]; then
+    echo "Can't find you locale currency code"
+    exit 1
+fi
+
+local_currency_value=`grep $local_currency /usr/share/currencies | cut -d \  -f 2`
+if [ -z "$local_currency_value" ]; then
+    echo "You currency $local_currency is unavailable in exchange rate database"
+    exit 1
+fi
+#echo "1 euro = $local_currency_value $local_currency"
+
+target_currency=$1
+target_currency_value=`grep $target_currency /usr/share/currencies | cut -d \  -f 2`
+if [ -z "$target_currency_value" ]; then
+    echo "The currency $target_currency is unavailable in exchange rate database"
+    exit 1
+fi
+#echo "1 euro = $target_currency_value $target_currency"
+
+rate1=`echo "scale=4;$local_currency_value/$target_currency_value" | bc`
+rate2=`echo "scale=4;$target_currency_value/$local_currency_value" | bc`
+echo "1 $local_currency = $rate1 $target_currency"
+echo "1 $target_currency = $rate2 $local_currency"
index 573d8388500782d937eabad89614ff554ea63f1b..5ea742b2a5f4b8cb32b884eb60c58ba370b56434 100755 (executable)
@@ -1,12 +1,13 @@
 #!/usr/bin/env bash
 #
 # This script builds a file, usually /var/share/currencies where each line as the syntax
-# <3 letter international currency code>=<decimal value>
+# <3 letter international currency code> <decimal value>
 # All the lines do have the same value
+#
 # Exemple:
-# GBP=1.4758
-# USD=
-# means than $ = £ 1.4758
+# GBP 1.4758
+# USD 0.7469
+# means than £ 1.4758 = $ 0.7469. From there all kind of conversion are possibles.
 #
 # You are free to copy / modify / redistribute / resell that file, just keep the author name.
 # Author: Jean-Michel Vourgère <jmv_deb@nirgal.com>
@@ -102,7 +103,7 @@ for c in $currencies; do
     if [ -n "$verbose" ]; then
         echo 1 $c = $equiv $REFERENCE
     fi
-    echo $c=$equiv>> $target_file.new
+    echo $c $equiv>> $target_file.new
 
     if [ -z "$aggressive" ]; then
         # be nice with server: wait 1 to 2 minutes
@@ -110,4 +111,38 @@ for c in $currencies; do
     fi
 done
 
+if [ "REFERENCE" == "EUR" ]; then
+    #echo ATS 1/13.7603>> $target_file.new
+    #echo BEF 1/40.3399>> $target_file.new
+    #echo DEM 1/1.95583>> $target_file.new
+    #echo ESP 1/166.386>> $target_file.new
+    #echo FIM 1/5.94573>> $target_file.new
+    #echo FRF 1/6.55957>> $target_file.new
+    #echo GRD 1/340.750>> $target_file.new
+    #echo IEP 1/0.787564>> $target_file.new
+    #echo ITL 1/1936.27>> $target_file.new
+    #echo LUF 1/40.3399>> $target_file.new
+    #echo NLG 1/2.20371>> $target_file.new
+    #echo PTE 1/200.482>> $target_file.new
+    #echo SIT 1/239.640>> $target_file.new
+    #echo VAL 1/1936.27>> $target_file.new
+    
+    echo ATS .07267283416785971236>> $target_file.new
+    echo BEF .02478935247732393982>> $target_file.new
+    echo DEM .51129188119621848524>> $target_file.new
+    echo ESP .00601012104383782289>> $target_file.new
+    echo FIM .16818792646151103396>> $target_file.new
+    echo FRF .15244901723741037903>> $target_file.new
+    echo GRD .00293470286133528980>> $target_file.new
+    echo IEP 1.26973807842918162841>> $target_file.new
+    echo ITL .00051645689908948648>> $target_file.new
+    echo LUF .02478935247732393982>> $target_file.new
+    echo NLG .45378021609013890212>> $target_file.new
+    echo PTE .00498797897068065961>> $target_file.new
+    echo SIT .00417292605575029210>> $target_file.new
+    echo VAL .00051645689908948648>> $target_file.new
+else
+    echo "WARNING: reference must be EUR to get legacy currencies exchange rates."
+    echo "WARNING: ATS BEF DEM ESP FIM FRF GRD IEP ITL LUF NLG PTE SIT VAL will be unavailable!"
+fi
 mv $target_file.new $target_file
index 052ba8a7e13cd19e25e2dcd8bd72934381fe97fa..3da45573a6587d7865ab830b7fc4967fbd3ee619 100644 (file)
-ALL=0.008127
-DZD=0.01100
-XAL=0.9560
-ARS=0.2428
-AWG=0.4171
-AUD=0.6290
-BSD=0.7469
-BHD=1.9808
-BDT=0.01086
-BBD=0.3734
-BYR=0.0003483
-BZD=0.3791
-BMD=0.7461
-BTN=0.01632
-BOB=0.09424
-BWP=0
-BRL=0.3905
-GBP=1.4758
-BND=0.4845
-BGN=0.5103
-BIF=0.0006934
-KHR=0
-CAD=0.6993
-CVE=0
-KYD=0.9108
-XOF=0.001522
-XAF=0.001523
-CLP=0.001422
-CNY=0.09794
-COP=0.0003904
-KMF=0.002023
-XCP=2.5542
-CRC=0.001442
-HRK=0.1360
-CUP=0.7469
-CYP=1.7071
-CZK=0.03502
-DKK=0.1342
-DJF=0
-DOP=0.02310
-XCD=0.2766
-ECS=0.00002987
-EGP=0.1310
-SVC=0.08535
-ERN=0
-EEK=0.06379
-ETB=0.08274
-EUR=1.0000
-FKP=0
-FJD=0.4642
-GMD=0.02771
-GHC=0.00008058
-GIP=0
-XAU=489.75
-GTQ=0.09737
-GNF=0.0002165
-GYD=0
-HTG=0.02110
-HNL=0.03954
-HKD=0.09553
-HUF=0.003993
-ISK=0.01198
-INR=0.01839
-IDR=0.00008259
-IRR=0.00008051
-IQD=0.0005931
-ILS=0.1807
-JMD=0.01094
-JPY=0.006050
-JOD=1.0541
-KZT=0.005819
-KES=0.01125
-KRW=0.0008037
-KWD=2.5923
-LAK=0
-LVL=1.4341
-LBP=0.0004938
-LSL=0.1029
-LRD=0
-LYD=0
-LTL=0.2891
-MOP=0.09328
-MKD=0.01620
-MWK=0.005316
-MYR=0.2163
-MVR=0.05835
-MTL=2.3266
-MRO=0.002917
-MUR=0.02367
-MXN=0.06930
-MDL=0.06070
-MNT=0.0006425
-MAD=0.08945
-MMK=0
-NAD=0.1041
-NPR=0.01051
-ANG=0.4172
-TRY=0.5712
-NZD=0.5639
-ZWN=0.002987
-NIO=0.04142
-NGN=0.005860
-KPW=0
-NOK=0.1238
-OMR=1.9399
-XPF=0.008180
-PKR=0.01232
-XPD=275.78
-PAB=0.7469
-PGK=0.2474
-PYG=0.0001464
-PEN=0.2357
-PHP=0.01611
-XPT=973.64
-PLN=0.2634
-QAR=0.2052
-RON=0.3071
-RUB=0.02874
-RWF=0.001369
-WST=0.2897
-STD=0.00005529
-SAR=0.1991
-SCR=0.1187
-SLL=0.0002502
-XAG=9.8839
-SGD=0.4856
-SKK=0.02948
-SIT=0.004165
-SBD=0.1087
-SOS=0
-ZAR=0.1047
-LKR=0.006736
-SHP=0
-SDD=0.003186
-SZL=0.1041
-SEK=0.1060
-CHF=0.6015
-SYP=0
-TWD=0.02251
-TZS=0.0005951
-THB=0.02302
-TOP=0.3764
-TTD=0.1195
-TND=0.5730
-USD=0.7469
-AED=0.2033
-UGX=0.0004526
-UAH=0.1485
-UYU=0.03067
-VUV=0.007578
-VEB=0.0003478
-VND=0.00004632
-YER=0.003771
-ZMK=0.0001905
-ZWD=0.002987
+ALL 0.008127
+DZD 0.01100
+XAL 0.9560
+ARS 0.2428
+AWG 0.4171
+AUD 0.6290
+BSD 0.7469
+BHD 1.9808
+BDT 0.01086
+BBD 0.3734
+BYR 0.0003483
+BZD 0.3791
+BMD 0.7461
+BTN 0.01632
+BOB 0.09424
+BWP 0
+BRL 0.3905
+GBP 1.4758
+BND 0.4845
+BGN 0.5103
+BIF 0.0006934
+KHR 0
+CAD 0.6993
+CVE 0
+KYD 0.9108
+XOF 0.001522
+XAF 0.001523
+CLP 0.001422
+CNY 0.09794
+COP 0.0003904
+KMF 0.002023
+XCP 2.5542
+CRC 0.001442
+HRK 0.1360
+CUP 0.7469
+CYP 1.7071
+CZK 0.03502
+DKK 0.1342
+DJF 0
+DOP 0.02310
+XCD 0.2766
+ECS 0.00002987
+EGP 0.1310
+SVC 0.08535
+ERN 0
+EEK 0.06379
+ETB 0.08274
+EUR 1.0000
+FKP 0
+FJD 0.4642
+GMD 0.02771
+GHC 0.00008058
+GIP 0
+XAU 489.75
+GTQ 0.09737
+GNF 0.0002165
+GYD 0
+HTG 0.02110
+HNL 0.03954
+HKD 0.09553
+HUF 0.003993
+ISK 0.01198
+INR 0.01839
+IDR 0.00008259
+IRR 0.00008051
+IQD 0.0005931
+ILS 0.1807
+JMD 0.01094
+JPY 0.006050
+JOD 1.0541
+KZT 0.005819
+KES 0.01125
+KRW 0.0008037
+KWD 2.5923
+LAK 0
+LVL 1.4341
+LBP 0.0004938
+LSL 0.1029
+LRD 0
+LYD 0
+LTL 0.2891
+MOP 0.09328
+MKD 0.01620
+MWK 0.005316
+MYR 0.2163
+MVR 0.05835
+MTL 2.3266
+MRO 0.002917
+MUR 0.02367
+MXN 0.06930
+MDL 0.06070
+MNT 0.0006425
+MAD 0.08945
+MMK 0
+NAD 0.1041
+NPR 0.01051
+ANG 0.4172
+TRY 0.5712
+NZD 0.5639
+ZWN 0.002987
+NIO 0.04142
+NGN 0.005860
+KPW 0
+NOK 0.1238
+OMR 1.9399
+XPF 0.008180
+PKR 0.01232
+XPD 275.78
+PAB 0.7469
+PGK 0.2474
+PYG 0.0001464
+PEN 0.2357
+PHP 0.01611
+XPT 973.64
+PLN 0.2634
+QAR 0.2052
+RON 0.3071
+RUB 0.02874
+RWF 0.001369
+WST 0.2897
+STD 0.00005529
+SAR 0.1991
+SCR 0.1187
+SLL 0.0002502
+XAG 9.8839
+SGD 0.4856
+SKK 0.02948
+SIT 0.004165
+SBD 0.1087
+SOS 0
+ZAR 0.1047
+LKR 0.006736
+SHP 0
+SDD 0.003186
+SZL 0.1041
+SEK 0.1060
+CHF 0.6015
+SYP 0
+TWD 0.02251
+TZS 0.0005951
+THB 0.02302
+TOP 0.3764
+TTD 0.1195
+TND 0.5730
+USD 0.7469
+AED 0.2033
+UGX 0.0004526
+UAH 0.1485
+UYU 0.03067
+VUV 0.007578
+VEB 0.0003478
+VND 0.00004632
+YER 0.003771
+ZMK 0.0001905
+ZWD 0.002987
+ATS .07267283416785971236
+BEF .02478935247732393982
+DEM .51129188119621848524
+ESP .00601012104383782289
+FIM .16818792646151103396
+FRF .15244901723741037903
+GRD .00293470286133528980
+IEP 1.26973807842918162841
+ITL .00051645689908948648
+LUF .02478935247732393982
+NLG .45378021609013890212
+PTE .00498797897068065961
+SIT .00417292605575029210
+VAL .00051645689908948648
index fb95cfe90fa4a3f6e3009e523a5a4bb76af089ab..274faae47b1d474d3388108acd411ac342095c41 100644 (file)
@@ -1,3 +1,11 @@
+curcy (0.1.1) UNRELEASED; urgency=low
+
+  * Added legacy currencies from old Europe
+  * Added man pages
+  * Added test script "curcy"
+
+ --  Jean-Michel Vourgère <jmv_deb@nirgal.com>  Sat, 16 Jun 2007 22:31:13 +0200
+
 curcy (0.1) UNRELEASED; urgency=low
 
   * Initial release.
index b4bba2b62b2a71af1dc39848ad0c5e177b592cfe..fff21a71225a79d29f38be7a4146713291b32ae1 100644 (file)
@@ -1,12 +1,12 @@
 Source: curcy
-Section: contrib/misc
+Section: misc
 Priority: optional
-Maintainer: Jean-Michel Vourgère  <debspam@nirgal.com>
+Maintainer: Jean-Michel Vourgère  <jmv_deb@nirgal.com>
 Build-Depends: debhelper (>> 3.0.0)
 Standards-Version: 3.7.2.2
 
 Package: curcy
-Section: contrib/misc
+Section: misc
 Architecture: any
 Depends: curl
 Description: Currency rates database builder
index 3f5646df3e6fbfc4413acab89a54cca7e0a4c718..b30ddb8cfbad2c79ec61e12d3e3eef51385d13de 100755 (executable)
@@ -62,7 +62,7 @@ binary-arch: build install
 #      dh_installmime
 #      dh_installinit
        dh_installcron
-       dh_installman
+       dh_installman man/*
        dh_installinfo
 #      dh_undocumented
        dh_installchangelogs
diff --git a/man/curcy-update.1 b/man/curcy-update.1
new file mode 100644 (file)
index 0000000..2c2746b
--- /dev/null
@@ -0,0 +1,43 @@
+.TH curcy-update 1 "June 15, 2007" "" "User Commands"
+.SH NAME
+curcy-update \- currencies exchange rate database updater
+.SH SYNOPSIS
+.B curcy-update [\-hlv] [\-\-agressive] [\-\-target=filname]
+.SH DESCRIPTION
+.PP
+Fetch information about the currency exchange rate from the internet and store
+them in a file. The process is usally quite long, as we are very nice to the
+servers, and takes almost 4 hours.
+.TP
+.B \-\-aggressive
+.FB
+Do not sleep between hits.
+.TP
+.B \-h, \-\-help
+.FB
+Display usage summary.
+.TP
+.B \-\-l, \-\-listonly
+.FB
+Stop after fetching the list of currencies. Only usefull for debugging.
+.TP
+.B "\-\-target=<filename>"
+.FB
+Sets target file.
+.TP
+.B \-v, \-\-verbose
+.FB
+Echo results during operation.
+.SH EXAMPLE
+curcy-update -v --target=./currencies
+.SH FILES
+.I /usr/share/currencies
+.I /etc/cron.weekly/curcy
+.SH BUGS
+Some currencies have a 0 value.
+.SH "AUTHOR"
+Jean-Michel Vourgère
+.mso www.tmac
+.URL "http://www.nirgal.com/"
+.SH "SEE ALSO"
+.BR currencies (5), curcy(1)
diff --git a/man/curcy.1 b/man/curcy.1
new file mode 100644 (file)
index 0000000..9a13f71
--- /dev/null
@@ -0,0 +1,28 @@
+.TH curcy 1 "June 15, 2007" "" "User Commands"
+.SH NAME
+curcy \- currencies exchange rate test script
+.SH SYNOPSIS
+.B curcy <symbol>
+.SH DESCRIPTION
+.PP
+Print currency exchange rates from and to your locale one.
+.SH EXAMPLE
+.BI "curcy USD"
+.PP
+1 GBP  = 1.9759 USD
+.PP
+1 USD = .5060 GBP
+.SH NOTES
+.PP
+This is an pre-release example script. Its output should not be used in
+scripts since it will be subject to changes.
+.SH FILES
+.I /usr/share/currencies
+.SH BUGS
+Some currencies have a 0 value, that can lead to NaN.
+.SH "AUTHOR"
+Jean-Michel Vourgère
+.mso www.tmac
+.URL "http://www.nirgal.com/"
+.SH "SEE ALSO"
+.BR currencies (5), curcy-update(1)
diff --git a/man/currencies.5 b/man/currencies.5
new file mode 100644 (file)
index 0000000..f446677
--- /dev/null
@@ -0,0 +1,34 @@
+.TH currencies 5 "June 15, 2007" "" "File formats and conversions"
+.SH NAME
+currencies \- currencies exchange rate database
+.SH SYNOPSIS
+This manual page describe the format of the currencies file
+.PP
+Whenever you work at a commercial multi locale project, currencies become a
+topic of concern sooner or later. Sometimes you can satisfy yourself with a few
+exchange rates that you lazilly updates, but what you need is a simple way to
+get curency rate.
+.SH DESCRIPTION
+The charset encoding is ascii7, that is compatatible with most charsets,
+including utf8. It does not contain any locale specific data.
+.PP
+It's really basic. Each line has the syntax:
+.PP
+<3 letter international currency code> <decimal value>
+.SH EXAMPLE
+.nf
+GBP 1.4758
+USD 0.7469
+.fi
+.PP
+This means than $ 0.7469 = £ 1.4758. From there all kind of conversion are possibles.
+.SH BUGS
+Some currencies have a 0 value.
+.SH FILES
+.I /usr/share/currencies
+.SH "AUTHOR"
+Jean-Michel Vourgère
+.mso www.tmac
+.URL "http://www.nirgal.com/"
+.SH "SEE ALSO"
+.BR curcy-update (1), curcy(1)