stairs 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -36
  3. data/.travis.yml +6 -2
  4. data/Guardfile +2 -2
  5. data/Rakefile +4 -4
  6. data/bin/stairs +10 -10
  7. data/lib/stairs.rb +13 -13
  8. data/lib/stairs/env_adapters.rb +6 -6
  9. data/lib/stairs/env_adapters/dotenv.rb +3 -3
  10. data/lib/stairs/env_adapters/rbenv.rb +3 -3
  11. data/lib/stairs/env_adapters/rvm.rb +3 -3
  12. data/lib/stairs/interactive_configuration.rb +11 -11
  13. data/lib/stairs/railtie.rb +1 -1
  14. data/lib/stairs/runner.rb +2 -2
  15. data/lib/stairs/step.rb +20 -17
  16. data/lib/stairs/steps.rb +3 -3
  17. data/lib/stairs/steps/facebook.rb +6 -6
  18. data/lib/stairs/steps/postgresql.rb +11 -11
  19. data/lib/stairs/steps/secret_key_base.rb +4 -4
  20. data/lib/stairs/tasks.rb +2 -2
  21. data/lib/stairs/util.rb +2 -2
  22. data/lib/stairs/util/cli.rb +3 -4
  23. data/lib/stairs/util/file_mutation.rb +10 -10
  24. data/lib/stairs/version.rb +1 -1
  25. data/spec/lib/configuration_spec.rb +8 -8
  26. data/spec/lib/stairs/env_adapters/dotenv_spec.rb +20 -20
  27. data/spec/lib/stairs/env_adapters/rbenv_spec.rb +22 -22
  28. data/spec/lib/stairs/env_adapters/rvm_spec.rb +22 -22
  29. data/spec/lib/stairs/env_adapters_spec.rb +12 -14
  30. data/spec/lib/stairs/interactive_configuration_spec.rb +27 -20
  31. data/spec/lib/stairs/runner_spec.rb +18 -14
  32. data/spec/lib/stairs/script_spec.rb +13 -14
  33. data/spec/lib/stairs/step_spec.rb +225 -189
  34. data/spec/lib/stairs/steps/secret_key_base_spec.rb +7 -5
  35. data/spec/lib/stairs/util/cli_spec.rb +29 -29
  36. data/spec/lib/stairs/util/file_mutation_spec.rb +46 -46
  37. data/spec/spec_helper.rb +6 -8
  38. data/stairs.gemspec +28 -23
  39. metadata +22 -23
  40. data/spec/support/configuration_helper.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad404f4b70626c2817effc44d7f1fc41499e31b7
4
- data.tar.gz: dbd672eeff228973b99ce38f42dabe367716d831
3
+ metadata.gz: 3f7585f6811ddc955a889ce075fa31bc41435a88
4
+ data.tar.gz: c80320f149af4d28ec0d92cf92d8655f5e53f164
5
5
  SHA512:
6
- metadata.gz: e8df3ad6375ce03deade1cb7018c61f1f7980cfc6aaefe94dcb0ea82c3c73a2988064035ac6d83b116232d73830f44daa62abb4eac6444366dd28601a2015ff6
7
- data.tar.gz: 40ab4d5a13cb7d391969f9e632ea4b38311c59e2a095fc71f04bff1a460eb888e550d114b8bdd16cfd3bc5d59051102a5d322b49f5a711325718a47b0c76dd73
6
+ metadata.gz: 405fb108cd9ccb42df1829b31cd0980195818eecda482d67670a2ac36087b3e9652c00bb4b20c1952f48d0f485481bc92b55bc5862015583cd50b32a889d4272
7
+ data.tar.gz: de05b5f9ae3d57cdf3303b999cf14b11766caad3f2568a9d872c403cc3e780fe2c7eded0e463448856a1be34e0643d0f04d8cedcbb5c5d745f8a7507ddbd7461
@@ -1,46 +1,13 @@
1
- StringLiterals:
2
- EnforcedStyle: "double_quotes"
3
-
4
- LineLength:
5
- Max: 80
6
-
7
- # This offends when not tabbed way out while using case in assignment
8
- CaseIndentation:
9
- Enabled: false
10
-
11
- # Not a part of our coding conventions
12
1
  Documentation:
