pulsar 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +3 -0
  3. data/.rubocop.yml +5 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +4 -1
  6. data/README.md +4 -4
  7. data/Rakefile +3 -3
  8. data/lib/pulsar.rb +9 -8
  9. data/lib/pulsar/commands/all.rb +4 -4
  10. data/lib/pulsar/commands/init.rb +7 -5
  11. data/lib/pulsar/commands/main.rb +43 -32
  12. data/lib/pulsar/commands/utils.rb +7 -3
  13. data/lib/pulsar/generators/init_repo/apps/your_app/defaults.rb +1 -1
  14. data/lib/pulsar/generators/init_repo/apps/your_app/production.rb +2 -2
  15. data/lib/pulsar/generators/init_repo/apps/your_app/staging.rb +2 -2
  16. data/lib/pulsar/generators/init_repo/recipes/generic/cleanup.rb +9 -9
  17. data/lib/pulsar/generators/init_repo/recipes/generic/utils.rb +6 -3
  18. data/lib/pulsar/helpers/all.rb +7 -5
  19. data/lib/pulsar/helpers/capistrano.rb +4 -4
  20. data/lib/pulsar/helpers/clamp.rb +32 -33
  21. data/lib/pulsar/helpers/path.rb +15 -2
  22. data/lib/pulsar/helpers/shell.rb +3 -3
  23. data/lib/pulsar/options/all.rb +5 -3
  24. data/lib/pulsar/options/conf_repo.rb +17 -16
  25. data/lib/pulsar/options/shared.rb +3 -2
  26. data/lib/pulsar/version.rb +1 -1
  27. data/pulsar.gemspec +17 -17
  28. data/spec/pulsar/commands/init_spec.rb +4 -3
  29. data/spec/pulsar/commands/list_spec.rb +63 -47
  30. data/spec/pulsar/commands/main_spec.rb +175 -125
  31. data/spec/pulsar/commands/utils_spec.rb +13 -13
  32. data/spec/pulsar/helpers/capistrano_spec.rb +37 -31
  33. data/spec/pulsar/helpers/clamp_spec.rb +68 -37
  34. data/spec/pulsar/helpers/shell_spec.rb +3 -3
  35. data/spec/spec_helper.rb +12 -11
  36. data/spec/support/dummies/dummy_conf/Gemfile +1 -1
  37. data/spec/support/dummies/dummy_conf/apps/base.rb +5 -5
  38. data/spec/support/dummies/dummy_conf/apps/dummy_app/custom_stage.rb +2 -2
  39. data/spec/support/dummies/dummy_conf/apps/dummy_app/defaults.rb +1 -1
  40. data/spec/support/dummies/dummy_conf/apps/dummy_app/production.rb +2 -2
  41. data/spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb +2 -2
  42. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/custom_stage.rb +2 -2
  43. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb +1 -1
  44. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb +2 -2
  45. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb +2 -2
  46. data/spec/support/modules/helpers.rb +40 -35
  47. metadata +20 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65bfc17e611312457af55a59e849357acf7fc6e5
4
- data.tar.gz: 4af24027523427551bc5bcdc26dd00134abb3bdd
3
+ metadata.gz: 85ff94bd2e09cdb4b78e52f893e1325e57040096
4
+ data.tar.gz: 6a9555c19b9dd1a2fac4da55d898cc508ef802c3
5
5
  SHA512:
6
- metadata.gz: cf819b8a1a90e5b9c45c453eea30d1d4b1c7d52edc9bc661200daed1ecb5ef88394306d033a3a49e2609d560c545554c534aaf67c4f8ebd2edffd6d9a6186e8d
7
- data.tar.gz: cd80a5a0bbd1d325eb9fd8586dc21434c0ef104aa3f5801c0aee494f4c9945c36e3ca758240f5d9ec3f59a7fba5dad6c69c41dd04921b5ec59c288adb8470236
6
+ metadata.gz: b192211345aeee06d45a10c4123e5294af7baf776bdde2c0a1772f7dc6fc41060c8592671cf10b400d9bee79a4876a61f616252a55ee08400b6a318ee9260086
7
+ data.tar.gz: a3acf3cea61a0431d419cc92781515695ed92d183cb1f3bef408ff46268e982bc6122f11b2e29b0e5429a9e6562c053a8a152788de153f9a0409a9ac1507fac2
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ enabled: true
3
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/SpecialGlobalVars:
5
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.0
data/.travis.yml CHANGED
@@ -8,7 +8,10 @@ notifications:
8
8
  branches:
