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
@@ -1,12 +1,14 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Steps::SecretKeyBase do
4
4
  subject { described_class.new }
5
5
 
6
- describe "#run" do
7
- it "generates a securerandom hex and sets to SECRET_KEY_BASE" do
8
- SecureRandom.stub hex: "imtotallysecurebro"
9
- subject.should_receive(:env).with("SECRET_KEY_BASE", "imtotallysecurebro")
6
+ describe '#run' do
7
+ it 'generates a securerandom hex and sets to SECRET_KEY_BASE' do
8
+ allow(SecureRandom).to receive(:hex).and_return('imtotallysecurebro')
9
+ expect(subject)
10
+ .to receive(:env).with('SECRET_KEY_BASE', 'imtotallysecurebro')
11
+
10
12
  subject.run
11
13
  end
12
14
  end
@@ -1,57 +1,57 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Util::CLI do
4
4
  subject { described_class }
5
5
 
6
- describe ".get" do
7
- it "outputs the prompt to screen" do
8
- output = follow_prompts("test") { subject.get("itefeffe") }
9
- expect(output).to include "itefeffe"
6
+ describe '.get' do
7
+ it 'outputs the prompt to screen' do
8
+ output = follow_prompts('test') { subject.get('itefeffe') }
9
+ expect(output).to include 'itefeffe'
10
10
  end
11
11
 
12
- it "collects and returns trimmed input" do
13
- follow_prompts "test" do
14
- expect(subject.get("it")).to eq "test"
12
+ it 'collects and returns trimmed input' do
13
+ follow_prompts 'test' do
14
+ expect(subject.get('it')).to eq 'test'
15
15
  end
16
16
  end
17
17
 
18
- it "returns nil for empty input" do
19
- follow_prompts "" do
20
- expect(subject.get("it")).to eq nil
18
+ it 'returns nil for empty input' do
19
+ follow_prompts '' do
20
+ expect(subject.get('it')).to eq nil
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
- describe ".collect" do
26
- it "returns the user provided input" do
27
- follow_prompts "test" do
28
- expect(subject.collect("itefeffe")).to eq "test"
25
+ describe '.collect' do
26
+ it 'returns the user provided input' do
27
+ follow_prompts 'test' do
28
+ expect(subject.collect('itefeffe')).to eq 'test'
29
29
  end
30
30
  end
31
31
 
32
- context "required" do
33
- it "repeatedly prompts until a non-empty value is received" do
34
- follow_prompts "", "", "", "finally" do
35
- expect(subject.collect("a value")).to eq "finally"
32
+ context 'required' do
33
+ it 'repeatedly prompts until a non-empty value is received' do
34
+ follow_prompts '', '', '', 'finally' do
35
+ expect(subject.collect('a value')).to eq 'finally'
36
36
  end
37
37
  end
38
38
  end
39
39
 
40
- context "not required" do
41
- it "returns nil for empty input" do
42
- follow_prompts "" do
43
- expect(subject.collect("gimme", required: false)).to eq nil
40
+ context 'not required' do
41
+ it 'returns nil for empty input' do
42
+ follow_prompts '' do
43
+ expect(subject.collect('gimme', required: false)).to eq nil
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
- context "with custom validation block" do
49
- it "repeatedly prompts until a valid value is received" do
50
- follow_prompts "", "", "wrong", "right" do
51
- response = subject.collect("a value") { |v, i| v == "right" }
52
- expect(response).to eq "right"
48
+ context 'with custom validation block' do
49
+ it 'repeatedly prompts until a valid value is received' do
50
+ follow_prompts '', '', 'wrong', 'right' do
51
+ response = subject.collect('a value') { |v, _i| v == 'right' }
52
+ expect(response).to eq 'right'
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -1,128 +1,128 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Util::FileMutation do
4
- let(:filename) { "file.txt" }
4
+ let(:filename) { 'file.txt' }
5
5
 
6
- describe ".replace_or_append" do
7
- context "when the pattern exists in the file" do
6
+ describe '.replace_or_append' do
7
+ context 'when the pattern exists in the file' do
8
8
  before do
9
- File.open(filename, "w") do |file|
9
+ File.open(filename, 'w') do |file|
10
10
  file.write("line1\nline2\nline3\n")
11
11
  end
12
12
  end
13
13
 
