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.
Files changed (76) hide show
  1. data/Gemfile +31 -0
  2. data/Gemfile.lock +68 -0
  3. data/LICENSE +25 -0
  4. data/README.md +0 -0
  5. data/Rakefile +56 -0
  6. data/VERSION +5 -0
  7. data/app/controllers/users_controller.rb +29 -0
  8. data/app/models/post.rb +4 -0
  9. data/app/models/user.rb +46 -0
  10. data/bare/Gemfile +31 -0
  11. data/bare/Rakefile +28 -0
  12. data/bare/config.ru +9 -0
  13. data/bare/config/app_tie.rb +12 -0
  14. data/bare/config/db.rb +20 -0
  15. data/bare/config/db_connect.rb +19 -0
  16. data/bare/config/environment.rb +17 -0
  17. data/bare/config/sinatra.rb +36 -0
  18. data/bare/config/studio54_tie.rb +2 -0
  19. data/bare/dance.rb +11 -0
  20. data/bare/lib/after_filters.rb +7 -0
  21. data/bare/lib/before_filters.rb +7 -0
  22. data/bare/lib/helpers.rb +5 -0
  23. data/bare/public/index.rhtml +1 -0
  24. data/bare/public/layout.rhtml +12 -0
  25. data/bare/static/css/base.css +86 -0
  26. data/bare/static/css/yui_reset.css +30 -0
  27. data/bare/test/helpers.rb +8 -0
  28. data/bare/test/suite.rb +13 -0
  29. data/bin/studio54 +65 -0
  30. data/config.ru +9 -0
  31. data/config/app_tie.rb +8 -0
  32. data/config/db.rb +20 -0
  33. data/config/db_connect.rb +19 -0
  34. data/config/environment.rb +17 -0
  35. data/config/sinatra.rb +36 -0
  36. data/dance.rb +80 -0
  37. data/ideas +0 -0
  38. data/lib/after_filters.rb +7 -0
  39. data/lib/base.rb +29 -0
  40. data/lib/before_filters.rb +30 -0
  41. data/lib/helpers.rb +24 -0
  42. data/lib/lazy_controller.rb +87 -0
  43. data/lib/lazy_record.rb +395 -0
  44. data/lib/partials.rb +19 -0
  45. data/lib/studio54.rb +14 -0
  46. data/lib/vendor.rb +23 -0
  47. data/public/_partial_test.rhtml +4 -0
  48. data/public/all.rhtml +7 -0
  49. data/public/form.rhtml +11 -0
  50. data/public/index.rhtml +6 -0
  51. data/public/layout.rhtml +15 -0
  52. data/public/partial_test.rhtml +6 -0
  53. data/public/test_find_by.rhtml +4 -0
  54. data/rack/cache/body/ec/b48431757330e446c58d88e317574ef0eca2e9 +0 -0
  55. data/rack/cache/meta/25/3a7a342a66b79119b7b8cb34bda89978f9e606 +0 -0
  56. data/rack/cache/meta/c1/34c9b7112c7d884220d6ee9a8e43ec69d2ea6e +0 -0
  57. data/static/css/base.css +86 -0
  58. data/static/css/yui_reset.css +30 -0
  59. data/static/hello.html +1 -0
  60. data/studio54.gemspec +25 -0
  61. data/tags +149 -0
  62. data/test/email.rb +8 -0
  63. data/test/environment.rb +28 -0
  64. data/test/helpers.rb +8 -0
  65. data/test/integration/index_test.rb +41 -0
  66. data/test/integration/partial_test.rb +50 -0
  67. data/test/mail/email_test.rb +14 -0
  68. data/test/rack/helpers.rb +23 -0
  69. data/test/suite.rb +8 -0
  70. data/test/unit/associations_test.rb +33 -0
  71. data/test/unit/callbacks_test.rb +16 -0
  72. data/test/unit/database_test.rb +73 -0
  73. data/test/unit/model_introspection_test.rb +44 -0
  74. data/test/unit/serialization_test.rb +19 -0
  75. data/test/unit/validations_test.rb +73 -0
  76. metadata +165 -0
@@ -0,0 +1,2 @@
1
+ require 'studio54'
2
+
@@ -0,0 +1,11 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), "config/app_tie")
2
+
3
+ class Studio54::Dancefloor
4
+ include LazyController::Routable
5
+
6
+ get '/' do
7
+ "yay"
8
+ end
9
+
10
+ end
11
+
@@ -0,0 +1,7 @@
1
+ module Studio54
2
+ class Dancefloor
3
+ after do
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+ module Studio54
2
+ class Dancefloor
3
+ before do
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,5 @@
1
+ class Studio54::Dancefloor
2
+ helpers do
3
+ end
4
+ end
5
+
@@ -0,0 +1 @@
1
+ <h1>Index</h1>
@@ -0,0 +1,12 @@
1
+ <html>
2
+ <head>
3
+ <!--
4
+ -<link rel="stylesheet" type="text/css" href="/css/yui_reset.css" />
5
+ -<link rel="stylesheet" type="text/css" href="/css/base.css" />
6
+ -->
7
+ </head>
8
+ <div id="page">
9
+ <%= yield %>
10
+ </div>
11
+ </html>
12
+
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ module Studio54
2
+
3
+ class Dancefloor
4
+
5
+ end
6
+
7
+ end
8
+
@@ -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
+
@@ -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
+
@@ -0,0 +1,9 @@
1
+ cur_dir = File.expand_path(File.dirname(__FILE__))
2
+ require File.join(cur_dir, 'dance')
3
+ use Rack::Cache,
4
+ :verbose => true,
5
+ :metastore => "file:#{cur_dir}/rack/cache/meta",
6
+ :entitystore => "file:#{cur_dir}/rack/cache/body"
7
+
8
+ run Studio54::Dancefloor
9
+
@@ -0,0 +1,8 @@
1
+ module Studio54
2
+ require_relative 'environment'
3
+ include Config::Environment
4
+
5
+ require File.join(LIBDIR, 'studio54')
6
+ require 'pony'
7
+ end
8
+
@@ -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
+
@@ -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
+
@@ -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
+