studio54 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +31 -0
- data/Gemfile.lock +68 -0
- data/LICENSE +25 -0
- data/README.md +0 -0
- data/Rakefile +56 -0
- data/VERSION +5 -0
- data/app/controllers/users_controller.rb +29 -0
- data/app/models/post.rb +4 -0
- data/app/models/user.rb +46 -0
- data/bare/Gemfile +31 -0
- data/bare/Rakefile +28 -0
- data/bare/config.ru +9 -0
- data/bare/config/app_tie.rb +12 -0
- data/bare/config/db.rb +20 -0
- data/bare/config/db_connect.rb +19 -0
- data/bare/config/environment.rb +17 -0
- data/bare/config/sinatra.rb +36 -0
- data/bare/config/studio54_tie.rb +2 -0
- data/bare/dance.rb +11 -0
- data/bare/lib/after_filters.rb +7 -0
- data/bare/lib/before_filters.rb +7 -0
- data/bare/lib/helpers.rb +5 -0
- data/bare/public/index.rhtml +1 -0
- data/bare/public/layout.rhtml +12 -0
- data/bare/static/css/base.css +86 -0
- data/bare/static/css/yui_reset.css +30 -0
- data/bare/test/helpers.rb +8 -0
- data/bare/test/suite.rb +13 -0
- data/bin/studio54 +65 -0
- data/config.ru +9 -0
- data/config/app_tie.rb +8 -0
- data/config/db.rb +20 -0
- data/config/db_connect.rb +19 -0
- data/config/environment.rb +17 -0
- data/config/sinatra.rb +36 -0
- data/dance.rb +80 -0
- data/ideas +0 -0
- data/lib/after_filters.rb +7 -0
- data/lib/base.rb +29 -0
- data/lib/before_filters.rb +30 -0
- data/lib/helpers.rb +24 -0
- data/lib/lazy_controller.rb +87 -0
- data/lib/lazy_record.rb +395 -0
- data/lib/partials.rb +19 -0
- data/lib/studio54.rb +14 -0
- data/lib/vendor.rb +23 -0
- data/public/_partial_test.rhtml +4 -0
- data/public/all.rhtml +7 -0
- data/public/form.rhtml +11 -0
- data/public/index.rhtml +6 -0
- data/public/layout.rhtml +15 -0
- data/public/partial_test.rhtml +6 -0
- data/public/test_find_by.rhtml +4 -0
- data/rack/cache/body/ec/b48431757330e446c58d88e317574ef0eca2e9 +0 -0
- data/rack/cache/meta/25/3a7a342a66b79119b7b8cb34bda89978f9e606 +0 -0
- data/rack/cache/meta/c1/34c9b7112c7d884220d6ee9a8e43ec69d2ea6e +0 -0
- data/static/css/base.css +86 -0
- data/static/css/yui_reset.css +30 -0
- data/static/hello.html +1 -0
- data/studio54.gemspec +25 -0
- data/tags +149 -0
- data/test/email.rb +8 -0
- data/test/environment.rb +28 -0
- data/test/helpers.rb +8 -0
- data/test/integration/index_test.rb +41 -0
- data/test/integration/partial_test.rb +50 -0
- data/test/mail/email_test.rb +14 -0
- data/test/rack/helpers.rb +23 -0
- data/test/suite.rb +8 -0
- data/test/unit/associations_test.rb +33 -0
- data/test/unit/callbacks_test.rb +16 -0
- data/test/unit/database_test.rb +73 -0
- data/test/unit/model_introspection_test.rb +44 -0
- data/test/unit/serialization_test.rb +19 -0
- data/test/unit/validations_test.rb +73 -0
- metadata +165 -0
data/bare/dance.rb
ADDED
data/bare/lib/helpers.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Index</h1>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/* base.css, part of YUI's CSS Foundation */
|
2
|
+
h1 {
|
3
|
+
/*18px via YUI Fonts CSS foundation*/
|
4
|
+
font-size:138.5%;
|
5
|
+
}
|
6
|
+
h2 {
|
7
|
+
/*16px via YUI Fonts CSS foundation*/
|
8
|
+
font-size:123.1%;
|
9
|
+
}
|
10
|
+
h3 {
|
11
|
+
/*14px via YUI Fonts CSS foundation*/
|
12
|
+
font-size:108%;
|
13
|
+
}
|
14
|
+
h1,h2,h3 {
|
15
|
+
/* top & bottom margin based on font size */
|
16
|
+
margin:1em 0;
|
17
|
+
}
|
18
|
+
h1,h2,h3,h4,h5,h6,strong {
|
19
|
+
/*bringing boldness back to headers and the strong element*/
|
20
|
+
font-weight:bold;
|
21
|
+
}
|
22
|
+
abbr,acronym {
|
23
|
+
/*indicating to users that more info is available */
|
24
|
+
border-bottom:1px dotted #000;
|
25
|
+
cursor:help;
|
26
|
+
}
|
27
|
+
em {
|
28
|
+
/*bringing italics back to the em element*/
|
29
|
+
font-style:italic;
|
30
|
+
}
|
31
|
+
blockquote,ul,ol,dl {
|
32
|
+
/*giving blockquotes and lists room to breath*/
|
33
|
+
margin:1em;
|
34
|
+
}
|
35
|
+
ol,ul,dl {
|
36
|
+
/*bringing lists on to the page with breathing room */
|
37
|
+
margin-left:2em;
|
38
|
+
}
|
39
|
+
ol li {
|
40
|
+
/*giving OL's LIs generated numbers*/
|
41
|
+
list-style: decimal outside;
|
42
|
+
}
|
43
|
+
ul li {
|
44
|
+
/*giving UL's LIs generated disc markers*/
|
45
|
+
list-style: disc outside;
|
46
|
+
}
|
47
|
+
dl dd {
|
48
|
+
/*giving UL's LIs generated numbers*/
|
49
|
+
margin-left:1em;
|
50
|
+
}
|
51
|
+
th,td {
|
52
|
+
/*borders and padding to make the table readable*/
|
53
|
+
border:1px solid #000;
|
54
|
+
padding:.5em;
|
55
|
+
}
|
56
|
+
th {
|
57
|
+
/*distinguishing table headers from data cells*/
|
58
|
+
font-weight:bold;
|
59
|
+
text-align:center;
|
60
|
+
}
|
61
|
+
caption {
|
62
|
+
/*coordinated marking to match cell's padding*/
|
63
|
+
margin-bottom:.5em;
|
64
|
+
/*centered so it doesn't blend in to other content*/
|
65
|
+
text-align:center;
|
66
|
+
}
|
67
|
+
p,fieldset,table {
|
68
|
+
/*so things don't run into each other*/
|
69
|
+
margin-bottom:1em;
|
70
|
+
}
|
71
|
+
|
72
|
+
/* my own styles */
|
73
|
+
body {
|
74
|
+
font-size:18px;
|
75
|
+
line-height:1.7;
|
76
|
+
}
|
77
|
+
|
78
|
+
h1 {
|
79
|
+
margin-bottom:10px;
|
80
|
+
}
|
81
|
+
|
82
|
+
#container {
|
83
|
+
margin:0 auto;
|
84
|
+
max-width:700px;
|
85
|
+
}
|
86
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
2
|
+
margin:0;
|
3
|
+
padding:0;
|
4
|
+
}
|
5
|
+
table {
|
6
|
+
border-collapse:collapse;
|
7
|
+
border-spacing:0;
|
8
|
+
}
|
9
|
+
fieldset,img {
|
10
|
+
border:0;
|
11
|
+
}
|
12
|
+
address,caption,cite,code,dfn,em,strong,th,var {
|
13
|
+
font-style:normal;
|
14
|
+
font-weight:normal;
|
15
|
+
}
|
16
|
+
ol,ul {
|
17
|
+
list-style:none;
|
18
|
+
}
|
19
|
+
caption,th {
|
20
|
+
text-align:left;
|
21
|
+
}
|
22
|
+
h1,h2,h3,h4,h5,h6 {
|
23
|
+
font-size:100%;
|
24
|
+
font-weight:normal;
|
25
|
+
}
|
26
|
+
q:before,q:after {
|
27
|
+
content:'';
|
28
|
+
}
|
29
|
+
abbr,acronym { border:0;
|
30
|
+
}
|
data/bare/test/suite.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# environment file
|
4
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'config/environment')
|
5
|
+
|
6
|
+
# minitest is default
|
7
|
+
require 'minitest/autorun'
|
8
|
+
###
|
9
|
+
# require 'minitest/spec'
|
10
|
+
# require 'test/unit'
|
11
|
+
# require 'shoulda'
|
12
|
+
# require 'rspec'
|
13
|
+
|
data/bin/studio54
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vim: set ts=2 sw=2 tw=78 ft=ruby :#
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'fileutils'
|
7
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "..", "config/environment")
|
8
|
+
include Studio54::Config::Environment
|
9
|
+
load File.join(ROOTDIR, 'VERSION')
|
10
|
+
|
11
|
+
module Studio54
|
12
|
+
|
13
|
+
class Options
|
14
|
+
|
15
|
+
def self.parse(args)
|
16
|
+
options = OpenStruct.new
|
17
|
+
|
18
|
+
opts_saved = OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: studio54 [options]"
|
20
|
+
opts.separator ""
|
21
|
+
opts.separator "Specific options:"
|
22
|
+
|
23
|
+
opts.on("-e", "--enter PROJECT_NAME", "Create studio54 project") do |name|
|
24
|
+
options.enter = true
|
25
|
+
options.project_name = name
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on_tail("-v", "--version", "Show Studio54 version") do
|
29
|
+
puts VERSION * '.'
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
34
|
+
puts opts
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
opts_saved.parse!(args)
|
40
|
+
options
|
41
|
+
end # end of Options::parse
|
42
|
+
end # end of class
|
43
|
+
|
44
|
+
options = Options.parse(ARGV)
|
45
|
+
if options.enter
|
46
|
+
newdir = File.join(File.expand_path('.'), options.project_name)
|
47
|
+
FileUtils.mkdir newdir
|
48
|
+
FileUtils.cp_r File.join(File.expand_path(File.dirname(__FILE__)),
|
49
|
+
'..') + '/bare/.', newdir
|
50
|
+
FileUtils.mkdir_p File.join(newdir, 'app', 'models')
|
51
|
+
FileUtils.mkdir File.join(newdir, 'app', 'controllers')
|
52
|
+
FileUtils.mkdir File.join(newdir, 'rakelib')
|
53
|
+
FileUtils.mkdir_p File.join(newdir, 'db', 'versions')
|
54
|
+
FileUtils.mkdir_p File.join(newdir, 'rack', 'cache', 'body')
|
55
|
+
FileUtils.mkdir File.join(newdir, 'rack', 'cache', 'meta')
|
56
|
+
if `ctags --version`
|
57
|
+
Dir.chdir newdir do
|
58
|
+
system "ctags -R ."
|
59
|
+
puts "Installed ctags."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
puts "Done."
|
63
|
+
end
|
64
|
+
end # end of module
|
65
|
+
|
data/config.ru
ADDED
data/config/app_tie.rb
ADDED
data/config/db.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Studio54
|
2
|
+
class Db
|
3
|
+
|
4
|
+
cattr_accessor :host
|
5
|
+
cattr_accessor :user
|
6
|
+
cattr_accessor :pass
|
7
|
+
cattr_accessor :schema
|
8
|
+
cattr_accessor :type
|
9
|
+
cattr_accessor :conn
|
10
|
+
|
11
|
+
self.host = 'localhost'
|
12
|
+
self.user = 'root'
|
13
|
+
self.pass = 'root'
|
14
|
+
self.schema = 'test'
|
15
|
+
# Mysql
|
16
|
+
self.type = 'Mysql'
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Studio54
|
2
|
+
begin
|
3
|
+
Db.conn.disconnect if Db.conn.kind_of? DBI::DatabaseHandle and
|
4
|
+
Db.conn.connected?
|
5
|
+
|
6
|
+
# connect to the MySQL server
|
7
|
+
Db.conn = DBI.connect("DBI:#{Db.type}:#{Db.schema}:#{Db.host}",
|
8
|
+
Db.user, Db.pass)
|
9
|
+
|
10
|
+
rescue DBI::DatabaseError => e
|
11
|
+
puts "Error code: #{e.err}"
|
12
|
+
puts "Error message: #{e.errstr}"
|
13
|
+
puts "Error SQLSTATE: #{e.state}" if e.respond_to? :state
|
14
|
+
|
15
|
+
# Db.conn is disconnected automatically if used in a controller
|
16
|
+
# action
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Studio54
|
2
|
+
module Config
|
3
|
+
module Environment
|
4
|
+
|
5
|
+
ROOTDIR = File.join(File.expand_path(File.dirname(__FILE__)), '..')
|
6
|
+
APPDIR = File.join(ROOTDIR, "app")
|
7
|
+
LIBDIR = File.join(ROOTDIR, "lib")
|
8
|
+
BINDIR = File.join(ROOTDIR, "bin")
|
9
|
+
CONFIGDIR = File.join(ROOTDIR, "config")
|
10
|
+
MODELSDIR = File.join(APPDIR, "models")
|
11
|
+
CONTROLLERSDIR = File.join(APPDIR, "controllers")
|
12
|
+
|
13
|
+
$:.unshift(ROOTDIR) unless $:.include? ROOTDIR
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/config/sinatra.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
class Studio54::Dancefloor < Sinatra::Base
|
2
|
+
|
3
|
+
set :app_file, __FILE__
|
4
|
+
|
5
|
+
configure :development do
|
6
|
+
set :server, %w[thin mongrel webrick]
|
7
|
+
set :dump_errors, false
|
8
|
+
set :shotgun, false
|
9
|
+
end
|
10
|
+
|
11
|
+
configure :production do
|
12
|
+
set :shotgun, false
|
13
|
+
end
|
14
|
+
|
15
|
+
# app root dir
|
16
|
+
set :root, File.join(File.expand_path(File.dirname(__FILE__)), '..')
|
17
|
+
### Static Files ###
|
18
|
+
# serve static files
|
19
|
+
set :static, true
|
20
|
+
# static file directory, served_from => :views.
|
21
|
+
# To override Sinatra's wrapping of rack/static, disable
|
22
|
+
# set :static and set :public_folder and explicity use
|
23
|
+
# Rack::Static from config.ru.
|
24
|
+
set :public_folder, Proc.new { File.join(root, 'static') }
|
25
|
+
###
|
26
|
+
# template files directory
|
27
|
+
set :views, Proc.new { File.join(root, 'public') }
|
28
|
+
# whether or not to use layout.* in view folder
|
29
|
+
set :erb, :layout => true
|
30
|
+
|
31
|
+
# enable sessions
|
32
|
+
set :sessions, true
|
33
|
+
# using _method (PUT, DELETE)
|
34
|
+
set :method_override, true
|
35
|
+
end
|
36
|
+
|
data/dance.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "config", "app_tie")
|
2
|
+
|
3
|
+
# main app class
|
4
|
+
#
|
5
|
+
# this is all test logic, to test the library files
|
6
|
+
# in studio54/lib
|
7
|
+
#
|
8
|
+
# the corresponding unit and integration test are in
|
9
|
+
# studio54/test/unit and studio54/test/integration
|
10
|
+
#
|
11
|
+
# along with those are some email tests (studio54/test/email)
|
12
|
+
# to test the default studio54 email gem: pony.
|
13
|
+
class Studio54::Dancefloor
|
14
|
+
include LazyController::Routable
|
15
|
+
|
16
|
+
get '/' do
|
17
|
+
controller :users, :index
|
18
|
+
# response["Cache-Control"] = "max-age=2, public"
|
19
|
+
flash[:notice] = "hi"
|
20
|
+
response.body = erb :index
|
21
|
+
response.send
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/test_find_by' do
|
25
|
+
controller :users, :find_by
|
26
|
+
response.body = erb :test_find_by
|
27
|
+
response.send
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/form' do
|
31
|
+
controller :users, :new
|
32
|
+
response.body = erb :form
|
33
|
+
response.send
|
34
|
+
end
|
35
|
+
|
36
|
+
get '/all' do
|
37
|
+
controller :users, :all
|
38
|
+
response.body = erb :all
|
39
|
+
response.send
|
40
|
+
end
|
41
|
+
|
42
|
+
get '/partial' do
|
43
|
+
@content = [1,2,3]
|
44
|
+
@partial_content = [4,5,6]
|
45
|
+
response.body = erb :partial_test
|
46
|
+
response.send
|
47
|
+
end
|
48
|
+
|
49
|
+
post '/create_user' do
|
50
|
+
res = controller :users, :create, params
|
51
|
+
if res
|
52
|
+
flash[:notice] = "you created user #{@user.name}"
|
53
|
+
redirect to('/all')
|
54
|
+
else
|
55
|
+
flash[:error] = @user.errors
|
56
|
+
redirect to('/form')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
post '/email/send' do
|
61
|
+
# set ENV['PASS'] to your gmail password
|
62
|
+
to = 'luke.gru@gmail.com'
|
63
|
+
from = to
|
64
|
+
Pony.mail :to => to,
|
65
|
+
:via => :smtp,
|
66
|
+
:via_options => {
|
67
|
+
:address => 'smtp.gmail.com',
|
68
|
+
:port => '587',
|
69
|
+
:enable_starttls_auto => true,
|
70
|
+
:user_name => from,
|
71
|
+
:password => ENV['PASS'],
|
72
|
+
:authentication => :plain,
|
73
|
+
:domain => "localhost.localdomain",
|
74
|
+
:headers => {"Content-Type" => 'text/plain'}
|
75
|
+
},
|
76
|
+
:subject => 'Hey, this is a really great idea',
|
77
|
+
:body => 'Hi me!'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|