9
9
  only:
10
10
  - master
11
+ env:
12
+ - CODECLIMATE_REPO_TOKEN=e2ce951cfe49257f658e6bd61d1cabe61648328c87a3f1a0908c4e4b3d9b2e7e
11
13
  rvm:
12
14
  - 1.9.3
13
15
  - 2.0.0
14
- - 2.1.2
16
+ - 2.1.3
17
+ - 2.2.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pulsar [![Gem Version](https://badge.fury.io/rb/pulsar.png)](http://badge.fury.io/rb/pulsar) [![Build Status](https://secure.travis-ci.org/nebulab/pulsar.png?branch=master)](http://travis-ci.org/nebulab/pulsar) [![Coverage Status](https://coveralls.io/repos/nebulab/pulsar/badge.png?branch=master)](https://coveralls.io/r/nebulab/pulsar) [![Code Climate](https://codeclimate.com/github/nebulab/pulsar.png)](https://codeclimate.com/github/nebulab/pulsar)
1
+ # Pulsar [![Gem Version](https://badge.fury.io/rb/pulsar.svg)](http://badge.fury.io/rb/pulsar) [![Build Status](https://travis-ci.org/nebulab/pulsar.svg?branch=master)](https://travis-ci.org/nebulab/pulsar) [![Test Coverage](https://codeclimate.com/github/nebulab/pulsar/badges/coverage.svg)](https://codeclimate.com/github/nebulab/pulsar) [![Code Climate](https://codeclimate.com/github/nebulab/pulsar/badges/gpa.svg)](https://codeclimate.com/github/nebulab/pulsar)
2
2
 
3
3
  The easy [Capistrano](https://rubygems.org/gems/capistrano) deploy and configuration manager.
4
4
 
@@ -164,13 +164,13 @@ You have three possibilities:
164
164
 
165
165
  * `-c` command line option
166
166
  * `PULSAR_CONF_REPO` environment variable
167
- * `~/.pulsar` configuration file
167
+ * `~/.pulsar/config` configuration file
168
168
 
169
- The fastest way is probably the `.pulsar` hidden file inside your home directory:
169
+ The fastest way is probably the `.pulsar/config` file inside your home directory:
170
170
 
171
171
  ```bash
172
172
  #
173
- # Inside ~/.pulsar
173
+ # Inside ~/.pulsar/config
174
174
  #
175
175
  PULSAR_CONF_REPO="gh-user/pulsar-conf"
176
176
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- task "default" => "spec"
4
+ task 'default' => 'spec'
5
5
 
6
6
  RSpec::Core::RakeTask.new do |t|
7
7
  t.pattern = 'spec/**/*_spec.rb'
data/lib/pulsar.rb CHANGED
@@ -1,11 +1,12 @@
1
- require "pulsar/version"
1
+ require 'pulsar/version'
2
2
 
3
3
  module Pulsar
4
- require "clamp"
5
- require "bundler"
6
- require "colored"
7
- require "shellwords"
8
- require "pulsar/helpers/all"
9
- require "pulsar/options/all"
10
- require "pulsar/commands/all"
4
+ require 'clamp'
5
+ require 'bundler'
6
+ require 'colored'
7
+ require 'shellwords'
8
+ require 'tmpdir'
9
+ require 'pulsar/helpers/all'
10
+ require 'pulsar/options/all'
11
+ require 'pulsar/commands/all'
11
12
  end
@@ -1,6 +1,6 @@
1
1
  module Pulsar
2
- autoload :MainCommand, "pulsar/commands/main"
3
- autoload :UtilsCommand, "pulsar/commands/utils"
4
- autoload :ListCommand, "pulsar/commands/list"
5
- autoload :InitCommand, "pulsar/commands/init"
2
+ autoload :MainCommand, 'pulsar/commands/main'
3
+ autoload :UtilsCommand, 'pulsar/commands/utils'
4
+ autoload :ListCommand, 'pulsar/commands/list'
5
+ autoload :InitCommand, 'pulsar/commands/init'
6
6
  end
@@ -1,6 +1,7 @@
1
1
  module Pulsar
2
2
  class InitCommand < UtilsCommand
3
- parameter "CONFIGURATION_PATH", "where to generate your configuration repository"
3
+ parameter 'CONFIGURATION_PATH',
4
+ 'where to generate your configuration repository'
4
5
 
5
6
  def execute
6
7
  with_clean_env_and_supported_vars do
@@ -9,12 +10,13 @@ module Pulsar
9
10
  pulsar_cmd_path = File.expand_path(File.dirname(__FILE__))
10
11
  init_repo_path = "#{pulsar_cmd_path}/../generators/init_repo"
11
12
 
12
- init_repo_path += "/*" if File.directory?(destination_path)
13
+ init_repo_path += '/*' if File.directory?(destination_path)
13
14
 
14
- run_cmd("cp -r #{init_repo_path} #{destination_path}", :verbose => verbose?)
15
+ run_cmd(
16
+ "cp -r #{init_repo_path} #{destination_path}", verbose: verbose?)
15
17
 
16
- puts "Your starter configuration repo is in #{destination_path.yellow}."
17
- puts "Remember to run #{ "bundle install".red } to add the needed Gemfile.lock."
18
+ puts 'Your starter configuration repo is in #{destination_path.yellow}.'
19
+ puts "Remember to run #{'bundle install'.red} to add a Gemfile.lock."
18
20
  end
19
21
  end
20
22
  end
@@ -4,50 +4,61 @@ module Pulsar
4
4
  include Pulsar::Options::Shared
5
5
  include Pulsar::Options::ConfRepo
6
6
 
7
- option [ "-l", "--log-level" ], "LOG LEVEL",
8
- "how much output will Capistrano print out. Can be any of: important, info, debug, trace",
9
- :default => "important"
7
+ option ['-l', '--log-level'], 'LOG LEVEL',
8
+ 'how much output will Capistrano print out. Can be any of: important, info, debug, trace',
9
+ default: 'important'
10
10
 
11
- option [ "-s", "--skip-cap-run" ], :flag,
12
- "do everything pulsar does (build a Capfile) but don't run the cap command",
13
- :default => false
11
+ option ['-s', '--skip-cap-run'], :flag,
12
+ 'do everything pulsar does (build a Capfile) but don\'t run the cap command',
13
+ default: false
14
14
 
15
- if !from_application_path?
16
- parameter "APPLICATIONS", "the applications which you would like to deploy. You can pass just one or a comma separated list to deploy multiple applications at once. It supports globbing too."
15
+ unless from_application_path?
16
+ parameter 'APPLICATIONS', 'the applications which you would like to deploy. You can pass just one or a comma separated list to deploy multiple applications at once. It supports globbing too.'
17
17
  end
18
18
 
19
- parameter "STAGE", "the stage on which you would like to deploy"
19
+ parameter 'STAGE', 'the stage on which you would like to deploy'
20
20
 
21
- parameter "[TASKS] ...",
22
- "the arguments and/or options that will be passed to capistrano",
23
- :environment_variable => "PULSAR_DEFAULT_TASK",
24
- :default => "deploy"
21
+ parameter '[TASKS] ...',
22
+ 'the arguments and/or options that will be passed to capistrano',
23
+ environment_variable: 'PULSAR_DEFAULT_TASK',
24
+ default: 'deploy'
25
25
 
26
26
  def execute
27
27
  with_clean_env_and_supported_vars do
28
28
  begin
29
- create_tmp_dir
30
- fetch_repo
31
- bundle_install
32
-
33
- expand_applications.each do |app|
34
- validate(app, stage)
35
- create_capfile
36
- build_capfile(app, stage)
37
-
38
- unless skip_cap_run?
39
- cap_args = [ tasks_list ].flatten.shelljoin
40
- run_capistrano(cap_args)
41
- end
42
-
43
- remove_capfile unless keep_capfile?
44
- reset_capfile_path!
45
- end
29
+ fetch_repo_and_bundle
30
+ expand_applications.each { |app| validate_and_run_capistrano(app) }
46
31
  ensure
47
- remove_capfile unless keep_capfile?
48
- remove_repo unless keep_repo?
32
+ cleanup
49
33
  end
50
34
  end
51
35
  end
36
+
37
+ private
38
+
39
+ def cleanup(opts = { full: true })
40
+ remove_capfile unless keep_capfile?
41
+ reset_capfile_path!
42
+ remove_repo if opts[:full] && !keep_repo?
43
+ end
44
+
45
+ def fetch_repo_and_bundle
46
+ create_tmp_dir
47
+ fetch_repo
48
+ bundle_install
49
+ end
50
+
51
+ def validate_and_run_capistrano(app)
52
+ validate(app, stage)
53
+ create_capfile
54
+ build_capfile(app, stage)
55
+
56
+ unless skip_cap_run?
57
+ cap_args = [tasks_list].flatten.shelljoin
58
+ run_capistrano(cap_args)
59
+ end
60
+
61
+ cleanup(full: false)
62
+ end
52
63
  end
53
64
  end
@@ -3,8 +3,12 @@ module Pulsar
3
3
  include Pulsar::Helpers::Clamp
4
4
  include Pulsar::Options::Shared
5
5
 
6
- subcommand "list", "list all available apps and stages which you can deploy", ListCommand
7
- subcommand "init", "generate a new configuration repo with some basic recipes to use with pulsar", InitCommand
6
+ subcommand 'list',
7
+ 'list all available apps and stages which you can deploy',
8
+ ListCommand
9
+
10
+ subcommand 'init',
11
+ 'generate a new configuration repo with some basic recipes to use with pulsar',
12
+ InitCommand
8
13
  end
9
14
  end
10
-
@@ -1,4 +1,4 @@
1
- set :application, "your_app"
1
+ set :application, 'your_app'
2
2
 
3
3
  load_recipes do
4
4
  #
@@ -1,6 +1,6 @@
1
- server "your_app.com", :db, :web, :app, :primary => true
1
+ server 'your_app.com', :db, :web, :app, primary: true
2
2
 
3
- set :stage, "production"
3
+ set :stage, 'production'
4
4
 
5
5
  load_recipes do
6
6
  #
@@ -1,6 +1,6 @@
1
- server "staging.your_app.com", :db, :web, :app, :primary => true
1
+ server 'staging.your_app.com', :db, :web, :app, primary: true
2
2
 
3
- set :stage, "staging"
3
+ set :stage, 'staging'
4
4
 
5
5
  load_recipes do
6
6
  #
@@ -1,50 +1,50 @@
1
1
  if logger.level == Capistrano::Logger::IMPORTANT
2
- arrow = "".yellow.bold
3
- ok = "".green
2
+ arrow = ''.yellow.bold
3
+ ok = ''.green
4
4
 
5
- before "deploy:update_code" do
5
+ before 'deploy:update_code' do
6
6
  SpinningCursor.start do
7
7
  banner "#{arrow} Updating Code"
8
8
  message "#{arrow} Updating Code #{ok}"
9
9
  end
10
10
  end
11
11
 
12
- before "bundle:install" do
12
+ before 'bundle:install' do
13
13
  SpinningCursor.start do
14
14
  banner "#{arrow} Installing Gems"
15
15
  message "#{arrow} Installing Gems #{ok}"
16
16
  end
17
17
  end
18
18
 
19
- before "deploy:assets:symlink" do
19
+ before 'deploy:assets:symlink' do
20
20
  SpinningCursor.start do
21
21
  banner "#{arrow} Symlinking Assets"
22
22
  message "#{arrow} Symlinking Assets #{ok}"
23
23
  end
24
24
  end
25
25
 
26
- before "deploy:assets:precompile" do
26
+ before 'deploy:assets:precompile' do
27
27
  SpinningCursor.start do
28
28
  banner "#{arrow} Compiling Assets"
29
29
  message "#{arrow} Compiling Assets #{ok}"
30
30
  end
31
31
  end
32
32
 
33
- before "deploy:create_symlink" do
33
+ before 'deploy:create_symlink' do
34
34
  SpinningCursor.start do
35
35
  banner "#{arrow} Symlinking Application"
36
36
  message "#{arrow} Symlinking Application #{ok}"
37
37
  end
38
38
  end
39
39
 
40
- before "deploy:restart" do
40
+ before 'deploy:restart' do
41
41
  SpinningCursor.start do
42
42
  banner "#{arrow} Restarting Webserver"
43
43
  message "#{arrow} Restarting Webserver #{ok}"
44
44
  end
45
45
  end
46
46
 
47
- after "deploy" do
47
+ after 'deploy' do
48
48
  SpinningCursor.stop
49
49
  end
50
50
  end
@@ -1,6 +1,9 @@
1
1
  namespace :utils do
2
- desc "Invoke your awesome rake tasks!"
3
- task :invoke_rake, :roles => :web do
4
- run("cd #{deploy_to}/current && RAILS_ENV=#{rails_env} #{rake} #{ENV['ARGS']}")
2
+ desc 'Invoke your awesome rake tasks!'
3
+ task :invoke_rake, roles: :web do
4
+ cd = "cd #{deploy_to}/current"
5
+ cmd = "RAILS_ENV=#{rails_env} #{rake} #{ENV['ARGS']}"
6
+
7
+ run("#{cd} && #{cmd}")
5
8
  end
6
9
  end
@@ -1,6 +1,8 @@
1
- module Pulsar::Helpers
2
- autoload :Capistrano, "pulsar/helpers/capistrano"
3
- autoload :Clamp, "pulsar/helpers/clamp"
4
- autoload :Path, "pulsar/helpers/path"
5
- autoload :Shell, "pulsar/helpers/shell"
1
+ module Pulsar
2
+ module Helpers
3
+ autoload :Capistrano, 'pulsar/helpers/capistrano'
4
+ autoload :Clamp, 'pulsar/helpers/clamp'
5
+ autoload :Path, 'pulsar/helpers/path'
6
+ autoload :Shell, 'pulsar/helpers/shell'
7
+ end
6
8
  end
@@ -10,16 +10,16 @@ module Pulsar
10
10
  instance_eval(&dsl_code)
11
11
  end
12
12
 
13
- def method_missing(meth, *args, &block)
13
+ def method_missing(meth, *args)
14
14
  return if !@capistrano.from_application_path? && @options[:app_only]
15
15
 
16
16
  recipes = "#{ENV['CONFIG_PATH']}/recipes/#{meth}"
17
17
 
18
- File.directory?(recipes) || raise("There are no recipes of type #{meth}")
18
+ File.directory?(recipes) || fail("There are no recipes of type #{meth}")
19
19
 
20
20
  args.each do |arg|
21
21
  recipe = "#{recipes}/#{arg}.rb"
22
- File.exists?(recipe) || raise("There is no #{arg} recipe")
22
+ File.exist?(recipe) || fail("There is no #{arg} recipe")
23
23
 
24
24
  @capistrano.send(:load, recipe)
25
25
  end
@@ -36,7 +36,7 @@ module Pulsar
36
36
  # as a variable and error out
37
37
  #
38
38
  def from_application_path?
39
- ENV.has_key?('APP_PATH')
39
+ ENV.key?('APP_PATH')
40
40
  end
41
41
 
42
42
  def load_recipes(opts = {}, &block)
@@ -11,7 +11,7 @@ module Pulsar
11
11
 
12
12
  module InstanceAndClassMethods
13
13
  def from_application_path?
14
- File.exists?("#{Dir.pwd}/config.ru")
14
+ File.exist?("#{Dir.pwd}/config.ru")
15
15
  end
16
16
  end
17
17
 
@@ -33,17 +33,17 @@ module Pulsar
33
33
  end
34
34
 
35
35
  def bundle_install
36
- cd(config_path, :verbose => verbose?) do
37
- run_cmd("bundle install --quiet", :verbose => verbose?)
36
+ cd(config_path, verbose: verbose?) do
37
+ run_cmd("bundle install --quiet --path=#{bundle_path.shellescape}", verbose: verbose?)
38
38
  end
39
39
  end
40
40
 
41
41
  def create_capfile
42
- touch(capfile_path, :verbose => verbose?)
42
+ touch(capfile_path, verbose: verbose?)
43
43
  end
44
44
 
45
45
  def create_tmp_dir
46
- run_cmd("mkdir -p #{tmp_dir}", :verbose => verbose?)
46
+ run_cmd("mkdir -p #{tmp_path.shellescape}", verbose: verbose?)
47
47
  end
48
48
 
49
49
  def each_app
@@ -54,7 +54,7 @@ module Pulsar
54
54
 
55
55
  def expand_applications
56
56
  if from_application_path?
57
- [ ENV['PULSAR_APP_NAME'] || File.basename(application_path) ]
57
+ [ENV['PULSAR_APP_NAME'] || File.basename(application_path)]
58
58
  else
59
59
  #
60
60
  # Given following applications:
@@ -86,14 +86,14 @@ module Pulsar
86
86
  end
87
87
 
88
88
  def fetch_directory_repo(repo)
89
- run_cmd("cp -rp #{repo} #{config_path}", :verbose => verbose?)
89
+ run_cmd("cp -rp #{repo} #{config_path}", verbose: verbose?)
90
90
  end
91
91
 
92
- def fetch_git_repo(repo, local=false)
92
+ def fetch_git_repo(repo, local = false)
93
93
  git_options = "--quiet --branch #{conf_branch}"
94
94
  git_options = "#{git_options} --depth=1" unless local
95
95
 
96
- run_cmd("git clone #{git_options} #{repo} #{config_path}", :verbose => verbose?)
96
+ run_cmd("git clone #{git_options} #{repo} #{config_path}", verbose: verbose?)
97
97
  end
98
98
 
99
99
  def find_apps_from_pattern(glob)
@@ -111,12 +111,12 @@ module Pulsar
111
111
  app_file = config_app_defaults_path(app)
112
112
  stage_file = config_stage_path(app, stage)
113
113
 
114
- if File.exists?(app_file)
115
- run_cmd("cat #{app_file} >> #{capfile_path}", :verbose => verbose?)
114
+ if File.exist?(app_file)
115
+ run_cmd("cat #{app_file} >> #{capfile_path}", verbose: verbose?)
116
116
  end
117
117
 
118
- if File.exists?(stage_file)
119
- run_cmd("cat #{stage_file} >> #{capfile_path}", :verbose => verbose?)
118
+ if File.exist?(stage_file)
119
+ run_cmd("cat #{stage_file} >> #{capfile_path}", verbose: verbose?)
120
120
  end
121
121
  end
122
122
 
@@ -125,12 +125,12 @@ module Pulsar
125
125
  stage_recipes_dir = config_app_stage_recipes_path(app, stage)
126
126
 
127
127
  Dir["#{recipes_dir}/*.rb", "#{stage_recipes_dir}/*.rb"].each do |recipe|
128
- run_cmd("cat #{recipe} >> #{capfile_path}", :verbose => verbose?)
128
+ run_cmd("cat #{recipe} >> #{capfile_path}", verbose: verbose?)
129
129
  end
130
130
  end
131
131
 
132
132
  def include_base_conf
133
- run_cmd("cat #{config_base_path} >> #{capfile_path}", :verbose => verbose?)
133
+ run_cmd("cat #{config_base_path} >> #{capfile_path}", verbose: verbose?)
134
134
  end
135
135
 
136
136
  def list_apps
@@ -140,41 +140,40 @@ module Pulsar
140
140
  end
141
141
 
142
142
  def load_configuration
143
- unless pulsar_configuration.nil?
144
- File.readlines(pulsar_configuration).each do |line|
145
- conf, value = line.split("=")
143
+ return if pulsar_configuration.nil?
146
144
 
147
- ENV[conf] = value.chomp.gsub('"', '') if !conf.nil? && !value.nil?
148
- end
145
+ File.readlines(pulsar_configuration).each do |line|
146
+ conf, value = line.split('=')
147
+
148
+ ENV[conf] = value.chomp.gsub('"', '') if !conf.nil? && !value.nil?
149
149
  end
150
150
  end
151
151
 
152
152
  def pulsar_configuration
153
- conf_file = ".pulsar"
154
- inside_app = File.join(application_path, conf_file) rescue nil
155
- inside_home = File.join(Dir.home, conf_file) rescue nil
153
+ path_list = []
154
+ path_list << File.join(application_path, '.pulsar') unless application_path.nil?
155
+ path_list << File.join(home_path, 'config')
156
156
 
157
- return inside_app if inside_app && File.file?(inside_app)
158
- return inside_home if inside_home && File.file?(inside_home)
157
+ path_list.find { |path| File.file?(path) }
159
158
  end
160
159
 
161
160
  def remove_capfile
162
- rm_rf(capfile_path, :verbose => verbose?)
161
+ rm_rf(capfile_path, verbose: verbose?)
163
162
  end
164
163
 
165
164
  def remove_repo
166
- rm_rf(config_path, :verbose => verbose?)
165
+ rm_rf(config_path, verbose: verbose?)
167
166
  end
168
167
 
169
168
  def run_capistrano(args)
170
- cmd = "bundle exec cap"
169
+ cmd = 'bundle exec cap'
171
170
  env = "CONFIG_PATH=#{config_path}"
172
171
  opts = "--file #{capfile_path}"
173
172
 
174
173
  env += " APP_PATH=#{application_path}" unless application_path.nil?
175
174
 
176
- cd(config_path, :verbose => verbose?) do
177
- run_cmd("#{cmd} #{env} #{opts} #{args}", :verbose => verbose?)
175
+ cd(config_path, verbose: verbose?) do
176
+ run_cmd("#{cmd} #{env} #{opts} #{args}", verbose: verbose?)
178
177
  end
179
178
  end
180
179
 
@@ -186,7 +185,7 @@ module Pulsar
186
185
 
187
186
  cmd = "echo 'logger.level = logger.level = Capistrano::Logger::#{level}' >> #{capfile_path}"
188
187
 
189
- run_cmd(cmd, :verbose => verbose?)
188
+ run_cmd(cmd, verbose: verbose?)
190
189
  end
191
190
 
192
191
  def supported_env_vars
@@ -206,8 +205,8 @@ module Pulsar
206
205
  def validate(app, stage)
207
206
  app_path = config_app_path(app)
208
207
  stage_path = config_stage_path(app, stage)
209
- valid_paths = File.exists?(app_path) && File.exists?(stage_path)
210
- raise(ArgumentError, "no pulsar config available for app=#{app}, stage=#{stage}") unless valid_paths
208
+ valid_paths = File.exist?(app_path) && File.exist?(stage_path)
209
+ fail(ArgumentError, "no pulsar config available for app=#{app}, stage=#{stage}") unless valid_paths
211
210
  end
212
211
 
213
212
  def with_clean_env_and_supported_vars