kelredd-sinatra-helpers 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'ftools'
1
+ require 'fileutils'
2
2
  require 'erb'
3
3
  require 'useful/ruby_extensions/string'
4
4
 
@@ -17,7 +17,7 @@ module SinatraHelpers::Generator
17
17
  end
18
18
 
19
19
  def name=(name)
20
- @name = name.gsub(/([A-Z])([a-z])/, '-\1\2').sub(/^-/, '').downcase
20
+ @name = name.gsub(/([A-Z])([a-z])/, '-\1\2').sub(/^-/, '').gsub(/\.\w*/, '').downcase
21
21
  end
22
22
 
23
23
  def generate
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'gemsconfig/tasks/rake'
3
2
  require 'rake/testtask'
4
3
 
5
4
  namespace :test do
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
- require 'config/boot'
3
+ require 'app/base'
4
4
 
5
5
  # define routes here or load in route definitions
6
6
 
@@ -20,8 +20,3 @@ def load_app(files_dir)
20
20
  end
21
21
 
22
22
  require 'config/env'
23
- begin
24
- require "config/envs/#{RACK_ENV.downcase}"
25
- rescue LoadError => err
26
- puts "no environment config set up for '#{RACK_ENV.downcase}', ignoring..."
27
- end
@@ -0,0 +1,11 @@
1
+ RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined? RACK_ENV
2
+ require 'app'
3
+ set :app_file, File.join(root_path, 'app.rb')
4
+ disable :run
5
+
6
+ FileUtils.mkdir_p 'log' unless File.exists?('log')
7
+ log = File.new("log/#{RACK_ENV.downcase}.log", "a+")
8
+ $stdout.reopen(log)
9
+ $stderr.reopen(log)
10
+
11
+ run Sinatra::Application
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ RACK_ENV = ENV['RACK_ENV'] ||= ARGV.first || 'development'
3
4
  platform_irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
5
 
5
6
  require 'rubygems'
@@ -2,3 +2,20 @@ require 'capistrano/ext/multistage'
2
2
  require 'useful/cap_tasks'
3
3
 
4
4
  set :stages, %w(live staging)
5
+
6
+ require 'useful/cap_tasks/git_query_revision_remote'
7
+ require 'useful/cap_tasks/passenger_deploy'
8
+ require 'useful/cap_tasks/disable_with_down_html'
9
+ require 'useful/cap_tasks/rack_cache'
10
+
11
+ namespace :deploy do
12
+
13
+ after 'deploy:update_code', 'deploy:setup_stage_environment'
14
+
15
+ desc "_: (#{application}) Setup production environment (files, symlinks, etc...)."
16
+ task :setup_stage_environment, :roles => :app, :except => { :no_release => true } do
17
+ config = "#{release_path}/admin/#{rack_env}.ru"
18
+ run "cp #{config} #{release_path}/config.ru"
19
+ end
20
+
21
+ end
@@ -0,0 +1,2 @@
1
+ set :stage_branch, :production
2
+ set :rack_env, 'production'
@@ -0,0 +1,2 @@
1
+ set :stage_branch, :current_git_branch
2
+ set :rack_env, 'staging'
@@ -1,3 +1,6 @@
1
+ require 'logger'
2
+ LOGGER = Logger.new(root_path('log', "#{RACK_ENV}.log"))
3
+
1
4
  require 'config/gems'
2
5
  Gemsconfig::load if defined?(Gemsconfig)
3
6
 
@@ -7,10 +10,23 @@ set :views, root_path("app", "views")
7
10
  set :images_path, public_path("images")
8
11
  set :environment, RACK_ENV.to_sym if defined?(RACK_ENV)
9
12
 
13
+ # Load environment
14
+ begin
15
+ require "config/envs/#{RACK_ENV.downcase}"
16
+ rescue LoadError => err
17
+ puts "no environment config set up for '#{RACK_ENV.downcase}', ignoring..."
18
+ end
19
+
20
+ # Load initializers
21
+ Dir[root_path('config', 'initializers', '*.rb')].each do |file|
22
+ require file
23
+ end
24
+
10
25
  # load app files
11
26
  load_app 'helpers'
12
27
  load_app 'models'
13
28
 
29
+ # load middlewares
14
30
  # TODO: set your session cookie name here
15
31
  use Rack::Session::Cookie, :key => '_sess'
16
32
  use Rack::Flash
@@ -20,12 +36,10 @@ Rack::Less.configure do |config|
20
36
  config.combinations = {
21
37
  'web' => ['reset', 'app']
22
38
  }
23
- config.compress = config.cache = production?
39
+ config.cache = production?
24
40
  end
25
41
 
26
42
  use Rack::Sprockets
27
43
  Rack::Sprockets.configure do |config|