13
2
  Enabled: false
14
3
 
15
4
  DoubleNegation:
16
5
  Enabled: false
17
6
 
18
- TrailingComma:
19
- EnforcedStyleForMultiline: comma
20
-
21
- DeprecatedClassMethods:
22
- Enabled: false
23
-
24
- SingleLineBlockParams:
25
- Enabled: false
26
-
27
- # Also just not something I've ever done or want to do...
28
- SpaceAroundEqualsInParameterDefault:
29
- Enabled: false
30
-
31
- # I don't see why... It's shorthand, just know your ruby!
32
7
  SpecialGlobalVars:
33
8
  Enabled: false
34
9
 
35
- # This was offending for a custom method called `collect` not on an `Enumerable`
36
- CollectionMethods:
37
- Enabled: false
38
-
39
- # Cuz we don't use any fancy characters anyway
40
- Encoding:
41
- Enabled: false
42
-
43
- # I just don't care so much about clean specs.. Like short methods and short lines
44
- AllCops:
10
+ BlockLength:
45
11
  Exclude:
46
- - spec/**
12
+ - "spec/**/*"
13
+ - "stairs.gemspec"
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 1.9.3
3
+ - 2.2.6
4
+ - 2.3.3
5
+ - 2.4.0
6
+ install:
7
+ - gem update --system
8
+ - bundle install --jobs=3 --retry=3
5
9
  addons:
6
10
  code_climate:
7
11
  repo_token: 6b9b2949be0934c1ef9c1b4db4ec1568e616d56c9c493ff470fd70dda0d96a08
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
- guard "rspec" do
1
+ guard 'rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch("spec/spec_helper.rb") { "spec" }
4
+ watch('spec/spec_helper.rb') { 'spec' }
5
5
  end
6
6
 
7
7
  guard :rubocop do
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "rubocop/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
- Rubocop::RakeTask.new
6
+ RuboCop::RakeTask.new
7
7
 
8
8
  task default: [:spec, :rubocop]
data/bin/stairs CHANGED
@@ -1,30 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "optparse"
4
- require "stairs"
3
+ require 'optparse'
4
+ require 'stairs'
5
5
 
6
6
  groups = nil
7
7
 
8
8
  Stairs.configure do |config|
9
9
  OptionParser.new do |options|
10
- options.banner = "Usage: stairs [options]"
10
+ options.banner = 'Usage: stairs [options]'
11
11
 
12
- options.on("--use-defaults", "Use defaults when available") do |value|
12
+ options.on('--use-defaults', 'Use defaults when available') do |value|
13
13
  config.use_defaults = value
14
14
  end
15
15
 
16
16
  options.on(
17
- "-g",
18
- "--groups GROUPS",
19
- "Specify groups to run. e.g. init,reset",
17
+ '-g',
18
+ '--groups GROUPS',
19
+ 'Specify groups to run. e.g. init,reset'
20
20
  ) do |value|
21
- groups = value.split(",").map { |g| g.to_sym } if value
21
+ groups = value.split(',').map(&:to_sym) if value
22
22
  end
23
23
  end.parse!
24
24
  end
25
25
 
26
26
  # Load Rails environment if we're in Rails
27
- rails_application = File.expand_path("./config/application.rb")
28
- require rails_application if File.exists?(rails_application)
27
+ rails_application = File.expand_path('./config/application.rb')
28
+ require rails_application if File.exist?(rails_application)
29
29
 
30
30
  Stairs::Runner.new(groups).run!
@@ -1,17 +1,17 @@
1
- require "stairs/version"
2
- require "active_support"
3
- require "active_support/core_ext"
4
- require "colorize"
1
+ require 'stairs/version'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+ require 'colorize'
5
5
 