14
14
  after { File.delete(filename) }
15
15
 
16
- it "replaces the match and writes back to the file" do
17
- described_class.replace_or_append /line2/, "newLINE2", filename
16
+ it 'replaces the match and writes back to the file' do
17
+ described_class.replace_or_append(/line2/, 'newLINE2', filename)
18
18
  expect(File.read(filename)).to eq "line1\nnewLINE2\nline3\n"
19
19
  end
20
20
  end
21
21
 
22
- context "when the pattern does not exist in the file" do
22
+ context 'when the pattern does not exist in the file' do
23
23
  before do
24
- File.open(filename, "w") do |file|
24
+ File.open(filename, 'w') do |file|
25
25
  file.write("line1\nline2\nline3\n")
26
26
  end
27
27
  end
28
28
 
29
29
  after { File.delete(filename) }
30
30
 
31
- it "appends to the end of the file" do
32
- described_class.replace_or_append /line4/, "line4", filename
31
+ it 'appends to the end of the file' do
32
+ described_class.replace_or_append(/line4/, 'line4', filename)
33
33
  expect(File.read(filename)).to eq "line1\nline2\nline3\nline4\n"
34
34
  end
35
35
  end
36
36
  end
37
37
 
38
- describe ".remove" do
38
+ describe '.remove' do
39
39
  before do
40
- File.open(filename, "w") do |file|
40
+ File.open(filename, 'w') do |file|
41
41
  file.write "VAR_1=hey\nVAR_2=hello\nVAR_3=hi\n"
42
42
  end
43
43
  end
44
44
 
45
- context "when the pattern exists in file" do
46
- it "removes the match from the file" do
47
- subject.remove /^VAR_2=(.*)\n/, filename
45
+ context 'when the pattern exists in file' do
46
+ it 'removes the match from the file' do
47
+ subject.remove(/^VAR_2=(.*)\n/, filename)
48
48
  expect(File.read(filename)).to eq "VAR_1=hey\nVAR_3=hi\n"
49
49
  end
50
50
 
51
- context "and is the last line without a trailing newline" do
51
+ context 'and is the last line without a trailing newline' do
52
52
  before do
53
- File.open(filename, "w+") do |file|
53
+ File.open(filename, 'w+') do |file|
54
54
  file.write "VAR_1=hey\nVAR_2=hello\nVAR_3=hi"
55
55
  end
56
56
 
57
- it "still matches and removes it" do
58
- subject.remove /^VAR_3=(.*)\n/, filename
57
+ it 'still matches and removes it' do
58
+ subject.remove(/^VAR_3=(.*)\n/, filename)
59
59
  expect(File.read(filename)).to eq "VAR_1=hey\nVAR_2=hello\n"
60
60
  end
61
61
  end
62
62
  end
63
63
  end
64
64
 
65
- context "when the pattern does not exist in file" do
66
- it "leaves the file untouched" do
67
- subject.remove /^VAR_2=(.*)\n/, filename
65
+ context 'when the pattern does not exist in file' do
66
+ it 'leaves the file untouched' do
67
+ subject.remove(/^VAR_2=(.*)\n/, filename)
68
68
  expect(File.read(filename)).to eq "VAR_1=hey\nVAR_3=hi\n"
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
- describe ".write_line" do
73
+ describe '.write_line' do
74
74
  before do
75
- File.open(filename, "w") do |file|
75
+ File.open(filename, 'w') do |file|
76
76
  file.write("line1\nline2\n")
77
77
  end
78
78
  end
79
79
 
80
80
  after { File.delete(filename) }
81
81
 
82
- it "appends a line to the bottom of the file" do
83
- described_class.write_line "line3", filename
82
+ it 'appends a line to the bottom of the file' do
83
+ described_class.write_line 'line3', filename
84
84
  expect(File.read(filename)).to eq "line1\nline2\nline3\n"
85
85
  end
86
86
 
87
- context "when there is no newline at the bottom" do
87
+ context 'when there is no newline at the bottom' do
88
88
  before do
89
- File.open(filename, "w+") do |file|
89
+ File.open(filename, 'w+') do |file|
90
90
  file.write("line1\nline2")
91
91
  end
92
92
  end
93
93
 
