Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[gem_template/sinatra] First commit

  • Loading branch information...
commit 299f8b9e6257e354a1e8a6e4e2ab4cc5cc933e0f 1 parent 4ab38af
@winton authored
View
5 .gitignore
@@ -1,5 +1,10 @@
.DS_Store
*.gem
+*.log
+config/database.yml
+config/deploy.rb
+config/mail.yml
coverage
+log
pkg
tmp
View
22 Rakefile
@@ -1,9 +1,31 @@
require 'rubygems'
+
+gems = [
+ [ 'cucumber', '=0.3.93' ],
+ [ 'rspec', '=1.2.8' ],
+ [ 'winton-active_wrapper', '=0.1.9' ]
+]
+
+gems.each do |name, version|
+ begin
+ gem name, version
+ rescue Exception
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/#{name}/lib"
+ end
+end
+
require 'rake'
+require 'active_wrapper/tasks'
+require 'cucumber/rake/task'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'gemspec'
+ActiveWrapper::Tasks.new(
+ :base => File.dirname(__FILE__),
+ :env => ENV['ENV']
+)
+
desc "Generate gemspec"
task :gemspec do
File.open("#{Dir.pwd}/#{GEM_NAME}.gemspec", 'w') do |f|
View
4 bin/gem_template
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.push File.expand_path("#{File.dirname(__FILE__)}/../lib")
-require 'gem_template'
View
3  config.ru
@@ -0,0 +1,3 @@
+require "#{File.dirname(__FILE__)}/lib/gem_template"
+
+run Application
View
6 config/database.example.yml
@@ -0,0 +1,6 @@
+development:
+ adapter: mysql
+ database: gem_template
+ username: root
+ password:
+ host: localhost
View
12 config/externals.yml
@@ -0,0 +1,12 @@
+winton-active_wrapper:
+ repo: git@github.com:winton/active_wrapper.git
+ path: vendor
+winton-secret_key:
+ repo: git@github.com:winton/secret_key.git
+ path: vendor
+sinatra:
+ repo: git://github.com/sinatra/sinatra.git
+ path: vendor
+webrat:
+ repo: git://github.com/brynary/webrat.git
+ path: vendor
View
32 config/mail.example.yml
@@ -0,0 +1,32 @@
+development:
+ imap:
+ password: password
+ port: 993
+ server: imap.gmail.com
+ ssl: true
+ use_login: true
+ username: test@sumapp.com
+ smtp:
+ address: smtp.gmail.com
+ authentication: :plain
+ domain: sumapp.com
+ password:
+ port: 587
+ enable_starttls_auto: true
+ user_name: test@sumapp.com
+production:
+ imap:
+ password: password
+ port: 993
+ server: imap.gmail.com
+ ssl: true
+ use_login: true
+ username: sum@sumapp.com
+ smtp:
+ address: smtp.gmail.com
+ authentication: :plain
+ domain: sumapp.com
+ password:
+ port: 587
+ enable_starttls_auto: true
+ user_name: sum@sumapp.com
View
19 config/schedule.example.rb
@@ -0,0 +1,19 @@
+require 'rubygems'
+
+begin
+ gem 'winton-secret_key', '=0.1.0'
+rescue Exception
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/winton-secret_key/lib"
+end
+
+require 'secret_key'
+key = SecretKey.new(File.dirname(__FILE__)).read
+
+every 1.minute do
+ case @environment
+ when 'development'
+ command "curl http://localhost:#{@port}/cron"
+ else
+ command "curl http://gem_template.com/#{key}"
+ end
+end
View
11 db/migrate/001_users.rb
@@ -0,0 +1,11 @@
+class Users < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+
+ end
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
View
10 features/example.feature
@@ -0,0 +1,10 @@
+Feature: Example
+
+ As a user
+ I want
+ In order
+
+ Scenario: I do something
+ /Given
+ /When
+ /Then
View
34 features/support/env.rb
@@ -0,0 +1,34 @@
+$testing = true
+$root = File.expand_path(File.dirname(__FILE__) + "/../../")
+$:.unshift "#{$root}/lib"
+
+require 'gem_template'
+
+gems = [
+ [ 'rack-test', '=0.4.0' ],
+ [ 'rspec', '=1.2.7' ]
+]
+
+gems.each do |name, version|
+ begin
+ gem name, version
+ rescue Exception
+ $:.unshift "#{File.dirname(__FILE__)}/../../vendor/#{name}/lib"
+ end
+end
+
+require 'rack/test'
+require 'spec/mocks'
+require 'test/unit'
+require "#{$root}/vendor/webrat/lib/webrat"
+
+World do
+ def app
+ Application
+ end
+
+ include Rack::Test::Methods
+ include Test::Unit::Assertions
+ include Webrat::Matchers
+ include Webrat::Methods
+end
View
11 features/support/rspec.rb
@@ -0,0 +1,11 @@
+Before do
+ $rspec_mocks ||= Spec::Mocks::Space.new
+end
+
+After do
+ begin
+ $rspec_mocks.verify_all
+ ensure
+ $rspec_mocks.reset_all
+ end
+end
View
3  features/support/webrat.rb
@@ -0,0 +1,3 @@
+Webrat.configure do |config|
+ config.mode = :rack
+end
View
29 gemspec.rb
@@ -1,5 +1,19 @@
GEM_NAME = 'gem_template'
-GEM_FILES = FileList['**/*'] - FileList['coverage', 'coverage/**/*', 'pkg', 'pkg/**/*']
+GEM_FILES = FileList['**/*'] - FileList[
+ '*.gem',
+ '*.log',
+ 'config/database.yml',
+ 'config/deploy.rb',
+ 'config/mail.yml',
+ 'coverage',
+ 'coverage/**/*',
+ 'log',
+ 'log/**/*',
+ 'pkg',
+ 'pkg/**/*',
+ 'tmp',
+ 'tmp/**/*'
+]
GEM_SPEC = Gem::Specification.new do |s|
# == CONFIGURE ==
s.author = "Winton Welsh"
@@ -7,8 +21,17 @@
s.homepage = "http://github.com/winton/#{GEM_NAME}"
s.summary = ""
# == CONFIGURE ==
- s.executables << GEM_NAME
- s.extensions << "install"
+ s.add_dependency('cucumber', '=0.3.93')
+ s.add_dependency('haml', '=2.2.2')
+ s.add_dependency('javan-whenever', '=0.3.6')
+ s.add_dependency('rack', '=1.0.0')
+ s.add_dependency('rack-test', '=0.4.0')
+ s.add_dependency('rspec', '=1.2.8')
+ s.add_dependency('shotgun', '=0.3')
+ s.add_dependency('sinatra', '=0.9.4')
+ s.add_dependency('winton-active_wrapper', '=0.1.9')
+ s.add_dependency('winton-externals', '=1.0.2')
+ s.add_dependency('winton-secret_key', '=0.1.0')
s.extra_rdoc_files = [ "README.markdown" ]
s.files = GEM_FILES.to_a
s.has_rdoc = false
View
4 install
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.push File.expand_path("#{File.dirname(__FILE__)}/lib")
-require 'gem_template'
View
29 lib/gem_template.rb
@@ -1 +1,28 @@
-require File.dirname(__FILE__) + "/gem_template/gem_template"
+require 'rubygems'
+
+gems = [
+ [ 'haml', '=2.2.2' ],
+ [ 'sinatra', '=0.9.4' ],
+ [ 'winton-active_wrapper', '=0.1.9' ],
+ [ 'winton-secret_key', '=0.1.0' ]
+]
+
+gems.each do |name, version|
+ begin
+ gem name, version
+ rescue Exception
+ $:.unshift "#{File.dirname(__FILE__)}/../vendor/#{name}/lib"
+ end
+end
+
+require 'haml'
+require 'sinatra/base'
+require 'active_wrapper'
+require 'secret_key'
+
+class Application < Sinatra::Base
+end
+
+Dir["#{File.dirname(__FILE__)}/gem_template/**/*.rb"].each do |path|
+ require path
+end
View
25 lib/gem_template/boot.rb
@@ -0,0 +1,25 @@
+Application.class_eval do
+
+ # Sinatra
+ enable :raise_errors
+ set :environment, $testing ? :test : environment
+ set :root, File.expand_path("#{File.dirname(__FILE__)}/../../")
+ set :public, "#{root}/public"
+ set :logging, true
+ set :static, true
+ set :views, "#{root}/lib/gem_template/view"
+
+ # Database, logging, and email
+ $db, $log, $mail = ActiveWrapper.setup(
+ :base => root,
+ :env => environment,
+ :stdout => environment != :test
+ )
+ $db.establish_connection
+ if $mail.config
+ ActionMailer::Base.raise_delivery_errors = true
+ end
+
+ # Secret key
+ $secret_key = SecretKey.new(root).read
+end
View
5 lib/gem_template/controller/front.rb
@@ -0,0 +1,5 @@
+Application.class_eval do
+ get '/' do
+ "#{self.class.environment}"
+ end
+end
View
8 lib/gem_template/helper/application.rb
@@ -0,0 +1,8 @@
+Application.class_eval do
+ helpers do
+
+ def partial(name, options={})
+ haml name, options.merge(:layout => false)
+ end
+ end
+end
View
2  lib/gem_template/model/user.rb
@@ -0,0 +1,2 @@
+class User < ActiveRecord::Base
+end
Please sign in to comment.
Something went wrong with that request. Please try again.