28
- if config.cache = production?
29
- config.compress = :whitespace
30
- end
44
+ config.cache = production?
31
45
  end
@@ -1,10 +0,0 @@
1
- require 'rack/cache'
2
- use Rack::Cache,
3
- :verbose => true,
4
- :metastore => "file:#{root_path('cache-rack', 'meta')}",
5
- :entitystore => "file:#{root_path('cache-rack', 'body')}"
6
-
7
- FileUtils.mkdir_p 'log' unless File.exists?('log')
8
- log = File.new("log/#{RACK_ENV.downcase}.log", "a+")
9
- $stdout.reopen(log)
10
- $stderr.reopen(log)
@@ -7,7 +7,7 @@ end
7
7
  Gemsconfig::init do |config|
8
8
 
9
9
  config.gem 'rack-flash', :lib => 'rack-flash'
10
- config.gem 'rack-cache', :lib => false
10
+ config.gem 'rack-cache', :lib => 'rack/cache'
11
11
  config.gem 'rack-less', :lib => 'rack/less'
12
12
  config.gem 'rack-sprockets', :lib => 'rack/sprockets'
13
13
 
@@ -11,7 +11,7 @@
11
11
  <meta name="robots" content="noindex,nofollow" />
12
12
  <% end %>
13
13
  <link rel="icon" type="image/png" href="/favicon.png"></link>
14
- <%= spreadsheet_link_tag Rack::Less.combinations('web'), :media => "all" %>
14
+ <%= stylesheet_link_tag Rack::Less.combinations('web'), :media => "all" %>
15
15
  <% unless @noscript %>
16
16
  <%= javascript_include_tag 'app.js' %>
17
17
  <% end %>
@@ -3,4 +3,14 @@ require 'app'
3
3
  set :app_file, File.join(root_path, 'app.rb')
4
4
  disable :run
5
5
 
6
- run Sinatra::Application
6
+ FileUtils.mkdir_p 'log' unless File.exists?('log')
7
+ log = File.new("log/#{RACK_ENV.downcase}.log", "a+")
8
+ $stdout.reopen(log)
9
+ $stderr.reopen(log)
10
+
11
+ use Rack::Cache,
12
+ :verbose => true,
13
+ :metastore => "file:#{root_path('cache-rack', 'meta')}",
14
+ :entitystore => "file:#{root_path('cache-rack', 'body')}"
15
+
16
+ run Sinatra::Application
@@ -0,0 +1,11 @@
1
+ RACK_ENV = ENV["RACK_ENV"] ||= "staging" unless defined? RACK_ENV
2
+ require 'app'
3
+ set :app_file, File.join(root_path, 'app.rb')
4
+ disable :run
5
+
6
+ FileUtils.mkdir_p 'log' unless File.exists?('log')
7
+ log = File.new("log/#{RACK_ENV.downcase}.log", "a+")
8
+ $stdout.reopen(log)
9
+ $stderr.reopen(log)
10
+
11
+ run Sinatra::Application
@@ -5,11 +5,13 @@ require 'useful/shoulda_macros/test_unit'
5
5
  require 'rack/test'
6
6
  require 'webrat'
7
7
 
8
+ ROOT_DIR = File.expand_path("#{File.dirname(__FILE__)}/..")
9
+ $LOAD_PATH.unshift(ROOT_DIR)
10
+ $LOAD_PATH.unshift(File.join(ROOT_DIR, 'test'))
11
+
8
12
  RACK_ENV = "test"
9
13
  require 'app'
10
14
 
11
- $LOAD_PATH.unshift(File.dirname(__FILE__))
12
-
13
15
  class Test::Unit::TestCase
14
16
  include Rack::Test::Methods
15
17
  include Webrat::Methods
@@ -18,5 +20,5 @@ class Test::Unit::TestCase
18
20
  Webrat.configure do |config|
19
21
  config.mode = :rack
20
22
  end
21
-
23
+
22
24
  end
@@ -4,15 +4,18 @@ module SinatraHelpers::Generator
4
4
 