94
- it "adds a newline before appending the line" do
95
- described_class.write_line "line3", filename
94
+ it 'adds a newline before appending the line' do
95
+ described_class.write_line 'line3', filename
96
96
  expect(File.read(filename)).to eq "line1\nline2\nline3\n"
97
97
  end
98
98
  end
99
99
 
100
- context "when the file is empty" do
100
+ context 'when the file is empty' do
101
101
  before do
102
- File.open filename, "w+" do |file|
103
- file.write ""
102
+ File.open filename, 'w+' do |file|
103
+ file.write ''
104
104
  end
105
105
  end
106
106
 
107
- it "writes to the first line of the line" do
108
- described_class.write_line "line1", filename
107
+ it 'writes to the first line of the line' do
108
+ described_class.write_line 'line1', filename
109
109
  expect(File.read(filename)).to eq "line1\n"
110
110
  end
111
111
  end
112
112
  end
113
113
 
114
- describe ".write" do
115
- context "when the file exists" do
114
+ describe '.write' do
115
+ context 'when the file exists' do
116
116
  before do
117
- File.open(filename, "w") do |file|
117
+ File.open(filename, 'w') do |file|
118
118
  file.write("some content\n")
119
119
  end
120
120
  end
121
121
 
122
122
  after { File.delete(filename) }
123
123
 
124
- it "replaces the contents of the file and leaves trailing newline" do
125
- described_class.write "new content", filename
124
+ it 'replaces the contents of the file and leaves trailing newline' do
125
+ described_class.write 'new content', filename
126
126
  expect(File.read(filename)).to eq "new content\n"
127
127
  end
128
128
  end
@@ -130,13 +130,13 @@ describe Stairs::Util::FileMutation do
130
130
  context "when the file doesn't exist" do
131
131
  after { File.delete(filename) }
132
132
 
133
- it "creates a file" do
134
- described_class.write "other content", filename
135
- expect(File.exists?(filename)).to be_true
133
+ it 'creates a file' do
134
+ described_class.write 'other content', filename
135
+ expect(File.exist?(filename)).to eq true
136
136
  end
137
137
 
138
- it "writes the contents to the file" do
139
- described_class.write "my favorite content", filename
138
+ it 'writes the contents to the file' do
139
+ described_class.write 'my favorite content', filename
140
140
  expect(File.read(filename)).to eq "my favorite content\n"
141
141
  end
142
142
  end
@@ -1,24 +1,22 @@
1
- require "bundler"
1
+ require 'bundler'
2
2
  Bundler.require
3
3
 
4
- require "codeclimate-test-reporter"
4
+ require 'codeclimate-test-reporter'
5
5
  CodeClimate::TestReporter.start
6
6
 
7
- require "stairs"
7
+ require 'stairs'
8
8
 
9
- require "mock_stdio"
9
+ require 'mock_stdio'
10
10
 
11
- Dir["./spec/support/**/*.rb"].each { |f| require f }
11
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
12
12
 
13
13
  RSpec.configure do |config|
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
14
  config.run_all_when_everything_filtered = true
16
15
  config.filter_run :focus
17
16
 
18
17
  config.include MockStdio
19
- config.include ConfigurationHelper
20
18
 
21
19
  config.before(:all, &:silence_output)
22
20
  config.after(:all, &:enable_output)
23
- config.after(:each, &:reset_configuration)
21
+ config.after(:each) { Stairs.reset_configuration! }
24
22
  end
@@ -4,33 +4,38 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'stairs/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "stairs"
7
+ spec.name = 'stairs'
8
8
  spec.version = Stairs::VERSION
9
- spec.authors = ["patbenatar"]
10
- spec.email = ["nick@gophilosophie.com"]
11
- spec.description = "It's a pain to setup new developers. Stairs is a utility and framework from which to write scripts for faster and easier setup of apps in new development environments. Scripts try to automate as much as possible and provide interactive prompts for everything else."
12
- spec.summary = "Setup Ruby apps in development fast and easy."
13
- spec.homepage = "http://github.com/patbenatar/stairs"
14
- spec.license = "MIT"
9
+ spec.authors = ['patbenatar']
10
+ spec.email = ['nick@gophilosophie.com']
11
+ spec.description = <<-DESCRIPTION
12
+ It's a pain to setup new developers. Stairs is a utility and framework from
13
+ which to write scripts for faster and easier setup of apps in new development
14
+ environments. Scripts try to automate as much as possible and provide
15
+ interactive prompts for everything else.
16
+ DESCRIPTION
17
+ spec.summary = 'Setup Ruby apps in development fast and easy.'
18
+ spec.homepage = 'http://github.com/patbenatar/stairs'
19
+ spec.license = 'MIT'
15
20
 
