stairs 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +57 -40
- data/lib/stairs/steps/facebook.rb +13 -0
- data/lib/stairs/steps/postgresql.rb +63 -0
- data/lib/stairs/steps.rb +2 -0
- data/lib/stairs/version.rb +1 -1
- data/spec/spec_helper.rb +7 -2
- data/stairs.gemspec +2 -0
- data/templates/postgresql/database.yml +15 -0
- metadata +33 -4
- data/spec/support/mock_stdout.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10da079ffb8a6117c979d9c4433a9708bac58baa
|
4
|
+
data.tar.gz: c21c9c77a94b8b6f6c8e2dba3c746d0c0739f22b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65567fc827aa2f8696d16c387df52bbecfe2649d8a204e1884def2c84df2df410098776a2ab6a3b8f76588fa67989a8f7d0d32556091052c36b87692438dad67
|
7
|
+
data.tar.gz: 13af55966c609b0e9d8295632291a807e2f7db52270cfd1f50e4db45ab2c8fde99c22ba089f396fbe36f1eb094fa204e280927266c1d32dc48ad4a322c9428ed
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
# Stairs
|
2
2
|
|
3
|
-
It's a pain to
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
It's a pain to set up new developers on your codebase. Stairs makes it easy.
|
4
|
+
|
5
|
+
### The Problem
|
6
|
+
|
7
|
+
Apps these days come with dependencies—S3, Facebook, Twitter, Zencoder, etc. We
|
8
|
+
can stub certain things in development, but we also want to make sure we're
|
9
|
+
developing in a realistic setting. Satisfying all of these requirements can
|
10
|
+
really slow down onboarding time when adding new developers to your existing
|
11
|
+
codebase.
|
7
12
|
|
8
|
-
|
9
|
-
|
13
|
+
### The Solution
|
14
|
+
|
15
|
+
Every codebase should come with a script to set itself up. An interactive
|
16
|
+
README, if you will. __Stairs__ aims to provide the tools to make writing these
|
17
|
+
scripts fast and easy. Scripts try to automate as much as possible and provide
|
18
|
+
interactive prompts for everything else.
|
10
19
|
|
11
20
|
[![Build Status](https://travis-ci.org/patbenatar/stairs.png?branch=master)](https://travis-ci.org/patbenatar/stairs)
|
12
21
|
[![Code Climate](https://codeclimate.com/github/patbenatar/stairs.png)](https://codeclimate.com/github/patbenatar/stairs)
|
@@ -62,37 +71,7 @@ rake "db:setup"
|
|
62
71
|
finish "Just run rails s and sidekiq to get rolling!"
|
63
72
|
```
|
64
73
|
|
65
|
-
|
66
|
-
|
67
|
-
Given the above script, the CLI might look like this.
|
68
|
-
|
69
|
-
```
|
70
|
-
$ rake newb
|
71
|
-
Looks like you're using rbenv to manage environment variables. Is this correct? (Y/N): Y
|
72
|
-
= Running script setup.rb
|
73
|
-
== Running bundle
|
74
|
-
...
|
75
|
-
== Completed bundle
|
76
|
-
== Running S3
|
77
|
-
AWS access key: 39u39d9u291
|
78
|
-
AWS secret: 19jd920i10is0i01i0s01ks0kfknkje
|
79
|
-
Do you have an existing bucket? (Y/N): Y
|
80
|
-
Bucket name (leave blank for app-dev): my-cool-bucket
|
81
|
-
== Completed S3
|
82
|
-
== Starting Zencoder
|
83
|
-
This step is optional, would you like to perform it? (Y/N): N
|
84
|
-
== Completed Zencoder
|
85
|
-
== Starting Misc
|
86
|
-
Cool check it value: w00t
|
87
|
-
== Completed Misc
|
88
|
-
== Running db:setup
|
89
|
-
...
|
90
|
-
== Completed db:setup
|
91
|
-
== All done!
|
92
|
-
Run rails s and sidekiq to get rolling!
|
93
|
-
```
|
94
|
-
|
95
|
-
## DSL
|
74
|
+
[See Example CLI](#example-cli)
|
96
75
|
|
97
76
|
### Collecting values
|
98
77
|
```ruby
|
@@ -111,6 +90,8 @@ dinner = choice "Meat or vegetables?", ["Meat", "Vegetables"]
|
|
111
90
|
```
|
112
91
|
|
113
92
|
### Setting env vars
|
93
|
+
Stairs currently supports writing environment variables for rbenv-vars, RVM, and dotenv.
|
94
|
+
|
114
95
|
```ruby
|
115
96
|
env "NAME", value
|
116
97
|
```
|
@@ -155,15 +136,20 @@ setup :facebook, required: false
|
|
155
136
|
## Plugins for common setups
|
156
137
|
|
157
138
|
### Built-in
|
139
|
+
|
158
140
|
* `:secret_token` sets a secure random secret token
|
141
|
+
* `:postgresql` quickly setup database.yml for use with PostgreSQL
|
142
|
+
* `:facebook` interactive prompt for setting Facebook app credentials
|
143
|
+
|
144
|
+
### Available as independent gems
|
145
|
+
|
146
|
+
Any plugin that has specific dependencies on third party gems is shipped
|
147
|
+
independently to avoid maintaining those dependencies within Stairs.
|
159
148
|
|
160
|
-
### Available as extension gems
|
161
149
|
* `:s3` interactive prompt for setting AWS + S3 bucket access credentials:
|
162
150
|
[patbenatar/stairs-steps-s3][s3]
|
163
151
|
* `:balanced` automatically creates a test Marketplace on Balanced:
|
164
152
|
[patbenatar/stairs-steps-balanced][balanced]
|
165
|
-
* `:facebook` interactive prompt for setting Facebook app credentials:
|
166
|
-
[patbenatar/stairs-steps-facebook][facebook]
|
167
153
|
|
168
154
|
### Defining custom plugins
|
169
155
|
|
@@ -171,6 +157,37 @@ Steps inherit from `Stairs::Step` and live in `Stairs::Steps`, have a title,
|
|
171
157
|
description, and implement the `run` method. See those included and in the
|
172
158
|
various extension gems for examples.
|
173
159
|
|
160
|
+
## Example CLI
|
161
|
+
|
162
|
+
Given the [example script above](#defining-scripts), the CLI would look like
|
163
|
+
this:
|
164
|
+
|
165
|
+
```
|
166
|
+
$ rake newb
|
167
|
+
Looks like you're using rbenv to manage environment variables. Is this correct? (Y/N): Y
|
168
|
+
= Running script setup.rb
|
169
|
+
== Running bundle
|
170
|
+
...
|
171
|
+
== Completed bundle
|
172
|
+
== Running S3
|
173
|
+
AWS access key: 39u39d9u291
|
174
|
+
AWS secret: 19jd920i10is0i01i0s01ks0kfknkje
|
175
|
+
Do you have an existing bucket? (Y/N): Y
|
176
|
+
Bucket name (leave blank for app-dev): my-cool-bucket
|
177
|
+
== Completed S3
|
178
|
+
== Starting Zencoder
|
179
|
+
This step is optional, would you like to perform it? (Y/N): N
|
180
|
+
== Completed Zencoder
|
181
|
+
== Starting Misc
|
182
|
+
Cool check it value: w00t
|
183
|
+
== Completed Misc
|
184
|
+
== Running db:setup
|
185
|
+
...
|
186
|
+
== Completed db:setup
|
187
|
+
== All done!
|
188
|
+
Run rails s and sidekiq to get rolling!
|
189
|
+
```
|
190
|
+
|
174
191
|
## Contributing
|
175
192
|
|
176
193
|
1. Fork it
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Stairs
|
2
|
+
module Steps
|
3
|
+
class Facebook < Stairs::Step
|
4
|
+
title "Facebook App"
|
5
|
+
description "Configure credentials for Facebook app"
|
6
|
+
|
7
|
+
def run
|
8
|
+
env "FACEBOOK_ID", provide("Facebook App ID")
|
9
|
+
env "FACEBOOK_SECRET", provide("Facebook App Secret")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Stairs
|
2
|
+
module Steps
|
3
|
+
class Postgresql < Stairs::Step
|
4
|
+
title "PostgreSQL"
|
5
|
+
description "Setup database.yml for PostgreSQL"
|
6
|
+
|
7
|
+
def run
|
8
|
+
set_database_name
|
9
|
+
set_test_database_name
|
10
|
+
set_username
|
11
|
+
set_password
|
12
|
+
|
13
|
+
write contents, "config/database.yml"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def set_database_name
|
19
|
+
contents.gsub!(
|
20
|
+
"{{database_name}}",
|
21
|
+
provide("Database name", default: "#{app_name}_development"),
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_test_database_name
|
26
|
+
contents.gsub!(
|
27
|
+
"{{test_database_name}}",
|
28
|
+
provide("Test database name", default: "#{app_name}_test"),
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_username
|
33
|
+
contents.gsub!(
|
34
|
+
"{{username}}",
|
35
|
+
provide("User", default: `whoami`.strip),
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_password
|
40
|
+
contents.gsub!(
|
41
|
+
"{{password}}",
|
42
|
+
provide("Password", default: ""),
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def app_name
|
47
|
+
@app_name ||= Rails.application.class.parent_name.downcase
|
48
|
+
end
|
49
|
+
|
50
|
+
def contents
|
51
|
+
@contents ||= template
|
52
|
+
end
|
53
|
+
|
54
|
+
def template
|
55
|
+
File.read "#{gem_root}/templates/postgresql/database.yml"
|
56
|
+
end
|
57
|
+
|
58
|
+
def gem_root
|
59
|
+
"#{File.dirname(__FILE__)}/../../.."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/stairs/steps.rb
CHANGED
data/lib/stairs/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
require "bundler"
|
2
2
|
Bundler.require
|
3
3
|
|
4
|
+
require "codeclimate-test-reporter"
|
5
|
+
CodeClimate::TestReporter.start
|
6
|
+
|
4
7
|
require "stairs"
|
5
8
|
|
9
|
+
require "mock_stdio"
|
10
|
+
|
6
11
|
Dir["./spec/support/**/*.rb"].each { |f| require f }
|
7
12
|
|
8
13
|
RSpec.configure do |config|
|
@@ -10,8 +15,8 @@ RSpec.configure do |config|
|
|
10
15
|
config.run_all_when_everything_filtered = true
|
11
16
|
config.filter_run :focus
|
12
17
|
|
13
|
-
config.include
|
18
|
+
config.include MockStdio
|
14
19
|
|
15
20
|
config.before(:all, &:silence_output)
|
16
21
|
config.after(:all, &:enable_output)
|
17
|
-
end
|
22
|
+
end
|
data/stairs.gemspec
CHANGED
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "fakefs", "~> 0.4.3"
|
29
29
|
spec.add_development_dependency "rubocop", "~> 0.14.1"
|
30
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"
|
31
33
|
|
32
34
|
spec.add_dependency "activesupport", ">= 3.2.0"
|
33
35
|
spec.add_dependency "colorize", "~> 0.6.0"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
development:
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
database: {{database_name}}
|
5
|
+
pool: 5
|
6
|
+
username: {{username}}
|
7
|
+
password: {{password}}
|
8
|
+
|
9
|
+
test:
|
10
|
+
adapter: postgresql
|
11
|
+
encoding: unicode
|
12
|
+
database: {{test_database_name}}
|
13
|
+
pool: 5
|
14
|
+
username: {{username}}
|
15
|
+
password: {{password}}
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- patbenatar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,34 @@ dependencies:
|
|
150
150
|
- - ~>
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 1.0.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: codeclimate-test-reporter
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: mock_stdio
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.0.1
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ~>
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.0.1
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: activesupport
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +236,8 @@ files:
|
|
208
236
|
- lib/stairs/script.rb
|
209
237
|
- lib/stairs/step.rb
|
210
238
|
- lib/stairs/steps.rb
|
239
|
+
- lib/stairs/steps/facebook.rb
|
240
|
+
- lib/stairs/steps/postgresql.rb
|
211
241
|
- lib/stairs/steps/secret_token.rb
|
212
242
|
- lib/stairs/tasks.rb
|
213
243
|
- lib/stairs/util.rb
|
@@ -226,8 +256,8 @@ files:
|
|
226
256
|
- spec/lib/stairs/util/cli_spec.rb
|
227
257
|
- spec/lib/stairs/util/file_mutation_spec.rb
|
228
258
|
- spec/spec_helper.rb
|
229
|
-
- spec/support/mock_stdout.rb
|
230
259
|
- stairs.gemspec
|
260
|
+
- templates/postgresql/database.yml
|
231
261
|
homepage: http://github.com/patbenatar/stairs
|
232
262
|
licenses:
|
233
263
|
- MIT
|
@@ -265,4 +295,3 @@ test_files:
|
|
265
295
|
- spec/lib/stairs/util/cli_spec.rb
|
266
296
|
- spec/lib/stairs/util/file_mutation_spec.rb
|
267
297
|
- spec/spec_helper.rb
|
268
|
-
- spec/support/mock_stdout.rb
|
data/spec/support/mock_stdout.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require "stringio"
|
2
|
-
|
3
|
-
module MockStdIO
|
4
|
-
def follow_prompts(*responses, &block)
|
5
|
-
old_stdin = $stdin
|
6
|
-
old_stdout = $stdout
|
7
|
-
|
8
|
-
$stdin = StringIO.new("", "r+")
|
9
|
-
fake_stdout = StringIO.new
|
10
|
-
$stdout = fake_stdout
|
11
|
-
|
12
|
-
responses.each { |r| $stdin << "#{r}\n" }
|
13
|
-
$stdin.rewind
|
14
|
-
|
15
|
-
block.call
|
16
|
-
|
17
|
-
fake_stdout.string
|
18
|
-
ensure
|
19
|
-
$stdin = old_stdin
|
20
|
-
$stdout = old_stdout
|
21
|
-
end
|
22
|
-
|
23
|
-
def capture_stdout(&block)
|
24
|
-
old_stdout = $stdout
|
25
|
-
|
26
|
-
fake_stdout = StringIO.new
|
27
|
-
$stdout = fake_stdout
|
28
|
-
|
29
|
-
block.call
|
30
|
-
|
31
|
-
fake_stdout.string
|
32
|
-
ensure
|
33
|
-
$stdout = old_stdout
|
34
|
-
end
|
35
|
-
|
36
|
-
def silence_output
|
37
|
-
@orig_stderr = $stderr
|
38
|
-
@orig_stdout = $stdout
|
39
|
-
|
40
|
-
# redirect stderr and stdout to /dev/null
|
41
|
-
$stderr = File.new("/dev/null", "w")
|
42
|
-
$stdout = File.new("/dev/null", "w")
|
43
|
-
end
|
44
|
-
|
45
|
-
# Replace stdout and stderr so anything else is output correctly.
|
46
|
-
def enable_output
|
47
|
-
$stderr = @orig_stderr
|
48
|
-
$stdout = @orig_stdout
|
49
|
-
@orig_stderr = nil
|
50
|
-
@orig_stdout = nil
|
51
|
-
end
|
52
|
-
end
|