Skip to content

Commit

Permalink
config files
Browse files Browse the repository at this point in the history
  • Loading branch information
matchy committed Nov 20, 2015
1 parent c55a0a1 commit c38c81a
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -40,10 +40,9 @@
*.rbc

/.bundle
/Gemfile.lock

/Gemfile.local

/config/nginx.conf
/Capfile


223 changes: 223 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,223 @@
GIT
remote: git://github.com/capistrano/rvm.git
revision: 9cfef39cf0022839dca6b5b330dfefeb5fc363e7
specs:
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)

GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.4)
actionview (= 4.2.4)
activesupport (= 4.2.4)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.1.1)
actionpack (>= 4.0.0, < 5.0)
actionpack-xml_parser (1.0.2)
actionpack (>= 4.0.0, < 5)
actionview (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4)
activesupport (= 4.2.4)
globalid (>= 0.3.0)
activemodel (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
activerecord (4.2.4)
activemodel (= 4.2.4)
activesupport (= 4.2.4)
arel (~> 6.0)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.8)
arel (6.0.3)
builder (3.2.2)
capistrano (3.2.1)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.5)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capybara (2.5.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.5.8)
ffi (~> 1.0, >= 1.0.11)
coderay (1.1.0)
colorize (0.7.7)
css_parser (1.3.7)
addressable
docile (1.1.5)
erubis (2.7.0)
ffi (1.9.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
htmlentities (4.3.1)
i18n (0.7.0)
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.8.3)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.11.2)
mysql2 (0.3.20)
net-ldap (0.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.0.1)
nokogiri (1.6.6.3)
mini_portile (~> 0.6.0)
protected_attributes (1.1.3)
activemodel (>= 4.0.1, < 5.0)
rack (1.6.4)
rack-openid (1.4.2)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.4)
actionmailer (= 4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
activemodel (= 4.2.4)
activerecord (= 4.2.4)
activesupport (= 4.2.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.4)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.4)
actionpack (= 4.2.4)
activesupport (= 4.2.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rbpdf (1.18.7)
htmlentities (= 4.3.1)
rdoc (4.2.0)
redcarpet (3.3.3)
request_store (1.0.5)
rmagick (2.15.4)
roadie (3.1.0)
css_parser (~> 1.3.4)
nokogiri (>= 1.5.0, < 1.7.0)
roadie-rails (1.1.0)
railties (>= 3.0, < 4.3)
roadie (~> 3.1)
ruby-openid (2.3.0)
rubyzip (1.1.7)
selenium-webdriver (2.48.1)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0)
simplecov (0.9.2)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
sprockets (3.4.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
websocket (1.2.2)
xpath (2.0.0)
nokogiri (~> 1.3)
yard (0.8.7.6)

PLATFORMS
ruby

DEPENDENCIES
actionpack-action_caching
actionpack-xml_parser
activerecord-jdbc-adapter (~> 1.3.2)
activerecord-jdbcmysql-adapter
activerecord-jdbcsqlite3-adapter
builder (>= 3.0.4)
capistrano (= 3.2.1)
capistrano-bundler (~> 1.1.3)
capistrano-rails (~> 1.1.1)
capistrano-rvm!
capybara
coderay (~> 1.1.0)
jdbc-sqlite3 (>= 3.8.10.1)
jquery-rails (~> 3.1.4)
mime-types
minitest
mocha
mysql2 (~> 0.3.11)
net-ldap (~> 0.12.0)
protected_attributes
rack-openid
rails (= 4.2.4)
rails-dom-testing
rbpdf (~> 1.18.7)
rdoc (>= 2.4.2)
redcarpet (~> 3.3.2)
request_store (= 1.0.5)
rmagick (>= 2.14.0)
roadie-rails
ruby-openid (~> 2.3.0)
selenium-webdriver
simplecov (~> 0.9.1)
sqlite3
tzinfo-data
yard

BUNDLED WITH
1.10.6
7 changes: 7 additions & 0 deletions lib/capistrano/substitude_strings.rb
@@ -0,0 +1,7 @@
def sub_strings(input_string)
output_string = input_string
input_string.scan(/{{(\w*)}}/).each do |var|
output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
end
output_string
end
File renamed without changes.
Expand Up @@ -2,7 +2,8 @@ namespace :deploy do
task :setup_config do
on roles(:app) do
# make the config dir
execute :mkdir, "-p #{shared_path}/config"
puts "hello"
#execute :mkdir, "-p #{shared_path}/config"
full_app_name = fetch(:full_app_name)

# config files to be uploaded to shared/config, see the
Expand All @@ -13,7 +14,7 @@ namespace :deploy do
# set in the stage files
config_files = fetch(:config_files)
config_files.each do |file|
smart_template file
normal_template file
end

# # which of the above files should be marked as executable
Expand All @@ -23,11 +24,11 @@ namespace :deploy do
# end

# symlink stuff which should be... symlinked
symlinks = fetch(:symlinks)

symlinks.each do |symlink|
sudo "ln -nfs #{shared_path}/config/#{symlink[:source]} #{sub_strings(symlink[:link])}"
end
# symlinks = fetch(:symlinks)
#
# symlinks.each do |symlink|
# sudo "ln -nfs #{shared_path}/config/#{symlink[:source]} #{sub_strings(symlink[:link])}"
# end
end
end
end
27 changes: 27 additions & 0 deletions lib/capistrano/template.rb
@@ -0,0 +1,27 @@
def smart_template(from, to=nil)
to ||= from
full_to_path = "#{shared_path}/config/#{to}"
if from_erb_path = template_file(from)
from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding))
upload! from_erb, full_to_path
info "copying: #{from_erb} to: #{full_to_path}"
else
error "error #{from} not found"
end
end

def normal_template(file_name)
from_path = "config/#{file_name}"
full_to_path = "#{shared_path}/config/#{file_name}"
upload! from_path, full_to_path
info "copying: #{from_path} to: #{full_to_path}"
end

def template_file(name)
if File.exist?((file = "config/deploy/#{fetch(:full_app_name)}/#{name}.erb"))
return file
elsif File.exist?((file = "config/deploy/shared/#{name}.erb"))
return file
end
return nil
end

0 comments on commit c38c81a

Please sign in to comment.