6
6
  module Stairs
7
- autoload :Step, "stairs/step"
8
- autoload :Script, "stairs/script"
9
- autoload :Steps, "stairs/steps"
10
- autoload :EnvAdapters, "stairs/env_adapters"
11
- autoload :Configuration, "stairs/configuration"
12
- autoload :InteractiveConfiguration, "stairs/interactive_configuration"
13
- autoload :Util, "stairs/util"
14
- autoload :Runner, "stairs/runner"
7
+ autoload :Step, 'stairs/step'
8
+ autoload :Script, 'stairs/script'
9
+ autoload :Steps, 'stairs/steps'
10
+ autoload :EnvAdapters, 'stairs/env_adapters'
11
+ autoload :Configuration, 'stairs/configuration'
12
+ autoload :InteractiveConfiguration, 'stairs/interactive_configuration'
13
+ autoload :Util, 'stairs/util'
14
+ autoload :Runner, 'stairs/runner'
15
15
 
16
16
  class << self
17
17
  def configure
@@ -28,4 +28,4 @@ module Stairs
28
28
  end
29
29
  end
30
30
 
31
- require "stairs/railtie" if defined?(Rails)
31
+ require 'stairs/railtie' if defined?(Rails)
@@ -1,17 +1,17 @@
1
1
  module Stairs
2
2
  module EnvAdapters
3
- autoload :Rbenv, "stairs/env_adapters/rbenv"
4
- autoload :RVM, "stairs/env_adapters/rvm"
5
- autoload :Dotenv, "stairs/env_adapters/dotenv"
3
+ autoload :Rbenv, 'stairs/env_adapters/rbenv'
4
+ autoload :RVM, 'stairs/env_adapters/rvm'
5
+ autoload :Dotenv, 'stairs/env_adapters/dotenv'
6
6
 
7
7
  ADAPTERS = {
8
8
  dotenv: Dotenv,
9
9
  rbenv: Rbenv,
10
- rvm: RVM,
11
- }
10
+ rvm: RVM
11
+ }.freeze
12
12
 
13
13
  def self.recommended_adapter
14
- ADAPTERS.values.find { |a| a.present? }
14
+ ADAPTERS.values.find(&:present?)
15
15
  end
16
16
 
17
17
  def self.name_for_adapter_class(adapter)
@@ -2,19 +2,19 @@ module Stairs
2
2
  module EnvAdapters
3
3
  class Dotenv
4
4
  def self.present?
5
- defined? ::Dotenv
5
+ !!defined?(::Dotenv)
6
6
  end
7
7
 
8
8
  def set(name, value)
9
9
  Util::FileMutation.replace_or_append(
10
10
  Regexp.new("^#{name}=(.*)$"),
11
11
  "#{name}=#{value}",
12
- ".env",
12
+ '.env'
13
13
  )
14
14
  end
15
15
 
16
16
  def unset(name)
17
- Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), ".env"
17
+ Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), '.env'
18
18
  end
19
19
  end
20
20
  end
@@ -3,19 +3,19 @@ module Stairs
3
3
  class Rbenv
4
4
  def self.present?
5
5
  `which rbenv-vars`
6
- $?.success?
6
+ $CHILD_STATUS.success?
7
7
  end
8
8
 
9
9
  def set(name, value)
10
10
  Util::FileMutation.replace_or_append(
11
11
  Regexp.new("^#{name}=(.*)$"),
12
12
  "#{name}=#{value}",
13
- ".rbenv-vars",
13
+ '.rbenv-vars'
14
14
  )
15
15
  end
16
16
 
17
17
  def unset(name)
18
- Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), ".rbenv-vars"
18
+ Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), '.rbenv-vars'
19
19
  end
20
20
  end
21
21
  end
@@ -3,19 +3,19 @@ module Stairs
3
3
  class RVM
4
4
  def self.present?
5
5
  `which rvm`
