capobvious 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/capobvious ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require 'optparse'
5
+ require 'fileutils'
6
+
7
+ OptionParser.new do |opts|
8
+ opts.banner = "Usage: #{File.basename($0)} [path]"
9
+
10
+ opts.on("-h", "--help", "Displays this help info") do
11
+ puts opts
12
+ exit 0
13
+ end
14
+
15
+ begin
16
+ opts.parse!(ARGV)
17
+ rescue OptionParser::ParseError => e
18
+ warn e.message
19
+ puts opts
20
+ exit 1
21
+ end
22
+ end
23
+
24
+ if ARGV.empty?
25
+ abort "Please specify the directory to capify, e.g. `#{File.basename($0)} .'"
26
+ elsif !File.exists?(ARGV.first)
27
+ abort "`#{ARGV.first}' does not exist."
28
+ elsif !File.directory?(ARGV.first)
29
+ abort "`#{ARGV.first}' is not a directory."
30
+ elsif ARGV.length > 1
31
+ abort "Too many arguments; please specify only the directory to capify."
32
+ end
33
+
34
+ def unindent(string)
35
+ indentation = string[/\A\s*/]
36
+ string.strip.gsub(/^#{indentation}/, "")
37
+ end
38
+
39
+ files = {
40
+ "Capfile" => <<FILE,
41
+ load 'deploy'
42
+ Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
43
+ load 'config/deploy' # remove this line to skip loading any of the default tasks
44
+ require 'capistrano/ext/capobvious'
45
+ FILE
46
+
47
+ "config/deploy.rb" => <<FILE
48
+ # -*- encoding : utf-8 -*-
49
+ set :rvm_ruby_string, '1.9.3'
50
+ set :application, "appname"
51
+ set :user, "USER_NAME_HERE"
52
+ set :serv, "IP_ADDRESS_HERE"
53
+
54
+ set :repository, "REPOSITORY_HERE"
55
+ set :server_name, "example.com"
56
+ set :server_redirect, "www.example.com"
57
+
58
+ set :assets, true
59
+ set :backup_db, false
60
+ set :backup_sys, false
61
+ set :auto_migrate, true
62
+
63
+
64
+ role :app, serv
65
+ role :web, serv
66
+ role :db, serv, :primary => true
67
+ FILE
68
+ }
69
+
70
+ base = ARGV.shift
71
+ files.each do |file, content|
72
+ file = File.join(base, file)
73
+ if File.exists?(file)
74
+ warn "[skip] '#{file}' already exists"
75
+ elsif File.exists?(file.downcase)
76
+ warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
77
+ else
78
+ unless File.exists?(File.dirname(file))
79
+ puts "[add] making directory '#{File.dirname(file)}'"
80
+ FileUtils.mkdir(File.dirname(file))
81
+ end
82
+ puts "[add] writing '#{file}'"
83
+ File.open(file, "w") { |f| f.write(content) }
84
+ end
85
+ end
86
+
87
+ puts "[done] capified!"
data/capobvious.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- VERSION = "0.0.6"
3
+ require "capobvious/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "capobvious"
7
- s.version = VERSION
7
+ s.version = Capobvious::VERSION
8
8
  s.authors = ["Dmitry Gruzd"]
9
9
  s.email = ["donotsendhere@gmail.com"]
10
10
  s.homepage = ""
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.add_dependency "capistrano"
22
+
21
23
  # specify any dependencies here; for example:
22
24
  # s.add_development_dependency "rspec"
23
25
  # s.add_runtime_dependency "rest-client"
@@ -8,12 +8,14 @@ set :rvm_type, :user
8
8
  default_run_options[:pty] = true
9
9
  ssh_options[:forward_agent] = true
10
10
 
11
- unless exists?(:rails_env)
12
- set :rails_env, "production"
13
- end
14
- unless exists?(:dbconf)
15
- set :dbconf, "database.yml"
16
- end
11
+ set :rails_env, "production" unless exists?(:rails_env)
12
+ set :branch, "master" unless exists?(:branch)
13
+ set :dbconf, "database.yml" unless exists?(:dbconf)
14
+ set :deploy_to, "/home/#{user}/www/#{application}" unless exists?(:deploy_to)
15
+ set :deploy_via, :remote_cache unless exists?(:deploy_via)
16
+ set :keep_releases, 5 unless exists?(:keep_releases)
17
+ set :use_sudo, false unless exists?(:use_sudo)
18
+ set :scm, :git unless exists?(:scm)
17
19
 
18
20
  if `uname -a`.include?("Darwin")
19
21
  run_local_psql = "psql -h localhost -U postgres"
@@ -88,8 +90,12 @@ end
88
90
 
89
91
  namespace :db do
90
92
  task :create do
93
+ if adapter == "postgresql"
91
94
  run "echo \"create user #{db_username} with password '#{db_password}';\" | #{sudo} -u postgres psql"
92
95
  run "echo \"create database #{database} owner #{db_username};\" | #{sudo} -u postgres psql"
96
+ else
97
+ puts "Cannot create, adapter #{adapter} is not implemented yet"
98
+ end
93
99
  end
94
100
  task :seed do
95
101
  run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} db:seed"
@@ -108,7 +114,7 @@ namespace :db do
108
114
  system "echo \"create database #{local_database} owner #{local_db_username};\" | #{run_local_psql}"
109
115
  # system "#{run_local_psql} #{local_database} < #{local_folder_path}/#{db_file_name}"
110
116
  puts "ENTER your development password: #{local_db_password}"
111
- system "psql -U#{local_db_username} #{local_database} < #{local_folder_path}/#{db_file_name}"
117
+ system "#{run_local_psql} -U#{local_db_username} #{local_database} < #{local_folder_path}/#{db_file_name}"
112
118
  system "rm #{local_folder_path}/#{db_file_name}"
113
119
  end
114
120
  task :pg_import do
@@ -206,6 +212,20 @@ namespace :nginx do
206
212
  listen 80;
207
213
  server_name #{server_name};
208
214
  root #{current_path}/public;
215
+ # location ~ ^/assets/ {
216
+ # expires 1y;
217
+ # add_header Cache-Control public;
218
+ # add_header ETag "";
219
+ # break;
220
+ # }
221
+
222
+ location ~ ^/(assets)/ {
223
+ root #{current_path}/public;
224
+ gzip_static on; # to serve pre-gzipped version
225
+ expires max;
226
+ add_header Cache-Control public;
227
+ }
228
+
209
229
  location / {
210
230
  try_files $uri @unicorn;
211
231
  }
@@ -0,0 +1,3 @@
1
+ module Capobvious
2
+ VERSION = "0.0.7"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capobvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-29 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &70265208585520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70265208585520
14
25
  description: Capfile that we use every day
15
26
  email:
16
27
  - donotsendhere@gmail.com
17
- executables: []
28
+ executables:
29
+ - capobvious
18
30
  extensions: []
19
31
  extra_rdoc_files: []
20
32
  files:
@@ -22,8 +34,10 @@ files:
22
34
  - Gemfile
23
35
  - README.markdown
24
36
  - Rakefile
37
+ - bin/capobvious
25
38
  - capobvious.gemspec
26
39
  - lib/capistrano/ext/capobvious.rb
40
+ - lib/capobvious/version.rb
27
41
  homepage: ''
28
42
  licenses: []
29
43
  post_install_message:
@@ -44,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
58
  version: '0'
45
59
  requirements: []
46
60
  rubyforge_project: capobvious
47
- rubygems_version: 1.8.17
61
+ rubygems_version: 1.8.15
48
62
  signing_key:
49
63
  specification_version: 3
50
64
  summary: Cap recipes