Skip to content

Commit

Permalink
Addinig directory structure to samples for #312
Browse files Browse the repository at this point in the history
* Created expert, good and simple subdirectories.
* Moved relevent samples to their own directory.
* Allow samples to be visible in the root directory.
* Shared files are in the root directory.
  • Loading branch information
IanTrudel committed Feb 21, 2017
1 parent f498d7d commit a410746
Show file tree
Hide file tree
Showing 51 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/shoes/help.rb
Expand Up @@ -134,7 +134,7 @@ def dewikify(str, intro = false)
def sample_page
folder = File.join DIR, 'samples'
h = {}
Dir.glob(File.join folder, '*').each do |file|
Dir.glob(File.join folder, '**/**').each do |file|
if File.extname(file) == '.rb'
key = File.basename(file).split('-')[0]
h[key] ? h[key].push(file) : h[key] = [file]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 23 additions & 23 deletions samples/simple-sqlite3.rb → samples/simple/simple-sqlite3.rb
@@ -1,23 +1,23 @@
require 'sqlite3'
require 'fileutils'
tmpdir = File.join(LIB_DIR,"sample-data")
mkdir_p tmpdir
dbfile = File.join(tmpdir, "simple-sqlite3.db")
if File.exists? dbfile
# this has a bad habit of failing on Windows
rm dbfile
end
Shoes.app :width => 350, :height => 130 do
info dbfile
db = SQLite3::Database.new dbfile
db.execute "create table t1 (t1key INTEGER PRIMARY KEY,data " \
"TEXT,num double,timeEnter DATE)"
db.execute "insert into t1 (data,num) values ('This is sample data',3)"
db.execute "insert into t1 (data,num) values ('More sample data',6)"
#db.execute "insert into t1 (data,num) values ('Aurélio, Küng, Stärk, Uña, Łuksza',6)"
db.execute "insert into t1 (data,num) values ('Aurlio, Kng, Strk, Ua, uksza',6)"
db.execute "insert into t1 (data,num) values ('And a little more',9)"
rows = db.execute "select * from t1"
rows.each{|k, d, n| para "#{k} : #{d} : #{n}\n"}
end
require 'sqlite3'
require 'fileutils'
tmpdir = File.join(LIB_DIR,"sample-data")
mkdir_p tmpdir
dbfile = File.join(tmpdir, "simple-sqlite3.db")
if File.exists? dbfile
# this has a bad habit of failing on Windows
rm dbfile
end
Shoes.app :width => 350, :height => 130 do
info dbfile
db = SQLite3::Database.new dbfile
db.execute "create table t1 (t1key INTEGER PRIMARY KEY,data " \
"TEXT,num double,timeEnter DATE)"
db.execute "insert into t1 (data,num) values ('This is sample data',3)"
db.execute "insert into t1 (data,num) values ('More sample data',6)"
#db.execute "insert into t1 (data,num) values ('Aurélio, Küng, Stärk, Uña, Łuksza',6)"
db.execute "insert into t1 (data,num) values ('Aurlio, Kng, Strk, Ua, uksza',6)"
db.execute "insert into t1 (data,num) values ('And a little more',9)"
rows = db.execute "select * from t1"
rows.each{|k, d, n| para "#{k} : #{d} : #{n}\n"}
end

File renamed without changes.

0 comments on commit a410746

Please sign in to comment.