6
- $?.success?
6
+ $CHILD_STATUS.success?
7
7
  end
8
8
 
9
9
  def set(name, value)
10
10
  Util::FileMutation.replace_or_append(
11
11
  Regexp.new("^export #{name}=(.*)$"),
12
12
  "export #{name}=#{value}",
13
- ".rvmrc",
13
+ '.rvmrc'
14
14
  )
15
15
  end
16
16
 
17
17
  def unset(name)
18
- Util::FileMutation.remove Regexp.new("^export #{name}=(.*)\n"), ".rvmrc"
18
+ Util::FileMutation.remove Regexp.new("^export #{name}=(.*)\n"), '.rvmrc'
19
19
  end
20
20
  end
21
21
  end
@@ -1,7 +1,7 @@
1
1
  module Stairs
2
2
  class InteractiveConfiguration < Stairs::Step
3
- title "Configuration"
4
- description "Interactive prompt for configuring Stairs"
3
+ title 'Configuration'
4
+ description 'Interactive prompt for configuring Stairs'
5
5
 
6
6
  def run!
7
7
  if Stairs.configuration.use_defaults
@@ -26,7 +26,7 @@ module Stairs
26
26
  end
27
27
 
28
28
  def select_env_adapter
29
- choice "Which would you prefer?", adapter_names do |name|
29
+ choice 'Which would you prefer?', adapter_names do |name|
30
30
  adapter_class = Stairs::EnvAdapters::ADAPTERS[name.to_sym]
31
31
  Stairs.configuration.env_adapter = adapter_class.new
32
32
  end
@@ -45,9 +45,9 @@ module Stairs
45
45
  end
46
46
 
47
47
  def prompt
48
- "".tap do |message|
48
+ ''.tap do |message|
49
49
  message << "Looks like you're using #{recommended_adapter_name} to "
50
- message << "manage environment variables. Is this correct?"
50
+ message << 'manage environment variables. Is this correct?'
51
51
  end
52
52
  end
53
53
 
@@ -56,12 +56,12 @@ module Stairs
56
56
  end
57
57
 
58
58
  def require_installed_adapter!
59
- unless recommended_adapter
60
- abort <<-MSG
61
- Please install a supported ENV variable manager:
62
- #{adapter_names.join(", ")}
63
- MSG
64
- end
59
+ return if recommended_adapter
60
+
61
+ abort <<-MSG
62
+ Please install a supported ENV variable manager:
63
+ #{adapter_names.join(', ')}
64
+ MSG
65
65
  end
66
66
  end
67
67
  end
@@ -1,7 +1,7 @@
1
1
  module Stairs
2
2
  class Railtie < Rails::Railtie
3
3
  rake_tasks do
4
- load "stairs/tasks.rb"
4
+ load 'stairs/tasks.rb'
5
5
  end
6
6
  end
7
7
  end
@@ -1,12 +1,12 @@
1
1
  module Stairs
2
2
  class Runner
3
- def initialize(groups=nil)
3
+ def initialize(groups = nil)
4
4
  @groups = groups
5
5
  end
6
6
 
7
7
  def run!
8
8
  Stairs::InteractiveConfiguration.new.run!
9
- Stairs::Script.new("setup.rb", groups).run!
9
+ Stairs::Script.new('setup.rb', groups).run!
10
10
  end
11
11
 
12
12
  private
@@ -36,12 +36,10 @@ module Stairs
36
36
  end
37
37
 
38
38
  # Prompt user to provide input
39
- def provide(prompt, options={})
39
+ def provide(prompt, options = {})
40
40
  options.reverse_merge! required: true, default: nil
41
41
  required = options[:required] && !options[:default]
42
-
43
- prompt << " (leave blank for #{options[:default]})" if options[:default]
44
- prompt << ": "
42
+ prompt = "#{defaulted_prompt(prompt, options[:default])}: "
45
43
 
46
44
  if Stairs.configuration.use_defaults && options[:default]
47
45
  options[:default]