5
5
  TEMPLATE = {
6
6
  'app.rb.erb' => 'app.rb',
7
+ 'config.ru.erb' => 'config.ru',
7
8
  'Capfile.erb' => 'Capfile',
8
9
  'Rakefile.erb' => 'Rakefile',
9
10
  'gitignore.erb' => '.gitignore',
10
11
 
11
12
  :admin => {
12
- 'production.ru.erb' => 'production.ru'
13
+ 'production.ru.erb' => 'production.ru',
14
+ 'staging.ru.erb' => 'staging.ru'
13
15
  },
14
16
 
15
17
  :app => {
18
+ 'base.rb.erb' => 'base.rb',
16
19
  :helpers => {},
17
20
  :models => {},
18
21
  :views => {
@@ -29,7 +32,6 @@ module SinatraHelpers::Generator
29
32
  },
30
33
 
31
34
  :config => {
32
- 'boot.rb.erb' => 'boot.rb',
33
35
  'deploy.rb.erb' => 'deploy.rb',
34
36
  :deploy => {
35
37
  'deploy_production.rb.erb' => 'production.rb',
@@ -38,10 +40,14 @@ module SinatraHelpers::Generator
38
40
  'env.rb.erb' => 'env.rb',
39
41
  :envs => {
40
42
  'env_development.rb.erb' => 'development.rb',
41
- 'env_test.rb.erb' => 'test.rb',
42
- 'env_production.rb.erb' => 'production.rb'
43
+ 'env_production.rb.erb' => 'production.rb',
44
+ 'env_staging.rb.erb' => 'staging.rb',
45
+ 'env_test.rb.erb' => 'test.rb'
43
46
  },
44
- 'gems.rb.erb' => 'gems.rb'
47
+ 'gems.rb.erb' => 'gems.rb',
48
+ :initializers => {
49
+ 'init.rb.erb' => 'init.rb'
50
+ }
45
51
  },
46
52
 
47
53
  :log => {},
@@ -51,8 +57,7 @@ module SinatraHelpers::Generator
51
57
  },
52
58
 
53
59
  :script => {
54
- 'console.erb' => 'console',
55
- 'server.erb' => 'server'
60
+ 'console.erb' => 'console'
56
61
  },
57
62
 
58
63
  :test => {
@@ -2,8 +2,8 @@ module SinatraHelpers
2
2
  module Version
3
3
 
4
4
  MAJOR = 0
5
- MINOR = 1
6
- TINY = 10
5
+ MINOR = 2
6
+ TINY = 0
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 10
9
- version: 0.1.10
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kelly Redding
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-25 00:00:00 -06:00
17
+ date: 2010-03-07 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -106,8 +106,9 @@ files:
106
106
  - lib/sinatra_helpers/generator/file_templates/app.js.erb
107
107
  - lib/sinatra_helpers/generator/file_templates/app.less.erb
108
108
  - lib/sinatra_helpers/generator/file_templates/app.rb.erb
109
- - lib/sinatra_helpers/generator/file_templates/boot.rb.erb
109
+ - lib/sinatra_helpers/generator/file_templates/base.rb.erb
110
110
  - lib/sinatra_helpers/generator/file_templates/Capfile.erb
111
+ - lib/sinatra_helpers/generator/file_templates/config.ru.erb
111
112
  - lib/sinatra_helpers/generator/file_templates/console.erb
112
113
  - lib/sinatra_helpers/generator/file_templates/deploy.rb.erb
113
114
  - lib/sinatra_helpers/generator/file_templates/deploy_production.rb.erb
@@ -115,17 +116,19 @@ files:
115
116
  - lib/sinatra_helpers/generator/file_templates/env.rb.erb
116
117
  - lib/sinatra_helpers/generator/file_templates/env_development.rb.erb
117
118
  - lib/sinatra_helpers/generator/file_templates/env_production.rb.erb
119
+ - lib/sinatra_helpers/generator/file_templates/env_staging.rb.erb
118
120
  - lib/sinatra_helpers/generator/file_templates/env_test.rb.erb
119
121
  - lib/sinatra_helpers/generator/file_templates/gems.rb.erb
120
122
  - lib/sinatra_helpers/generator/file_templates/gitignore.erb
121
123
  - lib/sinatra_helpers/generator/file_templates/index.html.erb.erb
124
+ - lib/sinatra_helpers/generator/file_templates/init.rb.erb
122
125
  - lib/sinatra_helpers/generator/file_templates/layout
123
126
  - lib/sinatra_helpers/generator/file_templates/layout_test.rb.erb
124
127
  - lib/sinatra_helpers/generator/file_templates/model_test.rb.erb
125
128
  - lib/sinatra_helpers/generator/file_templates/production.ru.erb
126
129
  - lib/sinatra_helpers/generator/file_templates/Rakefile.erb
127
130
  - lib/sinatra_helpers/generator/file_templates/reset.less.erb
128
- - lib/sinatra_helpers/generator/file_templates/server.erb
131
+ - lib/sinatra_helpers/generator/file_templates/staging.ru.erb
129
132
  - lib/sinatra_helpers/generator/file_templates/test_helper.rb.erb
130
133
  - lib/sinatra_helpers/generator/template.rb
131
134
  - lib/sinatra_helpers/generator.rb
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- platform_ruby = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'ruby.bat' : 'ruby'
4
-
5
- require 'rubygems'
6
- require 'sinatra/base'
7
-
8
- puts "Loading default environment (Sinatra #{Sinatra::VERSION})"
9
- exec "#{platform_ruby} app.rb"