webapp 0.0.1

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/bin/webapp ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ require 'webapp'
3
+
4
+ if application = ARGV[0]
5
+ Webapp::Generator.generate(application)
6
+ else
7
+ puts "Usage: webapp <application_name>"
8
+ exit 1
9
+ end
10
+
11
+
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), 'lib', 'project')
2
+ require 'rake/testtask'
3
+
4
+ task :default => :test
5
+
6
+ Rake::TestTask.new { |t| t.pattern = 'test/**/*_test.rb' }
7
+
8
+ namespace :db do
9
+ desc "Database migrations"
10
+ task :migrate do
11
+ require 'sequel/extensions/migration'
12
+ if ENV['VERSION']
13
+ Sequel::Migrator.apply(Project.db, Project.migration_dir, ENV['VERSION'].to_i)
14
+ else
15
+ Sequel::Migrator.apply(Project.db, Project.migration_dir)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ gems:
2
+ - name: sinatra
3
+ install_options: --no-ri --no-rdoc
4
+ # version: '>= 0.8'
5
+ - name: haml
6
+ install_options: --no-ri --no-rdoc
7
+ - name: sequel
8
+ install_options: --no-ri --no-rdoc
9
+ - name: rake
10
+ install_options: --no-ri --no-rdoc
11
+ - name: mysql
12
+ install_options: --no-ri --no-rdoc
@@ -0,0 +1,14 @@
1
+ server {
2
+ listen 80;
3
+ server_name <%= application %>;
4
+
5
+ access_log /var/www/<%= application %>/shared/log/nginx_access.log;
6
+ error_log /var/www/<%= application %>/shared/log/nginx_error.log;
7
+ root /var/www/<%= application %>/current/public;
8
+
9
+ passenger_enabled on;
10
+ # rack_env production; # default is production
11
+
12
+ error_page 404 /404.html;
13
+ error_page 500 502 503 504 /500.html;
14
+ }
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require File.join(File.dirname(__FILE__), 'lib', 'server')
4
+
5
+ run Sinatra::Application
@@ -0,0 +1,53 @@
1
+ require 'logger'
2
+ require 'rubygems'
3
+ require 'sequel'
4
+
5
+ class Project
6
+ def self.root
7
+ File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
+ end
9
+
10
+ def self.migration_dir
11
+ File.expand_path(File.join(File.dirname(__FILE__), 'migrations'))
12
+ end
13
+
14
+ def self.env
15
+ ENV['RACK_ENV'] || 'development'
16
+ end
17
+
18
+ def self.logger
19
+ @logger ||= begin
20
+ if self.env == 'production'
21
+ FileUtils.mkdir_p(File.join(self.root, 'log'))
22
+ logger = Logger.new(File.new(File.join(self.root, 'log', 'production.log'), 'a'))
23
+ logger.level = Logger::WARN
24
+ logger
25
+ elsif self.env == 'test'
26
+ logger = Logger.new(STDOUT)
27
+ logger.level = Logger::ERROR
28
+ logger
29
+ else
30
+ logger = Logger.new(STDOUT)
31
+ logger.level = Logger::INFO
32
+ logger
33
+ end
34
+ end
35
+ end
36
+
37
+ def self.db
38
+ @db ||= begin
39
+ defaults = {:user => 'root', :encoding => 'utf8'}
40
+ db = case self.env
41
+ when 'production'
42
+ opts = defaults.merge(:password => 'ROCK')
43
+ Sequel.mysql('<%= application %>_production', opts)
44
+ when 'test'
45
+ Sequel.sqlite
46
+ else
47
+ Sequel.mysql('<%= application %>_development', defaults)
48
+ end
49
+ db.loggers << self.logger
50
+ db
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'project')
2
+
3
+ require 'sinatra'
4
+ require 'haml'
5
+
6
+ configure do
7
+ set :views, File.join(Project.root, 'views')
8
+ end
9
+
10
+ get '/' do
11
+ 'Hello '
12
+ end
data/lib/webapp.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+ include FileUtils
4
+
5
+ module Webapp
6
+ class Generator
7
+ def self.generate(application)
8
+
9
+ %w[lib test config views lib/migrations].each { |dir| mkdir_p "#{application}/#{dir}" }
10
+
11
+ files = %w[lib/project.rb lib/server.rb Rakefile config.ru config/nginx.conf config/geminstaller.yml]
12
+
13
+ files.each do |tmpl|
14
+ template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', tmpl)))
15
+ File.open("#{application}/#{tmpl}", 'w') { |f| f << template.result(binding) }
16
+ end
17
+
18
+ end
19
+ end
20
+ end
data/webapp.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'webapp'
3
+ s.version = '0.0.1'
4
+ s.platform = Gem::Platform::RUBY
5
+ s.summary, s.description = 'Cmd that generates a webapp skeleton'
6
+ s.author = 'George Malamidis'
7
+ s.email = 'george@nutrun.com'
8
+ s.homepage = 'http://nutrun.com/'
9
+ s.has_rdoc = true
10
+ s.executables = ['webapp']
11
+ s.files = [
12
+ 'bin/webapp',
13
+ 'lib/templates/config/geminstaller.yml',
14
+ 'lib/templates/config/nginx.conf',
15
+ 'lib/templates/config.ru',
16
+ 'lib/templates/lib/server.rb',
17
+ 'lib/templates/lib/project.rb',
18
+ 'lib/templates/Rakefile',
19
+ 'lib/webapp.rb',
20
+ 'webapp.gemspec',
21
+ ]
22
+ s.add_dependency('sinatra')
23
+ s.add_dependency('sequel')
24
+ s.add_dependency('haml')
25
+ s.add_dependency('geminstaller')
26
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - George Malamidis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-28 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sequel
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: haml
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: geminstaller
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: ""
56
+ email: george@nutrun.com
57
+ executables:
58
+ - webapp
59
+ extensions: []
60
+
61
+ extra_rdoc_files: []
62
+
63
+ files:
64
+ - bin/webapp
65
+ - lib/templates/config/geminstaller.yml
66
+ - lib/templates/config/nginx.conf
67
+ - lib/templates/config.ru
68
+ - lib/templates/lib/server.rb
69
+ - lib/templates/lib/project.rb
70
+ - lib/templates/Rakefile
71
+ - lib/webapp.rb
72
+ - webapp.gemspec
73
+ has_rdoc: true
74
+ homepage: http://nutrun.com/
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.3.5
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Cmd that generates a webapp skeleton
101
+ test_files: []
102
+