Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moving generic application files to own directory

  • Loading branch information...
commit d9cb7f5e6157bab797507e1b86c3b714accde220 1 parent 86c7477
@winton authored
View
6 lib/application/controller.rb
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ Dir["#{root}/lib/#{app_name}/controller/*.rb"].sort.each do |path|
+ require path
+ end
+end
View
0  lib/gem_template/boot/haml.rb → lib/application/haml.rb
File renamed without changes
View
6 lib/application/helper.rb
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ Dir["#{root}/lib/#{app_name}/helper/*.rb"].sort.each do |path|
+ require path
+ end
+end
View
0  lib/gem_template/boot/lilypad.rb → lib/application/lilypad.rb
File renamed without changes
View
0  lib/gem_template/boot/log.rb → lib/application/log.rb
File renamed without changes
View
26 lib/application/redis.rb
@@ -0,0 +1,26 @@
+require 'redis'
+
+def redis
+ $redis ||= (
+
+ env = ENV['RACK_ENV'] || 'development'
+
+ if File.exists?('config/redis.yml')
+ yaml = YAML.load(File.read('config/redis.yml'))[env]
+
+ db = yaml.keys.first
+ config = yaml[db]
+ config['db'] = db
+
+ $redis_url = "#{config['host']}:#{config['port']}/#{config['db']}"
+
+ ::Redis.new(
+ :host => config['host'],
+ :port => config['port'],
+ :db => config['db']
+ )
+ end
+ )
+end
+
+redis
View
0  lib/gem_template/boot/session.rb → lib/application/session.rb
File renamed without changes
View
4 lib/gem_template/boot/sinatra.rb → lib/application/sinatra.rb
@@ -1,9 +1,9 @@
Application.class_eval do
set :environment, $testing ? :test : environment
- set :root, File.expand_path("#{File.dirname(__FILE__)}/../../../")
+ 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"
+ set :views, "#{root}/lib/#{app_name}/view"
end
View
21 lib/gem_template.rb
@@ -1,16 +1,17 @@
require "rubygems"
require "bundler"
-Bundler.require(:default)
+Bundler.setup(:default)
$:.unshift File.dirname(__FILE__)
-require 'gem_template/boot/application'
-require 'gem_template/boot/sinatra'
-require 'gem_template/boot/log'
-require 'gem_template/boot/session'
-require 'gem_template/boot/haml'
-require 'gem_template/boot/lilypad'
-require 'gem_template/boot/redis'
-require 'gem_template/boot/controller'
-require 'gem_template/boot/helper'
+require 'gem_template/application'
+
+require 'application/sinatra'
+require 'application/log'
+require 'application/session'
+require 'application/haml'
+require 'application/lilypad'
+require 'application/redis'
+require 'application/controller'
+require 'application/helper'
View
1  lib/gem_template/boot/application.rb → lib/gem_template/application.rb
@@ -1,4 +1,5 @@
require 'sinatra/base'
class Application < Sinatra::Base
+ set :app_name, 'gem_template'
end
View
8 lib/gem_template/boot/console.rb
@@ -1,8 +0,0 @@
-require File.expand_path('../../gems', __FILE__)
-
-GemTemplate::Gems.activate %w(active_wrapper sinatra)
-
-require File.dirname(__FILE__) + '/application'
-require File.dirname(__FILE__) + '/sinatra'
-require File.dirname(__FILE__) + '/active_wrapper'
-require File.dirname(__FILE__) + '/model'
View
6 lib/gem_template/boot/controller.rb
@@ -1,6 +0,0 @@
-Application.class_eval do
-
- Dir["#{root}/lib/gem_template/controller/*.rb"].sort.each do |path|
- require path
- end
-end
View
6 lib/gem_template/boot/helper.rb
@@ -1,6 +0,0 @@
-Application.class_eval do
-
- Dir["#{root}/lib/gem_template/helper/*.rb"].sort.each do |path|
- require path
- end
-end
View
23 lib/gem_template/boot/redis.rb
@@ -1,23 +0,0 @@
-require 'redis'
-
-def redis
- $redis ||= (
-
- env = ENV['RACK_ENV'] || 'development'
- yaml = YAML.load(File.read('config/redis.yml'))[env]
-
- db = yaml.keys.first
- config = yaml[db]
- config['db'] = db
-
- $redis_url = "#{config['host']}:#{config['port']}/#{config['db']}"
-
- ::Redis.new(
- :host => config['host'],
- :port => config['port'],
- :db => config['db']
- )
- )
-end
-
-redis
View
7 lib/gem_template/console.rb
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require
+
+require File.dirname(__FILE__) + '/application'
+require File.expand_path('../../application/sinatra', __FILE__)
View
4 script/console
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-lib = File.expand_path(File.dirname(__FILE__) + "/../lib/gem_template")
-exec "irb -r #{lib}/boot/console"
+lib = File.expand_path(File.dirname(__FILE__) + "/../lib")
+exec "irb -r #{lib}/gem_template/console"
Please sign in to comment.
Something went wrong with that request. Please try again.