@@ -86,7 +84,7 @@ module Stairs
86
84
  # Embed a step where step_name is a symbol that can be resolved to a class
87
85
  # in Stairs::Steps or a block is provided to be executed in an instance
88
86
  # of Step
89
- def setup(step_name, options={}, &block)
87
+ def setup(step_name, options = {}, &block)
90
88
  if block_given?
91
89
  Step.new(groups, options).tap do |step|
92
90
  step.define_singleton_method :run, &block
@@ -103,7 +101,7 @@ module Stairs
103
101
  end
104
102
 
105
103
  def finish(message)
106
- puts "== All done!".green
104
+ puts '== All done!'.green
107
105
  puts message.green
108
106
  end
109
107
 
@@ -115,12 +113,17 @@ module Stairs
115
113
 
116
114
  def run_step?
117
115
  return true if options[:required]
118
- choice "This step is optional, would you like to perform it?"
116
+ choice 'This step is optional, would you like to perform it?'
117
+ end
118
+
119
+ def defaulted_prompt(prompt, default = nil)
120
+ return prompt if default.nil?
121
+ "#{prompt} (leave blank for #{default})"
119
122
  end
120
123
 
121
124
  class Choice
122
125
  # TODO: shouldn't care about case?
123
- def initialize(question, choices=%w(Y N), &block)
126
+ def initialize(question, choices = %w(Y N), &block)
124
127
  @question = question
125
128
  @choices = choices
126
129
  @block = block
@@ -136,22 +139,22 @@ module Stairs
136
139
  attr_reader :question, :choices, :block
137
140
 
138
141
  def prompt
139
- "#{question} (#{choices.join("/")}): "
142
+ "#{question} (#{choices.join('/')}): "
140
143
  end
141
144
 
142
145
  def processed_response
143
146
  @processed_response ||= case response
144
- when "Y"
145
- true
146
- when "N"
147
- false
148
- else
149
- response
150
- end
147
+ when 'Y'
148
+ true
149
+ when 'N'
150
+ false
151
+ else
152
+ response
153
+ end
151
154
  end
152
155
 
153
156
  def response
154
- @reponse ||= Stairs::Util::CLI.collect prompt.blue do |value, i|
157
+ @reponse ||= Stairs::Util::CLI.collect prompt.blue do |value, _i|
155
158
  choices.include? value
156
159
  end
157
160
  end
@@ -1,7 +1,7 @@
1
1
  module Stairs
2
2
  module Steps
3
- autoload :SecretKeyBase, "stairs/steps/secret_key_base"
4
- autoload :Postgresql, "stairs/steps/postgresql"
5
- autoload :Facebook, "stairs/steps/facebook"
3
+ autoload :SecretKeyBase, 'stairs/steps/secret_key_base'
4
+ autoload :Postgresql, 'stairs/steps/postgresql'
5
+ autoload :Facebook, 'stairs/steps/facebook'
6
6
  end
7
7
  end
@@ -1,22 +1,22 @@
1
1
  module Stairs
2
2
  module Steps
3
3
  class Facebook < Stairs::Step
4
- title "Facebook App"
5
- description "Configure credentials for Facebook app"
4
+ title 'Facebook App'
5
+ description 'Configure credentials for Facebook app'
6
6
 
7
7
  def run
8
- env id_name, provide("Facebook App ID")
9
- env secret_name, provide("Facebook App Secret")
8
+ env id_name, provide('Facebook App ID')
9
+ env secret_name, provide('Facebook App Secret')
10
10
  end
11
11
 
12
12
  private
13
13
 
14
14
  def id_name
15
- options[:app_id] || "FACEBOOK_ID"
15
+ options[:app_id] || 'FACEBOOK_ID'
16
16
  end
17
17
 
18
18
  def secret_name
19
- options[:app_secret] || "FACEBOOK_SECRET"
19
+ options[:app_secret] || 'FACEBOOK_SECRET'
20
20
  end
21
21
  end
22
22
  end