16
- spec.files = `git ls-files`.split($/)
21
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
22
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
20
25
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "pry"
24
- spec.add_development_dependency "rspec", "~> 2.14.1"
25
- spec.add_development_dependency "guard-rspec", "~> 4.0.3"
26
- spec.add_development_dependency "rb-fsevent", "~> 0.9.3"
27
- spec.add_development_dependency "awesome_print", "~> 1.2.0"
28
- spec.add_development_dependency "fakefs", "~> 0.4.3"
29
- spec.add_development_dependency "rubocop", "~> 0.20.1"
30
- spec.add_development_dependency "guard-rubocop", "~> 1.0.0"
31
- spec.add_development_dependency "codeclimate-test-reporter"
32
- spec.add_development_dependency "mock_stdio", "~> 0.0.1"
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'rspec', '~> 3.5.0'
30
+ spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
31
+ spec.add_development_dependency 'rb-fsevent', '~> 0.9.3'
32
+ spec.add_development_dependency 'awesome_print', '~> 1.2.0'
33
+ spec.add_development_dependency 'fakefs', '~> 0.4.3'
34
+ spec.add_development_dependency 'rubocop', '~> 0.47.1'
35
+ spec.add_development_dependency 'guard-rubocop', '~> 1.2.0'
36
+ spec.add_development_dependency 'codeclimate-test-reporter', '< 1.0.0'
37
+ spec.add_development_dependency 'mock_stdio', '~> 0.0.1'
33
38
 
34
- spec.add_dependency "activesupport", ">= 3.2.0"
35
- spec.add_dependency "colorize", "~> 0.6.0"
39
+ spec.add_dependency 'activesupport', '>= 3.2.0'
40
+ spec.add_dependency 'colorize', '~> 0.8.1'
36
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stairs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - patbenatar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.14.1
61
+ version: 3.5.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.14.1
68
+ version: 3.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 4.0.3
75
+ version: 4.7.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 4.0.3
82
+ version: 4.7.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rb-fsevent
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -128,42 +128,42 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.20.1
131
+ version: 0.47.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.20.1
138
+ version: 0.47.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: guard-rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.0
145
+ version: 1.2.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.0.0
152
+ version: 1.2.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: codeclimate-test-reporter
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "<"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 1.0.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - "<"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.0.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: mock_stdio
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -198,18 +198,19 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.6.0
201
+ version: 0.8.1
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.6.0
209
- description: It's a pain to setup new developers. Stairs is a utility and framework
210
- from which to write scripts for faster and easier setup of apps in new development
211
- environments. Scripts try to automate as much as possible and provide interactive
212
- prompts for everything else.
208
+ version: 0.8.1
209
+ description: |
210
+ It's a pain to setup new developers. Stairs is a utility and framework from
211
+ which to write scripts for faster and easier setup of apps in new development
212
+ environments. Scripts try to automate as much as possible and provide
213
+ interactive prompts for everything else.
213
214
  email:
214
215
  - nick@gophilosophie.com
215
216
  executables:
@@ -260,7 +261,6 @@ files:
260
261
  - spec/lib/stairs/util/cli_spec.rb
261
262
  - spec/lib/stairs/util/file_mutation_spec.rb
262
263
  - spec/spec_helper.rb
263
- - spec/support/configuration_helper.rb
264
264
  - stairs.gemspec
265
265
  - templates/postgresql/database.yml
266
266
  homepage: http://github.com/patbenatar/stairs
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  version: '0'
284
284
  requirements: []
285
285
  rubyforge_project:
286
- rubygems_version: 2.2.2
286
+ rubygems_version: 2.6.9
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: Setup Ruby apps in development fast and easy.
@@ -301,4 +301,3 @@ test_files:
301
301
  - spec/lib/stairs/util/cli_spec.rb
302
302
  - spec/lib/stairs/util/file_mutation_spec.rb
303
303
  - spec/spec_helper.rb
304
- - spec/support/configuration_helper.rb