Permalink
Browse files

preparing for 2.7 release :)

  • Loading branch information...
1 parent 500510a commit ecc53c5860bc9b11db9b5aada5681e5654bc2ec7 @gurugeek committed Apr 17, 2012
View
14 README
@@ -1,13 +1,12 @@
-= KirbyBase 2.6
+= KirbyBase 2.7
A small, plain-text, dbms written in Ruby. It can be used either embedded
or client/server.
== Installation
-
-Unpack the file you downloaded. Execute "ruby install.rb" or simply make
-sure kirbybase.rb is somewhere in your Ruby library path.
+You can install Kirbybase via ruby gems:
+gem install KirbyBase
== Documentation
@@ -34,7 +33,7 @@ See the examples directory for examples of how to use KirbyBase.
== Author
Written in 2005 by Jamey Cribbs <mailto:jcribbs@twmi.rr.com>
-
+version 2.7 release & maintenance by gurugeek
== License
@@ -58,9 +57,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
== Feedback
Please send any bug reports, suggestions, ideas,
-improvements, to:
-
-jcribbs@netpromi.com
+improvements through the github repository
+https://github.com/gurugeek/KirbyBase
== Home Page
View
@@ -1,7 +1,7 @@
2012-04-16:: Version 2.7
* Adapted to work with both Ruby 1.9 and Ruby 1.8 including fixed to_report
(thanks to manveru for the help).
-* Added an example on how to use KirbyBase with Sinatra
+* Added an example on how to use KirbyBase with Camping (ruby microframework)
* This is mainly a maintenance relese. Please report any issue to
https://github.com/gurugeek/KirbyBase
@@ -0,0 +1,58 @@
+require 'camping'
+require 'camping-kirbybase'
+
+Camping.goes :CampingStocks
+
+module CampingStocks
+
+ module Models
+ end
+
+ module Controllers
+
+ class Index < R '/'
+ def get
+ render :index
+ end
+ end
+
+ class Page < R '/(\w+)'
+ def get(page_name)
+ render page_name
+ end
+ end
+ end
+
+ module Views
+ def layout
+ self << yield
+ end
+
+ def index
+ kirby = KirbyBase.new
+ stocks_tbl = kirby.get_table(:stocks)
+ results = stocks_tbl.select(:name,:ticker,:tradeprice,:tradedate,:quantity,:totalposition,:recno).sort(+:totalposition)
+
+ table do
+ tr do
+ td 'Stock Name'
+ td 'Ticker'
+ td 'Number of Stocks'
+ td 'Price'
+ td 'Date'
+ td 'Total Position'
+ end
+ for result in results
+ tr do
+ td result.name
+ td result.ticker
+ td result.quantity
+ td result.tradeprice
+ td result.tradedate
+ td result.totalposition
+ end
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+000004|000000|Struct|recno:Integer|name:String|ticker:String|tradeprice:Float|tradedate:Date|quantity:Integer|totalposition:Float:Calculated->quantity*tradeprice
+1|Coca-Cola|KO|72|2012-04-17|100|kb_nil
+2|Apple|AAPL|580.13|2012-04-17|10|kb_nil
+3|IBM|IBM|202.72|2012-04-17|20|kb_nil
+4|Amazon|AMZN|185.5|2012-04-17|45|kb_nil
@@ -0,0 +1,47 @@
+require 'rubygems'
+require 'kirbybase'
+db = KirbyBase.new
+db.drop_table(:stocks) if db.table_exists?(:stocks)
+
+stocks_tbl = db.create_table(:stocks, :name, :String, :ticker, :String,
+:tradeprice, :Float,:tradedate,:Date,:quantity,:Integer,:totalposition,{:DataType=>:Float,
+:Calculated=>'quantity*tradeprice'})
+
+stocks_tbl= db.get_table(:stocks)
+
+stocks_tbl.insert do |r|
+ r.name = 'Coca-Cola'
+ r.ticker = 'KO'
+ r.tradeprice = 72
+ r.tradedate = Date.today
+ r.quantity=100
+end
+
+
+stocks_tbl.insert do |r|
+ r.name = 'Apple'
+ r.ticker = 'AAPL'
+ r.tradeprice = 580.13
+ r.tradedate = Date.today
+ r.quantity=10
+end
+
+stocks_tbl.insert do |r|
+ r.name = 'IBM'
+ r.ticker = 'IBM'
+ r.tradeprice = 202.72
+ r.tradedate = Date.today
+ r.quantity=20
+end
+
+stocks_tbl.insert do |r|
+ r.name = 'Amazon'
+ r.ticker = 'AMZN'
+ r.tradeprice = 185.50
+ r.tradedate = Date.today
+ r.quantity=45
+end
+
+results=stocks_tbl.select(:name,:ticker,:tradeprice,:tradedate,:quantity,:totalposition,:recno).sort(+:totalposition).to_report
+puts results
+

0 comments on commit ecc53c5

Please sign in to comment.